public void InitialiseTest() { using (ServiceContainerSetup setup = new ServiceContainerSetup(Settings, new TestLogger())) { setup.Initialise(); Assert.NotNull(setup .GetType() .GetProperty("DisposableServiceLocator", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(setup)); Assert.NotNull(ServiceLocator.Current); Assert.IsType( Assembly .GetAssembly(setup.GetType()) .DefinedTypes .Where(type => type.Name.Equals("UaooiServiceLocator")) .FirstOrDefault(), ServiceLocator.Current); } }
public void ConstructorTest() { using (ServiceContainerSetup setup = new ServiceContainerSetup( ServiceContainerSetupTest.Settings, new ServiceContainerSetupTest.TestLogger())) { setup.GetType() .GetField("shouldComposeLoggers", BindingFlags.Instance | BindingFlags.NonPublic) ?.SetValue(setup, false); setup.Initialise(); IServiceLocator serviceLocator = setup .GetType() .GetProperty("DisposableServiceLocator", BindingFlags.NonPublic | BindingFlags.Instance) .GetValue(setup) as IServiceLocator; using (UaooiMessageBus bus = new UaooiMessageBus( serviceLocator.GetInstance <IConfigurationFactory>(), serviceLocator.GetInstance <IEncodingFactory>(), serviceLocator.GetInstance <IBindingFactory>(), serviceLocator.GetInstance <IMessageHandlerFactory>(), serviceLocator.GetInstance <ILogger>() )) { Assert.NotNull(bus.ConfigurationFactory); Assert.NotNull(bus.EncodingFactory); Assert.NotNull(bus.BindingFactory); Assert.NotNull(bus.MessageHandlerFactory); Assert.Null(bus .GetType() .GetProperty("AssociationsCollection", BindingFlags.NonPublic | BindingFlags.Instance) .GetValue(bus)); Assert.Null(bus .GetType() .GetProperty("MessageHandlersCollection", BindingFlags.NonPublic | BindingFlags.Instance) .GetValue(bus)); } } }