예제 #1
0
        public void RegisterType_Valid()
        {
            var helper = new UnityHelper();

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

            helper.RegisterType(container, typeof(ITestInterface), typeof(TestClass1), RegistrationType.Singleton);
            Assert.IsTrue(container.IsRegistered(typeof(ITestInterface)));
        }
예제 #2
0
        public void RegisterType_ImplementingTypeNull()
        {
            var helper = new UnityHelper();

            var container = new UnityContainer();
            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.RegisterType(container, typeof(ITestInterface), null, RegistrationType.Singleton));
        }
예제 #3
0
        public void RegisterType_InvalidContainer()
        {
            var helper = new UnityHelper();

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

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