namespace Bit.Seeder; /// /// Base interface for seeding operations. The base interface should not be used directly, rather use `IScene<Request>`. /// /// /// Scenes are components in the seeding system that create and configure test data. They follow /// a type-safe pattern using generics to ensure proper request/response handling while maintaining /// a common non-generic interface for dynamic invocation. /// public interface IScene { /// /// Gets the type of request this scene expects. /// /// The request type that this scene can process. Type GetRequestType(); /// /// Seeds data based on the provided request object. /// /// The request object containing parameters for the seeding operation. /// A scene result containing any returned data, mangle map, and entity tracking information. Task> SeedAsync(object request); } /// /// Generic scene interface for seeding operations with a specific request type. Does not return a value beyond tracking entities and a mangle map. /// /// The type of request object this scene accepts. /// /// Use this interface when your scene needs to process a specific request type but doesn't need to /// return any data beyond the standard mangle map for ID transformations and entity tracking. /// The explicit interface implementations allow this scene to be invoked dynamically through the /// base IScene interface while maintaining type safety in the implementation. /// public interface IScene : IScene where TRequest : class { /// /// Seeds data based on the provided strongly-typed request. /// /// The request object containing parameters for the seeding operation. /// A scene result containing the mangle map and entity tracking information. Task SeedAsync(TRequest request); /// /// Gets the request type for this scene. /// /// The type of TRequest. Type IScene.GetRequestType() => typeof(TRequest); /// /// Adapts the non-generic SeedAsync to the strongly-typed version. /// /// The request object to cast and process. /// A scene result wrapped as an object result. async Task> IScene.SeedAsync(object request) { var result = await SeedAsync((TRequest)request); return new SceneResult(mangleMap: result.MangleMap); } } /// /// Generic scene interface for seeding operations with a specific request type that returns typed data. /// /// The type of request object this scene accepts. Must be a reference type. /// The type of data this scene returns. Must be a reference type. /// /// Use this interface when your scene needs to return specific data that can be used by subsequent /// scenes or test logic. The result is wrapped in a SceneResult that also includes the mangle map /// and entity tracking information. The explicit interface implementations allow dynamic invocation /// while preserving type safety in the implementation. /// public interface IScene : IScene where TRequest : class where TResult : class { /// /// Seeds data based on the provided strongly-typed request and returns typed result data. /// /// The request object containing parameters for the seeding operation. /// A scene result containing the typed result data, mangle map, and entity tracking information. Task> SeedAsync(TRequest request); /// /// Gets the request type for this scene. /// /// The type of TRequest. Type IScene.GetRequestType() => typeof(TRequest); /// /// Adapts the non-generic SeedAsync to the strongly-typed version. /// /// The request object to cast and process. /// A scene result with the typed result cast to object. async Task> IScene.SeedAsync(object request) => (SceneResult)await SeedAsync((TRequest)request); }