public static async Task GetBuyerOrganisationByOdsCode_WithValidResponse_Returns_BuyerOrganisation() { var context = OdsRepositoryTestContext.Setup(); using var httpTest = new HttpTest(); httpTest.RespondWith(status: 200, body: ValidResponseBody); var expected = new OdsOrganisation { OdsCode = OdsCode, OrganisationName = "SOUTH EAST - H&J COMMISSIONING HUB", PrimaryRoleId = "RO98", Address = new Address { Line1 = "C/O NHS ENGLAND", Line2 = "1W09, 1ST FLOOR, QUARRY HOUSE", Line3 = "QUARRY HILL", Town = "LEEDS", Postcode = "LS2 7UA", Country = "ENGLAND", }, IsActive = true, IsBuyerOrganisation = true, }; var actual = await context.OdsRepository.GetBuyerOrganisationByOdsCodeAsync(OdsCode); actual.Should().BeOfType <OdsOrganisation>(); actual.Should().NotBeNull(); actual.Should().BeEquivalentTo(expected); }
internal OdsControllerBuilder WithGetByOdsCode(OdsOrganisation result) { var odsRepositoryMock = new Mock <IOdsRepository>(); odsRepositoryMock.Setup(x => x.GetBuyerOrganisationByOdsCodeAsync(It.IsAny <string>())).ReturnsAsync(result); _odsRepository = odsRepositoryMock.Object; return(this); }
internal OdsControllerBuilder WithGetByOdsCode(OdsOrganisation result, Organisation organisation) { var odsRepositoryMock = new Mock <IOdsRepository>(); if (result is not null) { odsRepositoryMock.Setup(r => r.GetBuyerOrganisationByOdsCodeAsync(result.OdsCode)).ReturnsAsync(result); } odsRepository = odsRepositoryMock.Object; var orgRepositoryMock = new Mock <IOrganisationRepository>(); if (organisation is not null) { orgRepositoryMock .Setup(o => o.GetByOdsCodeAsync(result == null ? organisation.OdsCode : result.OdsCode)) .ReturnsAsync(organisation); } orgRepository = orgRepositoryMock.Object; return(this); }