public void Constructor_WhenInvoked_ShouldNotInitializeTheContainer() { //Arrange var containerOptions = A.Fake <IBootstrapperContainerExtensionOptions>(); //Act var result = new AutofacOptions(containerOptions); //Assert Assert.IsNull(result.Container); }
public void UsingAutoRegistration_WhenInvoked_ShouldReturnTheSameAutofacOptions() { //Arrange var containerOptions = A.Fake <IBootstrapperContainerExtensionOptions>(); var options = new AutofacOptions(containerOptions); //Act var result = options.UsingAutoRegistration(); //Assert Assert.AreSame(options, result); }
public void UsingAutoRegistration_WhenInvoked_ShouldInvokeUsingAutoRegistrationInTheOptions() { //Arrange var containerOptions = A.Fake <IBootstrapperContainerExtensionOptions>(); var options = new AutofacOptions(containerOptions); //Act options.UsingAutoRegistration(); //Assert A.CallTo(() => containerOptions.UsingAutoRegistration()).MustHaveHappened(); }
public void WithContainer_WhenInvoked_ShouldSetTheContainer() { //Arrange var container = A.Fake <IContainer>(); var containerOptions = A.Fake <IBootstrapperContainerExtensionOptions>(); var options = new AutofacOptions(containerOptions); //Act options.WithContainer(container); //Assert Assert.AreSame(container, options.Container); }
public void Constructor_WhenInvoked_ShouldReturnAutofacOptions() { //Arrange var containerOptions = A.Fake <IBootstrapperContainerExtensionOptions>(); //Act var result = new AutofacOptions(containerOptions); //Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(AutofacOptions)); Assert.IsInstanceOfType(result, typeof(IBootstrapperContainerExtensionOptions)); }
public void AutoRegistration_WhenInvoked_ShouldReturnTheValueOfTheOptionsAutoRegistration() { //Arrange var containerOptions = A.Fake <IBootstrapperContainerExtensionOptions>(); var options = new AutofacOptions(containerOptions); A.CallTo(() => containerOptions.AutoRegistration).Returns(true); //Act var result = options.AutoRegistration; //Assert Assert.IsTrue(result); }
/// <summary> /// Use the KickStart extension to configure Autofac. /// </summary> /// <param name="configurationBuilder">The configuration builder.</param> /// <param name="configure">The <see langword="delegate"/> to configure Autofac options.</param> /// <returns> /// A fluent <see langword="interface" /> to configure KickStart. /// </returns> public static IConfigurationBuilder UseAutofac(this IConfigurationBuilder configurationBuilder, Action <IAutofacBuilder> configure) { var options = new AutofacOptions(); var service = new AutofacStarter(options); if (configure != null) { var builder = new AutofacBuilder(options); configure(builder); } configurationBuilder.ExcludeName("Autofac"); configurationBuilder.Use(service); return(configurationBuilder); }
/// <summary> /// Use the KickStart extension to configure Autofac. /// </summary> /// <param name="configurationBuilder">The configuration builder.</param> /// <param name="configure">The <see langword="delegate"/> to configure Autofac options.</param> /// <returns> /// A fluent <see langword="interface" /> to configure KickStart. /// </returns> public static IConfigurationBuilder UseAutofac(this IConfigurationBuilder configurationBuilder, Action <IAutofacBuilder> configure) { var options = new AutofacOptions(); var service = new AutofacStarter(options); if (configure != null) { var builder = new AutofacBuilder(options); configure(builder); } configurationBuilder.ExcludeAssemblyFor <AutofacStarter>(); configurationBuilder.ExcludeAssemblyFor <global::Autofac.ContainerBuilder>(); configurationBuilder.Use(service); return(configurationBuilder); }