Пример #1
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>());
        }
Пример #2
0
        public void RegisterInstance_InstanceNull()
        {
            var helper = new NinjectHelper();

            var container = new StandardKernel();

            ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => helper.RegisterInstance(container, typeof(ITestInterface), null));
        }
Пример #3
0
        public void RegisterInstance_InvalidContainer()
        {
            var helper = new NinjectHelper();

            var container = new object();

            ExceptionTester.CallMethodAndExpectException <NotSupportedException>(() => helper.RegisterInstance(container, typeof(ITestInterface), new TestClass1()));
        }
Пример #4
0
        public void RegisterInstance_ContainerNull()
        {
            var helper = new NinjectHelper();

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