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

            var container = new WindsorContainer();

            Assert.IsNull(helper.GetRegistrationInfo(container, typeof(ITestInterface)));
        }
Пример #2
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);
        }
Пример #3
0
        public void GetRegistrationInfo_ContainerWithTransientTypeRegistered()
        {
            var helper = new WindsorHelper();

            var container = new WindsorContainer();

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

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

            Assert.AreEqual(typeof(ITestInterface), registrationInfo.DeclaringType);
            Assert.AreEqual(RegistrationType.Transient, registrationInfo.RegistrationType);
        }
Пример #4
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>());
        }
Пример #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_InterfaceTypeNull()
        {
            var helper = new WindsorHelper();

            var container = new WindsorContainer();

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

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