Exemplo n.º 1
0
        public void TestRecursionDependecies()
        {
            var dependencies = new DependenciesConfiguration();

            dependencies.Register <IService, ServiceImplementation>();
            dependencies.Register <IRepository, RecursionRepositoryImplementation>();
            dependencies.Register <IAnotherRepository, AnotherRepositoryImplementation>();

            var provider = new DependencyProvider(dependencies);
            var service  = provider.Resolve <IService>();

            IRepository FirstRepo = (service as ServiceImplementation).repository;

            Assert.AreEqual(FirstRepo.IdentificateRepository(), RecursionRepositoryAnswer);
            Assert.IsTrue(FirstRepo is RecursionRepositoryImplementation);

            IAnotherRepository SecondRepo = (FirstRepo as RecursionRepositoryImplementation).repo;

            Assert.AreEqual(SecondRepo.IdentificateRepository(), RepositoryAnswer);
            Assert.IsTrue(SecondRepo is AnotherRepositoryImplementation);
        }
 public DefaultPaymentRepository(IAnotherRepository anotherRepo)
 {
     Console.WriteLine("Constructor of payment repo called!");
     this.anotherRepo = anotherRepo;
 }
Exemplo n.º 3
0
 public RecursionRepositoryImplementation(IAnotherRepository repo)
 {
     this.repo = repo;
 }