[TestMethod] public void ShouldThrowNoContainerExceptionWhenResolvingMultipleTypesBeforeInitializingTheContainer() { //Arrange var containerExtension = new StructureMapExtension(registrationHelper, options); //Act var result = ExceptionAssert.Throws <NoContainerException>(() => containerExtension.ResolveAll <object>()); //Assert Assert.AreEqual(NoContainerException.DefaultMessage, result.Message); }
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 ShouldResolveMultipleTypes() { //Arrange var containerExtension = new StructureMapExtension(registrationHelper, options); var container = A.Fake <IContainer>(); containerExtension.InitializeContainer(container); var instances = new List <object> { new object(), new object() }; A.CallTo(() => container.GetAllInstances <object>()).Returns(instances); //Act var result = containerExtension.ResolveAll <object>(); //Assert A.CallTo(() => container.GetAllInstances <object>()).MustHaveHappened(); Assert.IsNotNull(result); Assert.AreEqual(instances.Count, result.Count); Assert.AreSame(instances[0], result[0]); Assert.AreSame(instances[1], result[1]); }