public void Create_ROOT_And_Two_Childs_Container_But_Regist_Same_Child_Container_Key_Test()
        {
            var container = new FrameworkContainerForUnity();

            var childContainer1 = new FrameworkContainerForUnityChild("Child1", container);
            var childContainer2 = new FrameworkContainerForUnityChild("Child1", container);
        }
        public void Register_Interceptor_Test()
        {
            IFrameworkContainer container = new FrameworkContainerForUnity();
            container.RegisterType<MockClass>();

            container.Resolve<MockClass>().Say();
        }
        public void SimpleInterception_Test()
        {
            IFrameworkContainer container = new FrameworkContainerForUnity();
            container.RegisterType<SimpleInterceptorObject>();

            container.Resolve<SimpleInterceptorObject>().Say();
        }
        public void Create_ROOT_And_Two_Childs_Container_But_Regist_Same_Child_Container_Key_Test()
        {
            var container = new FrameworkContainerForUnity();

            var childContainer1 = new FrameworkContainerForUnityChild("Child1", container);
            var childContainer2 = new FrameworkContainerForUnityChild("Child1", container);
        }
Пример #5
0
        public void FrameworkContainerComposition_with_DynamicAttribute_Test()
        {
            var container = new FrameworkContainerForUnity();

            var catalog = new FrameworkTypeCatalog(new Type[] { typeof(IEntity), typeof(Entity), typeof(DynamicObject_Tests), typeof(Unity_Component_Tests) });
            var visitor = new FrameworkDependencyVisitor(catalog);



            var root      = visitor.VisitTypes();
            var composite = new FrameworkCompositionResolverForUnity(container, root);

            composite.Compose();

            //XmlSerializer xs = new XmlSerializer(typeof(UmcCoreIoCElement));
            //xs.Serialize(Console.Out, root);

            var entity = container.Resolve <IEntity>();

            entity.Name = "Junil, Um";
            Console.WriteLine("Name={0}", entity.Name);

            entity = container.Resolve <IEntity>();
            Console.WriteLine("Name={0}", entity.Name);
        }
        public void Create_ROOT_Container_Of_One_Object_Test()
        {
            IFrameworkContainer container = new FrameworkContainerForUnity();
            container.RegisterType<IMockSimple, MockSimple>();

            container.Resolve<IMockSimple>().Say();
        }
        public void Save_and_Load_FrameworkConfiguratoinExtension_Test()
        {
            var filename = "configuration.ioc.config";

            var mockTypes = new Type[]
            {
                typeof(MockSimple),
            };

            var catalog = new FrameworkTypeCatalog(mockTypes);
            var visitor = new FrameworkDependencyVisitor(catalog);
            var root    = visitor.VisitTypes();

            var xs = new XmlSerializer(typeof(UmcCoreIoCElement));

            using (StreamWriter sw = new StreamWriter(filename))
            {
                xs.Serialize(sw, root);
            }

            TestContext.WriteLine(File.ReadAllText(filename));


            IFrameworkContainer newContainer = new FrameworkContainerForUnity();

            newContainer.Load(filename);

            TestContext.WriteLine(newContainer.Resolve <IMockSimple>().GetHashCode().ToString());
        }
        public void FrameworkContainer_Register_and_Resolve_Methods_Overrode1_Test()
        {
            var container = new FrameworkContainerForUnity();

            container.RegisterType <IMockSimple, MockSimple>();
            container.Resolve <IMockSimple>().Say();
        }
        public void SimpleInterception_Test()
        {
            IFrameworkContainer container = new FrameworkContainerForUnity();

            container.RegisterType <SimpleInterceptorObject>();

            container.Resolve <SimpleInterceptorObject>().Say();
        }
        public void FrameworkContainer_Resolve_Constructor_Contract_Test()
        {
            var container = new FrameworkContainerForUnity();

            container.RegisterType <IMockInitConstructor, MockInitConstructor>();

            container.Resolve <IMockInitConstructor>().Say();
        }
        public void Create_ROOT_Container_Of_One_Object_Test()
        {
            IFrameworkContainer container = new FrameworkContainerForUnity();

            container.RegisterType <IMockSimple, MockSimple>();

            container.Resolve <IMockSimple>().Say();
        }
        public void Register_Interceptor_Test()
        {
            IFrameworkContainer container = new FrameworkContainerForUnity();

            container.RegisterType <MockClass>();

            container.Resolve <MockClass>().Say();
        }
        public void Create_ROOT_and_Two_Childs_Container_Test()
        {
            var container = new FrameworkContainerForUnity();

            var childContainer1 = new FrameworkContainerForUnityChild("Child1", container);
            var childContainer2 = new FrameworkContainerForUnityChild("Child2", container);

            Assert.IsTrue( container.Childs.Count() == 2, "FrameworkContainer 에 두 개의 Child Container 를 등록하였지만, FrameworkContainer Child Count 는 {0} 개 입니다.", container.Childs.Count());
        }
        public void Create_ROOT_Container_Of_Two_Object_Test()
        {
            var container = new FrameworkContainerForUnity();
            container.RegisterType<IMockSimple, MockSimple>();
            container.RegisterType<IMockConstructor, MockConstructor>();

            container.Resolve<IMockSimple>().Say();
            container.Resolve<IMockConstructor>().Delegate();
        }
        public void Create_ROOT_and_Two_Childs_Container_Test()
        {
            var container = new FrameworkContainerForUnity();

            var childContainer1 = new FrameworkContainerForUnityChild("Child1", container);
            var childContainer2 = new FrameworkContainerForUnityChild("Child2", container);

            Assert.IsTrue(container.Childs.Count() == 2, "FrameworkContainer 에 두 개의 Child Container 를 등록하였지만, FrameworkContainer Child Count 는 {0} 개 입니다.", container.Childs.Count());
        }
        public void FrameworkContainer_Register_and_Resolve_Methods_Override5_Test()
        {
            var container = new FrameworkContainerForUnity();

            container.RegisterType <IMockSimple, MockSimple>();
            var obj = container.Resolve(typeof(IMockSimple));

            Assert.IsTrue(obj is IMockSimple, "Resolve된 Object 가 등록된 IMock 타입과 다르므로 실패하였습니다");
        }
        public void FrameworkContainer_PropertyInjection_Test()
        {
            var container = new FrameworkContainerForUnity();

            container.RegisterType <IMockSimple, MockSimple>()
            .RegisterType <IMockPropertyInjection, MockPropertyInjection>();

            container.Resolve <IMockPropertyInjection>().Say();
        }
        public void Create_ROOT_Container_Of_Two_Object_Test()
        {
            var container = new FrameworkContainerForUnity();

            container.RegisterType <IMockSimple, MockSimple>();
            container.RegisterType <IMockConstructor, MockConstructor>();

            container.Resolve <IMockSimple>().Say();
            container.Resolve <IMockConstructor>().Delegate();
        }
        private static IFrameworkContainer SetupFrameworkContainer(string path, ref IFrameworkContainer container)
        {
            if (File.Exists(path) == false)
                throw new FileNotFoundException(path);

            if (container == null)
                container = new FrameworkContainerForUnity();

            return container;
        }
        private FrameworkContainerForUnity CompositionTheTypes(Type[] types)
        {
            var visitor = new FrameworkDependencyVisitor(types);
            var root    = visitor.VisitTypes();

            WriteToSerialization(root);

            var container = new FrameworkContainerForUnity();
            var resolver  = new FrameworkCompositionResolverForUnity(container, root);

            resolver.Compose();
            return(container);
        }
        public void Create_ROOT_and_Child_Container_test()
        {
            var container = new FrameworkContainerForUnity();
            container.RegisterType<IMockSimple, MockSimple>();

            var childContainer = new FrameworkContainerForUnityChild("child1", container);
            container.AddChildContainer(childContainer);

            childContainer.RegisterType<IMockConstructor, MockConstructor>();

            container.Resolve<IMockSimple>();
            container.Childs.FirstOrDefault().Resolve<IMockConstructor>().Delegate();
        }
