public void ShouldGetInstanceOfRegisteredType() { // Arrange var busContainer = new StructureMapContainer(); busContainer.AddHandler(typeof(IMessageHandler <MyMessage>), new MyMessageHandler()); // Act var result = busContainer.GetInstance(typeof(IMessageHandler <MyMessage>)); // Assert Assert.NotNull(result); Assert.Equal("MyMessageHandler", result.GetType().Name); }
public void ShouldGetAllHandlerReferences() { // Arrange var busContainer = new StructureMapContainer(); busContainer.AddHandler(typeof(IMessageHandler <MyMessage>), new MyMessageHandler()); // Act var result = busContainer.GetHandlerTypes(); // Assert Assert.NotNull(result); Assert.Equal(1, result.Count()); Assert.Equal("MyMessage", result.ToList()[0].MessageType.Name); Assert.Equal("MyMessageHandler", result.ToList()[0].HandlerType.Name); }
public void ShouldGetInstanceOfRegisteredTypeWithCtorParameters() { // Arrange var busContainer = new StructureMapContainer(); busContainer.AddHandler(typeof(IMessageHandler <MyMessage>), new MyMessageHandler2("TestName")); // Act var result = busContainer.GetInstance <IMessageHandler <MyMessage> >(new Dictionary <string, object> { { "name", "TestName" } }); // Assert Assert.NotNull(result); Assert.Equal("MyMessageHandler2", result.GetType().Name); }