Exemple #1
0
        public void AddNewExtensionToUnityContainer()
        {
            //unitycontainer :Creates a default UnityContainer. Returns a reference to the new container 
            //as an instance of the IUnityContainer interface.
            //AddNewExtension : Creates a new extension object of type TExtension and adds it to the container. The 
            //extension type must have a zero-argument public constructor. Returns a reference to the container
            IUnityContainer container = new UnityContainer().AddNewExtension<StaticFactoryExtension>();
            // container.Register<Container, UnityContainer>;
            Assert.IsNotNull(container);

            container = container.RemoveAllExtensions();
            Assert.IsNotNull(container);
        }
Exemple #2
0
        public void Test_TaskID_16777()
        {
            UnityContainer uc = new UnityContainer();

            uc.RemoveAllExtensions();
            uc.AddExtension(new MyExtension());
            uc.RegisterType<UnityTestClass>(new ContainerControlledLifetimeManager());

            UnityTestClass mytestparent = uc.Resolve<UnityTestClass>();
        }
Exemple #3
0
 public void Ext_RemovingAllExtensionsDisablesDefaultBehavior()
 {
     IUnityContainer container = new UnityContainer();
     container.RemoveAllExtensions();
     object result = container.Resolve<object>();
     
     Assert.IsNull(result);
 }