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; }
public RecursionRepositoryImplementation(IAnotherRepository repo) { this.repo = repo; }