public async Task GetFundingStreamById_GivenFundingStreamnWasNotFound_ReturnsNotFound() { // Arrange const string fundingStreamId = "fs-1"; ILogger logger = CreateLogger(); IPolicyRepository policyRepository = CreatePolicyRepository(); policyRepository .GetFundingStreamById(Arg.Is(fundingStreamId)) .Returns((FundingStream)null); FundingStreamService fundingStreamsService = CreateFundingStreamService(logger: logger, policyRepository: policyRepository); // Act IActionResult result = await fundingStreamsService.GetFundingStreamById(fundingStreamId); // Assert result .Should() .BeOfType <NotFoundResult>(); logger .Received(1) .Error(Arg.Is($"No funding stream was found for funding stream id : {fundingStreamId}")); }
public async Task GetFundingStreamById__GivenFundingStreamWasFound_ReturnsSuccess() { // Arrange const string fundingStreamId = "fs-1"; FundingStream fundingStream = new FundingStream { Id = fundingStreamId, Name = "Funding Stream Name", ShortName = "FSN", }; IPolicyRepository policyRepository = CreatePolicyRepository(); policyRepository .GetFundingStreamById(Arg.Is(fundingStreamId)) .Returns(fundingStream); FundingStreamService fundingStreamsService = CreateFundingStreamService(policyRepository: policyRepository); // Act IActionResult result = await fundingStreamsService.GetFundingStreamById(fundingStreamId); // Assert result .Should() .BeOfType <OkObjectResult>() .Which .Value .Should() .Be(fundingStream); }
public async Task GetFundingStreamById_GivenFundingStreamIdDoesNotExist_ReturnsBadRequest(string fundingStreamId) { // Arrange ILogger logger = CreateLogger(); FundingStreamService fundingStreamsService = CreateFundingStreamService(logger: logger); // Act IActionResult result = await fundingStreamsService.GetFundingStreamById(fundingStreamId); // Assert result .Should() .BeOfType <BadRequestObjectResult>() .Which .Value .Should() .Be("Null or empty funding stream Id provided"); logger .Received(1) .Error(Arg.Is("No funding stream Id was provided to GetFundingStreamById")); }