public void ShouldReturnNonDynamicAssemblies() { //Act var result = registrationHelper.GetAssemblies().ToList(); //Assert Assert.IsFalse(result.Any(a => a.IsDynamic)); }
protected void AutoRegister() { Registrator .GetAssemblies() .SelectMany(a => a.GetExportedTypes()) .Where(t => !t.IsGenericType && !t.IsAbstract) .Select(t => new { Type = t, DefaultInterface = t.GetInterface("I" + t.Name) }) .Where(t => t.DefaultInterface != null) .ForEach(t => Register(t.DefaultInterface, t.Type)); }
public void AutoRegister_WhenInvoked_ShouldRegisterBasedOnConvention() { //Arrange var assembly = Assembly.GetAssembly(typeof(RegisteredByConvention)); A.CallTo(() => registrationHelper.GetAssemblies()).Returns(new List <Assembly> { assembly }); var containerExtension = new TestContainerExtension(registrationHelper); //Act containerExtension.DoAutoRegister(); //Assert var result = containerExtension.Registrations; A.CallTo(() => registrationHelper.GetAssemblies()).MustHaveHappened(); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(Dictionary <Type, Type>)); Assert.IsTrue(result.ContainsKey(typeof(IRegisteredByConvention))); Assert.AreSame(typeof(RegisteredByConvention), result[typeof(IRegisteredByConvention)]); }
public void ShouldRegisterAllTypesOfIBootstrapperRegistration() { //Arrange var assembly = Assembly.GetAssembly(typeof(AutoMapperRegistration)); A.CallTo(() => registrationHelper.GetAssemblies()).Returns(new List <Assembly> { assembly }); var containerExtension = new StructureMapExtension(registrationHelper, options); //Act containerExtension.Run(); var result = containerExtension.ResolveAll <IBootstrapperRegistration>(); //Assert A.CallTo(() => registrationHelper.GetAssemblies()).MustHaveHappened(); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(IEnumerable <IBootstrapperRegistration>)); Assert.IsTrue(result.Any()); }
public void Run_WhenInvoked_ShouldRegisterAllTypesOfIBootstrapperRegistration() { //Arrange var assembly = Assembly.GetAssembly(typeof(AutoMapperRegistration)); A.CallTo(() => registrationHelper.GetAssemblies()).Returns(new List <Assembly> { assembly }); A.CallTo(() => registrationHelper.GetTypesImplementing <IBootstrapperRegistration>(assembly)) .Returns(new List <Type> { typeof(AutoMapperRegistration) }); var containerExtension = new SimpleInjectorExtension(registrationHelper, options); //Act containerExtension.Run(); var result = containerExtension.ResolveAll <IBootstrapperRegistration>(); //Assert A.CallTo(() => registrationHelper.GetAssemblies()).MustHaveHappened(); A.CallTo(() => registrationHelper.GetTypesImplementing <IBootstrapperRegistration>(assembly)).MustHaveHappened(); Assert.IsInstanceOfType(result, typeof(IEnumerable <IBootstrapperRegistration>)); Assert.IsTrue(result.Any()); Assert.IsInstanceOfType(result.First(), typeof(AutoMapperRegistration)); }