예제 #1
0
        public void Should_inject_class_dependency()
        {
            container.Register(Component.For <ServiceImpl>().ImplementedBy <ServiceImpl>());

            var sut = new DerivedClassWithDependency();

            Assert.IsNull(sut.ServiceImpl);

            dependencyBuilder.BuildUp(sut);

            Assert.IsNotNull(sut.ServiceImpl);
        }
예제 #2
0
        public void Should_inject_all_required_dependencies()
        {
            container.Register(Component.For <ServiceImpl>().ImplementedBy <ServiceImpl>());
            container.Register(Component.For <IService1>().ImplementedBy <Service1Impl>());
            container.Register(Component.For <IService2>().ImplementedBy <Service2Impl>());

            var sut = new DerivedClassWithDependency();

            dependencyBuilder.BuildUp(sut);

            Assert.IsNotNull(sut.Service1);
            Assert.IsNotNull(sut.Service2);
            Assert.IsNotNull(sut.ServiceImpl);
        }