Пример #22
0
        private static IFrameworkContainer SetupFrameworkContainer(string path, ref IFrameworkContainer container)
        {
            if (File.Exists(path) == false)
            {
                throw new FileNotFoundException(path);
            }

            if (container == null)
            {
                container = new FrameworkContainerForUnity();
            }

            return(container);
        }
        public void Create_ROOT_and_Child_Container_test()
        {
            var container = new FrameworkContainerForUnity();

            container.RegisterType <IMockSimple, MockSimple>();

            var childContainer = new FrameworkContainerForUnityChild("child1", container);

            container.AddChildContainer(childContainer);

            childContainer.RegisterType <IMockConstructor, MockConstructor>();

            container.Resolve <IMockSimple>();
            container.Childs.FirstOrDefault().Resolve <IMockConstructor>().Delegate();
        }
        public void FrameworkContainer_Register_with_PerCall_Lifetime_Test1()
        {
            var container = new FrameworkContainerForUnity();

            container.RegisterType <IMockSimple, MockSimple>(LifetimeFlag.PerCall);

            var obj = container.Resolve <IMockSimple>();

            Assert.IsTrue(obj.Name == null);

            obj.Name = "엄준일";

            obj = container.Resolve <IMockSimple>();
            Assert.IsTrue(obj.Name == null);
        }
        public void FrameworkContainer_Registering_With_Parallal_Test()
        {
            FrameworkContainerForUnity container = new FrameworkContainerForUnity();
            Action a1 = () => container.RegisterType <IMockSimple, MockSimple>();
            Action a2 = () => container.RegisterType <IMockConstructor, MockConstructor>();

            List <Action> actions = new List <Action>()
            {
                a1, a2
            };

            container.RegisterTypeAsParallel(actions);

            container.Resolve <IMockSimple>().Say();
            container.Resolve <IMockConstructor>().Delegate();
        }
