Example #1
0
            public void ResolvesSameInstanceFromBothContainers()
            {
                var unityContainer = new UnityContainer();

                var serviceLocator = new ServiceLocator();
                serviceLocator.AutomaticallyKeepContainersSynchronized = true;
                serviceLocator.RegisterExternalContainer(unityContainer);

                serviceLocator.RegisterTypeIfNotYetRegistered<IMessageService, MessageService>();

                var ns1 = unityContainer.Resolve<IMessageService>();
                var ns2 = serviceLocator.ResolveType<IMessageService>();

                Assert.AreEqual(ns1, ns2);
            }
Example #2
0
            public void AutomaticSynchronization_RegisterIfTypeNotYetRegistered()
            {
                var serviceLocator = new ServiceLocator();
                var ninjectContainer = new StandardKernel();
                serviceLocator.RegisterExternalContainer(ninjectContainer);
                serviceLocator.RegisterTypeIfNotYetRegistered<ITestInterface, TestClass1>();

                Assert.IsTrue(ninjectContainer.GetBindings(typeof(ITestInterface)).Any());
            }