コード例 #1
0
        public void BuildUpResolvesAllInjectedProperties()
        {
            var container = new MicroIocContainer()
                .Register<IFirst, First>()
                .Register<ISecond, Second>();

            container.GetConfiguration()
                .Property<TestClassWithProperties, string>(x => x.CustomerName, "TestCustomerName");

            var obj = new TestClassWithProperties();

            container.BuildUp(obj);

            Assert.AreEqual("TestCustomerName", obj.CustomerName);

            Assert.IsNotNull(obj.FirstProperty, "FirstProperty shouldn't be null");
            Assert.IsInstanceOfType(obj.FirstProperty, typeof(First), "FirstProperty should a 'First' object");

            Assert.IsNotNull(obj.SecondProperty, "SecondProperty shouldn't be null");
            Assert.IsInstanceOfType(obj.SecondProperty, typeof(Second), "SecondProperty should a 'Second' object");
        }
コード例 #2
0
        public void BuildUpResolvesAllInjectedProperties()
        {
            var container = new MicroIocContainer()
                            .Register <IFirst, First>()
                            .Register <ISecond, Second>();

            container.GetConfiguration()
            .Property <TestClassWithProperties, string>(x => x.CustomerName, "TestCustomerName");

            var obj = new TestClassWithProperties();

            container.BuildUp(obj);

            Assert.AreEqual("TestCustomerName", obj.CustomerName);

            Assert.IsNotNull(obj.FirstProperty, "FirstProperty shouldn't be null");
            Assert.IsInstanceOfType(obj.FirstProperty, typeof(First), "FirstProperty should a 'First' object");

            Assert.IsNotNull(obj.SecondProperty, "SecondProperty shouldn't be null");
            Assert.IsInstanceOfType(obj.SecondProperty, typeof(Second), "SecondProperty should a 'Second' object");
        }