public void Support_type_scanning() { var builder = new MockContainerBuilder(); builder.RegisterAssemblyTypes(typeof(IDummy).Assembly) .Where(t => t.IsAssignableTo <IDummy>()) .Except <Dummy3>() .AsSelf() .AsImplementedInterfaces() .As <IDummy>() .As(t => t.GetInterfaces()[0]); var container = builder.Build(); var types = container.Should().RegisterAssemblyTypes(typeof(IDummy).Assembly) .Where(t => t.IsAssignableTo <IDummy>()) .Except <Dummy3>() .AsSelf() .AsImplementedInterfaces() .As <IDummy>() .As(t => t.GetInterfaces()[0]) .Types; container.Should().RegisterTypes(types) .AsSelf() .AsImplementedInterfaces() .As <IDummy>() .As(t => t.GetInterfaces()[0]); }
public void Support_testing_assembly_modules_registrations() { var sut = new MockContainerBuilder(); var assembly = typeof(MockContainerBuilderAssertions_Should).Assembly; sut.RegisterAssemblyModules(assembly); sut.Should().RegisterModulesIn(assembly); sut.Should().RegisterModule <SampleModule>(); sut.Should().RegisterModule <SampleModule2>(); }
public void Support_testing_module_registration() { var builder = new MockContainerBuilder(); builder.RegisterModule <SampleModule>(); var builderShould = builder.Should(); builderShould.RegisterModule <SampleModule>(); builderShould.RegisterModule(typeof(SampleModule)); builderShould.RegisterModule <SampleModule2>(); }
/// <summary> /// Returns an <see cref="MockContainerBuilder"/> suitable for testing the specified module. /// </summary> /// <param name="module">The module</param> /// <param name="arrange">optional builder arrangement for the module</param> public static MockContainerBuilder Builder <TModule>(this TModule module, Action <ContainerBuilder> arrange = null) where TModule : Module, new() { if (module == null) { throw new ArgumentNullException(nameof(module)); } var builder = new MockContainerBuilder(); arrange?.Invoke(builder); builder.RegisterModule(module); return(builder); }
public void Register_And_Return_Callbacks() { var sut = new MockContainerBuilder(); Action <IComponentRegistryBuilder> cb1 = registry => { }; sut.RegisterCallback(cb1); sut.Callbacks.Single().Callback.Should().Be(cb1); Action <IComponentRegistryBuilder> cb2 = registry => { }; sut.RegisterCallback(cb2); sut.Callbacks.Last().Callback.Should().Be(cb2); }
public void Register_And_Return_Callbacks() { var sut = new MockContainerBuilder(); Action <IComponentRegistry> cb1 = registry => { }; sut.RegisterCallback(cb1); sut.Callbacks.Should().HaveCount(1); sut.Callbacks.Should().OnlyContain(action => action == cb1); Action <IComponentRegistry> cb2 = registry => { }; sut.RegisterCallback(cb2); sut.Callbacks.Should().HaveCount(2); sut.Callbacks.Should().OnlyContain(action => action == cb1 || action == cb2); }
public void Provide_builder_extension() { var builder = new MockContainerBuilder(); builder.Should().Should().BeOfType <MockContainerBuilderAssertions>(); }
public void Be_Empty_At_Start() { var sut = new MockContainerBuilder(); sut.Callbacks.Should().BeEmpty(); }
/// <summary> /// Returns an <see cref="MockContainerBuilderAssertions"/> object that can be used to assert the current <see cref="MockContainerBuilder"/>. /// </summary> public static MockContainerBuilderAssertions Should(this MockContainerBuilder builder) { return(new MockContainerBuilderAssertions(builder)); }