コード例 #1
0
        public void Resolve_Singleton_Type_Test()
        {
            var containerService = new IoCContainerService();
            containerService.Register<ITestTypeOne, TestTypeOne>(Common.Enums.LifetimeType.Singleton);

            var implementationOne = containerService.Resolve<ITestTypeOne>();
            var implementationTwo = containerService.Resolve<ITestTypeOne>();

            Assert.IsTrue(implementationOne is TestTypeOne && implementationTwo is TestTypeOne && implementationOne == implementationTwo);
        }
コード例 #2
0
        public void Resolve_Default_Type_Test()
        {
            var containerService = new IoCContainerService();
            containerService.Register<ITestTypeOne, TestTypeOne>();

            var implementationOne = containerService.Resolve<ITestTypeOne>();
            var implementationTwo = containerService.Resolve<ITestTypeOne>();

            Assert.IsTrue(implementationOne is TestTypeOne && implementationTwo is TestTypeOne && implementationOne != implementationTwo);
        }
コード例 #3
0
        public void Resolve_Unknown_Type_Test()
        {
            var containerService = new IoCContainerService();

            containerService.Resolve<ITestTypeOne>();
        }
コード例 #4
0
        public void Resolve_Type_With_Resolvable_Constructor_Arguements_Test()
        {
            var containerService = new IoCContainerService();
            containerService.Register<ITestTypeOne, TestTypeOne>();
            containerService.Register<ITestTypeWithParameterConstructor, TestTypeWithParameterConstructor>();

            var implementation = containerService.Resolve<ITestTypeWithParameterConstructor>();

            Assert.IsTrue(implementation is TestTypeWithParameterConstructor && implementation.TestTypeOne is TestTypeOne);
        }