/// <summary> /// Initializes a new instance of the <see cref = "AutoMockingContainer{TTargetClass}" /> class. /// </summary> public AutoMockingContainer() { _fabric = FrameworkConfig.BuildFabric(); _mockingEngine = FrameworkConfig.MockingEngine; _serviceLocator = this; _container = new AutoMockedContainer(this); }
/// <summary> /// Creates a new instance of the <see cref="Fabric"/> class. /// </summary> /// <param name="mockingEngine">The mock factory.</param> /// <param name="builders">A collection of all known builders.</param> /// <param name="configurationRules">A set of rules for configuration of the produced instances.</param> public Fabric(IMockingEngine mockingEngine, IEnumerable <IBuilder> builders, IEnumerable <IConfigurationRule> configurationRules) { Guard.AgainstArgumentNull(mockingEngine, "mockingEngine"); Guard.AgainstArgumentNull(builders, "builders"); Guard.AgainstArgumentNull(configurationRules, "configurationRules"); _mockingEngine = mockingEngine; _builders = builders; _configurationRules = configurationRules; }
/// <summary> /// Creates a new instance of the <see cref="Fabric"/> class. /// </summary> /// <param name="mockingEngine">The mock factory.</param> /// <param name="builders">A collection of all known builders.</param> /// <param name="configurationRules">A set of rules for configuration of the produced instances.</param> public Fabric(IMockingEngine mockingEngine, IEnumerable<IBuilder> builders, IEnumerable<IConfigurationRule> configurationRules) { Guard.AgainstArgumentNull(mockingEngine, "mockingEngine"); Guard.AgainstArgumentNull(builders, "builders"); Guard.AgainstArgumentNull(configurationRules, "configurationRules"); _mockingEngine = mockingEngine; _builders = builders; _configurationRules = configurationRules; }
/// <summary> /// Creates a new instance of the <see cref="FabricContext"/> class. /// </summary> /// <param name="typeToBuild"> /// Specifies the type to build. /// </param> /// <param name="mockingEngine"> /// Specifies the mock factory. /// </param> /// <param name="container"> /// Specifies the container. /// </param> /// <param name="fabric"> /// Specifies the fabric. /// </param> public FabricContext(Type typeToBuild, IMockingEngine mockingEngine, IContainer container, Fabric fabric) { Guard.AgainstArgumentNull(typeToBuild, "typeToBuild"); Guard.AgainstArgumentNull(mockingEngine, "mockingEngine"); Guard.AgainstArgumentNull(container, "container"); TypeToBuild = typeToBuild; _mockingEngine = mockingEngine; _container = container; _fabric = fabric; }
/// <summary> /// Creates a new instance of the <see cref="FabricContext"/> class. /// </summary> /// <param name="typeToBuild"> /// Specifies the type to build. /// </param> /// <param name="mockingEngine"> /// Specifies the mock factory. /// </param> /// <param name="container"> /// Specifies the container. /// </param> /// <param name="fabric"> /// Specifies the fabric. /// </param> public FabricContext(Type typeToBuild, IMockingEngine mockingEngine, IContainer container, Fabric fabric) { Guard.AgainstArgumentNull(typeToBuild, "typeToBuild"); Guard.AgainstArgumentNull(mockingEngine, "mockingEngine"); Guard.AgainstArgumentNull(container, "container"); TypeToBuild = typeToBuild; _mockingEngine = mockingEngine; _container = container; _fabric = fabric; }
/// <summary> /// Creates a new instance of the <see cref="StaticContextSpecification"/> class. /// </summary> protected StaticContextSpecification() { _mockingEngine = FrameworkConfig.MockingEngine; }
/// <summary> /// Creates a stub. /// </summary> /// <typeparam name="T"> /// Specifies the type of the stub. This needs to be an interface. /// </typeparam> /// <returns> /// The created stub instance. /// </returns> public static T Stub <T>(this IMockingEngine mockingEngine) where T : class { Guard.AgainstArgumentNull(mockingEngine, "mockingEngine"); return((T)mockingEngine.Stub(typeof(T))); }
/// <summary> /// Creates list filled with 3 stubs of the type specified via <typeparamref name="TInterfaceType"/>. /// </summary> /// <typeparam name="TInterfaceType"> /// Specifies the interface type. /// </typeparam> /// <param name="mockingEngine"> /// Specifies the factory for creating stub implementations on-the-fly. /// </param> /// <returns> /// A collection containing three stubs of the specified type. /// </returns> public static IList <TInterfaceType> CreateStubCollectionOf <TInterfaceType>(this IMockingEngine mockingEngine) where TInterfaceType : class { Guard.AgainstArgumentNull(mockingEngine, "mockingEngine"); return(Enumerable.Range(0, 3).Select(x => mockingEngine.Stub <TInterfaceType>()).ToList()); }