예제 #1
0
        public void IsValidContainer_InvalidContainer()
        {
            var helper = new NinjectHelper();

            var container = new object();
            Assert.IsFalse(helper.IsValidContainer(container));
        }
예제 #2
0
        public void GetRegistrationInfo_InterfaceTypeNull()
        {
            var helper = new NinjectHelper();

            var container = new StandardKernel();
            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.GetRegistrationInfo(container, null));
        }
예제 #3
0
        public void GetRegistrationInfo_ContainerWithoutTypeRegistered()
        {
            var helper = new NinjectHelper();

            var container = new StandardKernel();
            Assert.IsNull(helper.GetRegistrationInfo(container, typeof(ITestInterface)));
        }
예제 #4
0
        public void IsValidContainer_ValidContainer()
        {
            var helper = new NinjectHelper();

            var container = new StandardKernel();
            Assert.IsTrue(helper.IsValidContainer(container));
        }
예제 #5
0
        public void GetRegistrationInfo_InvalidContainer()
        {
            var helper = new NinjectHelper();

            var container = new object();
            ExceptionTester.CallMethodAndExpectException<NotSupportedException>(() => helper.GetRegistrationInfo(container, typeof(ITestInterface)));
        }
예제 #6
0
        public void ResolveType_Transient()
        {
            var helper = new NinjectHelper();

            var container = new StandardKernel();
            container.Bind(typeof(ITestInterface)).To<TestClass1>().InTransientScope();

            var resolvedInstance1 = helper.ResolveType(container, typeof(ITestInterface));

            Assert.IsNotNull(resolvedInstance1);
            Assert.IsInstanceOfType(resolvedInstance1, typeof(TestClass1));

            var resolvedInstance2 = helper.ResolveType(container, typeof(ITestInterface));

            Assert.IsNotNull(resolvedInstance2);
            Assert.IsInstanceOfType(resolvedInstance2, typeof(TestClass1));

            Assert.IsFalse(ReferenceEquals(resolvedInstance1, resolvedInstance2));
        }
예제 #7
0
        public void IsValidContainer_Null()
        {
            var helper = new NinjectHelper();

            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.IsValidContainer(null));
        }
예제 #8
0
        public void ResolveType_ContainerWithTypeRegistered()
        {
            var helper = new NinjectHelper();

            var container = new StandardKernel();
            container.Bind(typeof(ITestInterface)).To<TestClass1>();
            var resolvedInstance = helper.ResolveType(container, typeof(ITestInterface));
            Assert.IsNotNull(resolvedInstance);
            Assert.IsInstanceOfType(resolvedInstance, typeof(TestClass1));
        }
예제 #9
0
        public void RegisterType_ImplementingTypeNull()
        {
            var helper = new NinjectHelper();

            var container = new StandardKernel();
            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.RegisterType(container, typeof(ITestInterface), null, RegistrationType.Singleton));
        }
예제 #10
0
        public void ResolveType_ContainerNull()
        {
            var helper = new NinjectHelper();

            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.ResolveType(null, typeof(ITestInterface)));
        }
예제 #11
0
        public void RegisterInstance_Valid()
        {
            var helper = new NinjectHelper();
            var instance = new TestClass1() { Name = "test" };

            var container = new StandardKernel();
            Assert.IsFalse(GetRegistrationInfo(container, typeof(ITestInterface)));

            helper.RegisterInstance(container, typeof(ITestInterface), instance);
            Assert.IsTrue(GetRegistrationInfo(container, typeof(ITestInterface)));
            Assert.AreEqual(instance, container.Get<ITestInterface>());
        }
예제 #12
0
        public void RegisterInstance_InvalidContainer()
        {
            var helper = new NinjectHelper();

            var container = new object();
            ExceptionTester.CallMethodAndExpectException<NotSupportedException>(() => helper.RegisterInstance(container, typeof(ITestInterface), new TestClass1()));
        }
예제 #13
0
        public void RegisterInstance_InstanceNull()
        {
            var helper = new NinjectHelper();

            var container = new StandardKernel();
            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.RegisterInstance(container, typeof(ITestInterface), null));
        }
예제 #14
0
        public void RegisterInstance_ContainerNull()
        {
            var helper = new NinjectHelper();

            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.RegisterInstance(null, typeof(ITestInterface), new TestClass1()));
        }
예제 #15
0
        public void RegisterType_Valid()
        {
            var helper = new NinjectHelper();

            var container = new StandardKernel();

            Assert.IsFalse(GetRegistrationInfo(container, (typeof(ITestInterface))));

            helper.RegisterType(container, typeof(ITestInterface), typeof(TestClass1), RegistrationType.Singleton);
            Assert.IsTrue(GetRegistrationInfo(container, typeof(ITestInterface)));
        }
예제 #16
0
        public void RegisterType_InvalidContainer()
        {
            var helper = new NinjectHelper();

            var container = new object();
            ExceptionTester.CallMethodAndExpectException<NotSupportedException>(() => helper.RegisterType(container, typeof(ITestInterface), typeof(TestClass1), RegistrationType.Singleton));
        }
예제 #17
0
        public void GetRegistrationInfo_ContainerNull()
        {
            var helper = new NinjectHelper();

            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.GetRegistrationInfo(null, typeof(ITestInterface)));
        }
예제 #18
0
        public void ResolveType_InterfaceTypeNull()
        {
            var helper = new NinjectHelper();

            var container = new StandardKernel();
            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.ResolveType(container, null));
        }
예제 #19
0
        public void ResolveType_InvalidContainer()
        {
            var helper = new NinjectHelper();

            var container = new object();
            ExceptionTester.CallMethodAndExpectException<NotSupportedException>(() => helper.ResolveType(container, typeof(ITestInterface)));
        }
예제 #20
0
        public void ResolveType_ContainerWithoutTypeRegistered()
        {
            var helper = new NinjectHelper();

            var container = new StandardKernel();
            ExceptionTester.CallMethodAndExpectException<NotSupportedException>(() => helper.ResolveType(container, typeof(ITestInterface)));
        }
예제 #21
0
        public void GetRegistrationInfo_ContainerWithSingletonTypeRegistered()
        {
            var helper = new NinjectHelper();

            var container = new StandardKernel();
            container.Bind<ITestInterface>().To<TestClass1>().InSingletonScope();

            var registrationInfo = helper.GetRegistrationInfo(container, typeof(ITestInterface));

            Assert.AreEqual(typeof(ITestInterface), registrationInfo.DeclaringType);
            Assert.AreEqual(RegistrationType.Singleton, registrationInfo.RegistrationType);
        }
예제 #22
0
        public void RegisterType_ContainerNull()
        {
            var helper = new NinjectHelper();

            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.RegisterType(null, typeof(ITestInterface), typeof(TestClass1), RegistrationType.Singleton));
        }