Пример #26
0
        public void DynamicEntity_With_FrameworkContainer_Test()
        {
            var type = DynamicObject.InterfaceImplementationType<IEntity>();
            var obj  = (IEntity)Activator.CreateInstance(type);

            IFrameworkContainer container = new FrameworkContainerForUnity();

            container.RegisterType<IEntity>(type, LifetimeFlag.PerCall);

            Console.WriteLine(obj.GetType());

            var data = container.Resolve<IEntity>();
            data.Name = "Junil, Um";
            data.Age = 10;
            Console.WriteLine("Name={0}, Age={1}", data.Name, data.Age);

            data = container.Resolve<IEntity>();
            Console.WriteLine("Name={0}, Age={1}", data.Name ?? "NULL", data.Age);
        }
Пример #27
0
        public void DynamicEntity_With_FrameworkContainer_Test()
        {
            var type = DynamicObject.InterfaceImplementationType <IEntity>();
            var obj  = (IEntity)Activator.CreateInstance(type);

            IFrameworkContainer container = new FrameworkContainerForUnity();

            container.RegisterType <IEntity>(type, LifetimeFlag.PerCall);

            Console.WriteLine(obj.GetType());

            var data = container.Resolve <IEntity>();

            data.Name = "Junil, Um";
            data.Age  = 10;
            Console.WriteLine("Name={0}, Age={1}", data.Name, data.Age);

            data = container.Resolve <IEntity>();
            Console.WriteLine("Name={0}, Age={1}", data.Name ?? "NULL", data.Age);
        }
