public void ShouldGetTypedInstanceOfRegisteredType() { // Arrange var services = new ServiceConnect.Container.Default.Container(); services.RegisterForAll(typeof(MyMessageHandler)); var busContainer = new DefaultBusContainer(); busContainer.Initialize(services); // Act var result = busContainer.GetInstance <IMessageHandler <MyMessage> >(); // Assert Assert.NotNull(result); Assert.Equal("MyMessageHandler", result.GetType().Name); }
public void ShouldGetAllHandlerReferences() { // Arrange var services = new ServiceConnect.Container.Default.Container(); services.RegisterForAll(typeof(MyMessageHandler)); var busContainer = new DefaultBusContainer(); busContainer.Initialize(services); // 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 services = new ServiceConnect.Container.Default.Container(); services.RegisterForAll(typeof(MyMessageHandler2)); var busContainer = new DefaultBusContainer(); busContainer.Initialize(services); // Act var result = busContainer.GetInstance <IMessageHandler <MyMessage> >(new Dictionary <string, object> { { "name", "TestName" } }); // Assert Assert.NotNull(result); Assert.Equal("MyMessageHandler2", result.GetType().Name); }