Пример #1
0
        public void IsValidContainer_InvalidContainer()
        {
            var helper = new WindsorHelper();

            var container = new object();
            Assert.IsFalse(helper.IsValidContainer(container));
        }
Пример #2
0
        public void IsValidContainer_ValidContainer()
        {
            var helper = new WindsorHelper();

            var container = new WindsorContainer();
            Assert.IsTrue(helper.IsValidContainer(container));
        }
Пример #3
0
        public void GetRegistrationInfo_ContainerWithoutTypeRegistered()
        {
            var helper = new WindsorHelper();

            var container = new WindsorContainer();
            Assert.IsNull(helper.GetRegistrationInfo(container, typeof(ITestInterface)));
        }
Пример #4
0
        public void GetRegistrationInfo_InterfaceTypeNull()
        {
            var helper = new WindsorHelper();

            var container = new WindsorContainer();
            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.GetRegistrationInfo(container, null));
        }
Пример #5
0
        public void GetRegistrationInfo_InvalidContainer()
        {
            var helper = new WindsorHelper();

            var container = new object();
            ExceptionTester.CallMethodAndExpectException<NotSupportedException>(() => helper.GetRegistrationInfo(container, typeof(ITestInterface)));
        }
Пример #6
0
        public void GetRegistrationInfo_ContainerWithSingletonTypeRegistered()
        {
            var helper = new WindsorHelper();

            var container = new WindsorContainer();
            container.Register(new IRegistration[] { new ComponentRegistration<ITestInterface>().ImplementedBy<TestClass1>().LifestyleSingleton() });

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

            // Note that we cannot get the lifestyle from windsor
            Assert.AreEqual(typeof(ITestInterface), registrationInfo.DeclaringType);
            Assert.AreEqual(RegistrationType.Transient, registrationInfo.RegistrationType);
        }
Пример #7
0
        public void ResolveType_ContainerNull()
        {
            var helper = new WindsorHelper();

            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.ResolveType(null, typeof(ITestInterface)));
        }
Пример #8
0
        public void GetRegistrationInfo_ContainerNull()
        {
            var helper = new WindsorHelper();

            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.GetRegistrationInfo(null, typeof(ITestInterface)));
        }
Пример #9
0
        public void RegisterType_InvalidContainer()
        {
            var helper = new WindsorHelper();

            var container = new object();
            ExceptionTester.CallMethodAndExpectException<NotSupportedException>(() => helper.RegisterType(container, typeof(ITestInterface), typeof(TestClass1), RegistrationType.Singleton));
        }
Пример #10
0
        public void RegisterInstance_ContainerNull()
        {
            var helper = new WindsorHelper();

            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.RegisterInstance(null, typeof(ITestInterface), new TestClass1()));
        }
Пример #11
0
        public void RegisterType_Valid()
        {
            var helper = new WindsorHelper();

            var container = new WindsorContainer();

            Assert.IsNull(helper.GetRegistrationInfo(container, typeof(ITestInterface)));

            helper.RegisterType(container, typeof(ITestInterface), typeof(TestClass1), RegistrationType.Singleton);
            Assert.IsTrue(container.Resolve<ITestInterface>() != null);
        }
Пример #12
0
        public void ResolveType_ContainerWithoutTypeRegistered()
        {
            var helper = new WindsorHelper();

            var container = new WindsorContainer();
            ExceptionTester.CallMethodAndExpectException<NotSupportedException>(() => helper.ResolveType(container, typeof(ITestInterface)));
        }
Пример #13
0
        public void ResolveType_Transient()
        {
            var helper = new WindsorHelper();

            var container = new WindsorContainer();
            container.Register(new IRegistration[] { new ComponentRegistration<ITestInterface>().ImplementedBy<TestClass1>().LifestyleTransient() });

            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));
        }
Пример #14
0
        public void RegisterType_ImplementingTypeNull()
        {
            var helper = new WindsorHelper();

            var container = new WindsorContainer();
            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.RegisterType(container, typeof(ITestInterface), null, RegistrationType.Singleton));
        }
Пример #15
0
        public void ResolveType_InvalidContainer()
        {
            var helper = new WindsorHelper();

            var container = new object();
            ExceptionTester.CallMethodAndExpectException<NotSupportedException>(() => helper.ResolveType(container, typeof(ITestInterface)));
        }
Пример #16
0
        public void RegisterInstance_InterfaceTypeNull()
        {
            var helper = new WindsorHelper();

            var container = new WindsorContainer();
            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.RegisterInstance(container, null, new TestClass1()));
        }
Пример #17
0
        public void IsValidContainer_Null()
        {
            var helper = new WindsorHelper();

            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.IsValidContainer(null));
        }
Пример #18
0
        public void RegisterInstance_Valid()
        {
            var helper = new WindsorHelper();
            var instance = new TestClass1() { Name = "test" };

            var container = new WindsorContainer();
            Assert.IsNull(helper.GetRegistrationInfo(container, typeof(ITestInterface)));

            helper.RegisterInstance(container, typeof(ITestInterface), instance);
            Assert.IsTrue(container.Resolve<ITestInterface>() != null);
            Assert.AreEqual(instance, container.Resolve<ITestInterface>());
        }
Пример #19
0
        public void RegisterInstance_InvalidContainer()
        {
            var helper = new WindsorHelper();

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

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

            var container = new WindsorContainer();
            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.ResolveType(container, null));
        }
Пример #22
0
        public void RegisterType_ContainerNull()
        {
            var helper = new WindsorHelper();

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