Пример #28
0
        public void FrameworkContainerComposition_with_DynamicAttribute_Test()
        {
            var container = new FrameworkContainerForUnity();

            var catalog = new FrameworkTypeCatalog(new Type[] { typeof(IEntity), typeof(Entity), typeof(DynamicObject_Tests), typeof(Unity_Component_Tests) });
            var visitor = new FrameworkDependencyVisitor(catalog);

            var root = visitor.VisitTypes();
            var composite = new FrameworkCompositionResolverForUnity(container, root);
            composite.Compose();

            //XmlSerializer xs = new XmlSerializer(typeof(UmcCoreIoCElement));
            //xs.Serialize(Console.Out, root);

            var entity = container.Resolve<IEntity>();
            entity.Name = "Junil, Um";
            Console.WriteLine("Name={0}", entity.Name);

            entity = container.Resolve<IEntity>();
            Console.WriteLine("Name={0}", entity.Name);
        }
        public void FrameworkContainer_Register_with_Static_Lifetime_Test1()
        {
            var container = new FrameworkContainerForUnity();
            container.RegisterType<IMockSimple, MockSimple>(LifetimeFlag.Singleton);

            var obj = container.Resolve<IMockSimple>();
            Assert.IsTrue(obj.Name == null);

            obj.Name = "엄준일";

            obj = container.Resolve<IMockSimple>();
            Assert.IsTrue(obj.Name == "엄준일");
        }
        public void FrameworkContainer_PropertyInjection_Test()
        {
            var container = new FrameworkContainerForUnity();
            container.RegisterType<IMockSimple, MockSimple>()
                .RegisterType<IMockPropertyInjection, MockPropertyInjection>();

            container.Resolve<IMockPropertyInjection>().Say();
        }
        public void FrameworkContainer_Register_and_Resolve_Methods_Override5_Test()
        {
            var container = new FrameworkContainerForUnity();

            container.RegisterType<IMockSimple, MockSimple>();
            var obj = container.Resolve(typeof(IMockSimple));

            Assert.IsTrue(obj is IMockSimple, "Resolve된 Object 가 등록된 IMock 타입과 다르므로 실패하였습니다");
        }
        public void FrameworkContainer_Register_and_Resolve_Methods_Overrode3_Test()
        {
            var container = new FrameworkContainerForUnity();

            container.RegisterType<IMockSimple, MockSimple>("key");
            container.Resolve<IMockSimple>("key").Say();
        }
        private FrameworkContainerForUnity CompositionTheTypes(Type[] types)
        {
            var visitor = new FrameworkDependencyVisitor(types);
            var root = visitor.VisitTypes();

            WriteToSerialization(root);

            var container = new FrameworkContainerForUnity();
            var resolver = new FrameworkCompositionResolverForUnity(container, root);

            resolver.Compose();
            return container;
        }
        public void FrameworkContainer_Resolve_Constructor_Contract_Test()
        {
            var container = new FrameworkContainerForUnity();
            container.RegisterType<IMockInitConstructor, MockInitConstructor>();

            container.Resolve<IMockInitConstructor>().Say();
        }
        public void FrameworkContainer_Registering_With_Parallal_Test()
        {
            FrameworkContainerForUnity container = new FrameworkContainerForUnity();
            Action a1 = () => container.RegisterType<IMockSimple, MockSimple>();
            Action a2 = () => container.RegisterType<IMockConstructor, MockConstructor>();

            List<Action> actions = new List<Action>() { a1, a2 };

            container.RegisterTypeAsParallel(actions);

            container.Resolve<IMockSimple>().Say();
            container.Resolve<IMockConstructor>().Delegate();
        }
        public void Save_and_Load_FrameworkConfiguratoinExtension_Test()
        {
            var filename = "configuration.ioc.config";

            var mockTypes = new Type[]
            {
                typeof(MockSimple),
            };

            var catalog = new FrameworkTypeCatalog(mockTypes);
            var visitor = new FrameworkDependencyVisitor(catalog);
            var root = visitor.VisitTypes();

            var xs = new XmlSerializer(typeof(UmcCoreIoCElement));
            using (StreamWriter sw = new StreamWriter(filename))
            {
                xs.Serialize(sw, root);
            }

            TestContext.WriteLine(File.ReadAllText(filename));

            IFrameworkContainer newContainer = new FrameworkContainerForUnity();
            newContainer.Load(filename);

            TestContext.WriteLine(newContainer.Resolve<IMockSimple>().GetHashCode().ToString());
        }