Beispiel #1
0
        public void RegisterInstance_Valid()
        {
            var helper = new UnityHelper();
            var instance = new TestClass1() { Name = "test" };

            var container = new UnityContainer();
            Assert.IsFalse(container.IsRegistered(typeof(ITestInterface)));

            helper.RegisterInstance(container, typeof(ITestInterface), instance);
            Assert.IsTrue(container.IsRegistered(typeof(ITestInterface)));
            Assert.AreEqual(instance, container.Resolve<ITestInterface>());
        }
Beispiel #2
0
        public void RegisterInstance_InvalidContainer()
        {
            var helper = new UnityHelper();

            var container = new object();
            ExceptionTester.CallMethodAndExpectException<NotSupportedException>(() => helper.RegisterInstance(container, typeof(ITestInterface), new TestClass1()));
        }
Beispiel #3
0
        public void RegisterInstance_InterfaceTypeNull()
        {
            var helper = new UnityHelper();

            var container = new UnityContainer();
            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.RegisterInstance(container, null, new TestClass1()));
        }
Beispiel #4
0
        public void RegisterInstance_InstanceNull()
        {
            var helper = new UnityHelper();

            var container = new UnityContainer();
            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.RegisterInstance(container, typeof(ITestInterface), null));
        }
Beispiel #5
0
        public void RegisterInstance_ContainerNull()
        {
            var helper = new UnityHelper();

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