public void Get_returns_null_when_no_provider_can_fulfil_the_request(IServiceRegistrationProvider[] providers, ResolutionRequest request) { // Arrange Mock.Get(providers[0]).Setup(x => x.CanFulfilRequest(request)).Returns(false); Mock.Get(providers[1]).Setup(x => x.CanFulfilRequest(request)).Returns(false); Mock.Get(providers[2]).Setup(x => x.CanFulfilRequest(request)).Returns(false); var sut = new StackOfRegistriesRegistrationProvider(providers); // Act var result = sut.Get(request); // Assert Assert.That(result, Is.Null); }
public void Get_gets_from_the_first_provider_which_can_fulfil_the_request(IServiceRegistrationProvider[] providers, ResolutionRequest request, IServiceRegistration registration) { // Arrange Mock.Get(providers[0]).Setup(x => x.CanFulfilRequest(request)).Returns(false); Mock.Get(providers[1]).Setup(x => x.CanFulfilRequest(request)).Returns(true); Mock.Get(providers[1]).Setup(x => x.Get(request)).Returns(registration); Mock.Get(providers[2]).Setup(x => x.CanFulfilRequest(request)).Returns(false); var sut = new StackOfRegistriesRegistrationProvider(providers); // Act var result = sut.Get(request); // Assert Assert.That(result, Is.SameAs(registration)); }
public void Get_only_gets_from_the_first_provider_which_can_fulfil_a_request(IServiceRegistrationProvider[] providers, ResolutionRequest request, IServiceRegistration registration) { // Arrange Mock.Get(providers[0]).Setup(x => x.CanFulfilRequest(request)).Returns(false); Mock.Get(providers[1]).Setup(x => x.CanFulfilRequest(request)).Returns(true); Mock.Get(providers[1]).Setup(x => x.Get(request)).Returns(registration); Mock.Get(providers[2]).Setup(x => x.CanFulfilRequest(request)).Returns(true); Mock.Get(providers[2]).Setup(x => x.Get(request)).Returns(registration); var sut = new StackOfRegistriesRegistrationProvider(providers); // Act var result = sut.Get(request); // Assert Mock.Get(providers[1]).Verify(x => x.Get(request), Times.Once); Mock.Get(providers[2]).Verify(x => x.Get(request), Times.Never); }