Beispiel #1
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));
        }
Beispiel #2
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));
        }
Beispiel #3
0
        public void ResolveType_ContainerWithoutTypeRegistered()
        {
            var helper = new NinjectHelper();

            var container = new StandardKernel();

            ExceptionTester.CallMethodAndExpectException <NotSupportedException>(() => helper.ResolveType(container, typeof(ITestInterface)));
        }
Beispiel #4
0
        public void ResolveType_InvalidContainer()
        {
            var helper = new NinjectHelper();

            var container = new object();

            ExceptionTester.CallMethodAndExpectException <NotSupportedException>(() => helper.ResolveType(container, typeof(ITestInterface)));
        }
Beispiel #5
0
        public void ResolveType_InterfaceTypeNull()
        {
            var helper = new NinjectHelper();

            var container = new StandardKernel();

            ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => helper.ResolveType(container, null));
        }
Beispiel #6
0
        public void ResolveType_ContainerNull()
        {
            var helper = new NinjectHelper();

            ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => helper.ResolveType(null, typeof(ITestInterface)));
        }