コード例 #1
0
ファイル: WindsorHelperTest.cs プロジェクト: pars87/Catel
        public void GetRegistrationInfo_ContainerWithoutTypeRegistered()
        {
            var helper = new WindsorHelper();

            var container = new WindsorContainer();
            Assert.IsNull(helper.GetRegistrationInfo(container, typeof(ITestInterface)));
        }
コード例 #2
0
ファイル: WindsorHelperTest.cs プロジェクト: pars87/Catel
        public void GetRegistrationInfo_InvalidContainer()
        {
            var helper = new WindsorHelper();

            var container = new object();
            ExceptionTester.CallMethodAndExpectException<NotSupportedException>(() => helper.GetRegistrationInfo(container, typeof(ITestInterface)));
        }
コード例 #3
0
ファイル: WindsorHelperTest.cs プロジェクト: pars87/Catel
        public void GetRegistrationInfo_InterfaceTypeNull()
        {
            var helper = new WindsorHelper();

            var container = new WindsorContainer();
            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.GetRegistrationInfo(container, null));
        }
コード例 #4
0
ファイル: WindsorHelperTest.cs プロジェクト: pars87/Catel
        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);
        }
コード例 #5
0
ファイル: WindsorHelperTest.cs プロジェクト: pars87/Catel
        public void GetRegistrationInfo_ContainerNull()
        {
            var helper = new WindsorHelper();

            ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.GetRegistrationInfo(null, typeof(ITestInterface)));
        }
コード例 #6
0
ファイル: WindsorHelperTest.cs プロジェクト: pars87/Catel
        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>());
        }
コード例 #7
0
ファイル: WindsorHelperTest.cs プロジェクト: pars87/Catel
        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);
        }