public static async Task GetByOdsCodeAsync_OrganisationIsNotBuyerOrganisation_ReturnsNotAccepted() { var nonBuyerOrganisation = OdsOrganisationBuilder.Create(1).Build(); var organisation = OrganisationBuilder.Create(1).WithOdsCode(nonBuyerOrganisation.OdsCode).Build(); using var controller = OdsControllerBuilder .Create() .WithGetByOdsCode(nonBuyerOrganisation, organisation) .Build(); var response = await controller.GetByOdsCodeAsync(nonBuyerOrganisation.OdsCode); response.As <StatusCodeResult>().StatusCode.Should().Be((int)StatusCodes.Status406NotAcceptable); }
public async Task GetByOdsCodeAsync_OrganisationIsNotBuyerOrganisation_ReturnsNotAccepted() { var nonBuyerOrganisation = OdsOrganisationBuilder.Create(1).Build(); using var controller = OdsControllerBuilder .Create() .WithGetByOdsCode(nonBuyerOrganisation) .Build(); var response = await controller.GetByOdsCodeAsync("dolor eternum"); response.Should().BeOfType <StatusCodeResult>(); response.Should().BeEquivalentTo(new StatusCodeResult(StatusCodes.Status406NotAcceptable)); }
public async Task GetByOdsCodeAsync_OrganisationExists_ReturnsActiveBuyerOrganisation() { var buyerOrganisation = OdsOrganisationBuilder.Create(1, true).Build(); using var controller = OdsControllerBuilder .Create() .WithGetByOdsCode(buyerOrganisation) .Build(); var response = await controller.GetByOdsCodeAsync(buyerOrganisation.OdsCode); response.Should().BeOfType <OkObjectResult>(); var result = response as OkObjectResult; result.Value.Should().BeEquivalentTo(buyerOrganisation, options => options.Excluding(o => o.IsActive).Excluding(o => o.IsBuyerOrganisation)); }
public static async Task GetByOdsCodeAsync_OrganisationDoesNotExists_ReturnsOrganisationWithNullOrganisationId() { var buyerOrganisation = OdsOrganisationBuilder.Create(1, true).Build(); using var controller = OdsControllerBuilder .Create() .WithGetByOdsCode(buyerOrganisation, null) .Build(); var response = await controller.GetByOdsCodeAsync(buyerOrganisation.OdsCode); response.Should().BeOfType <OkObjectResult>(); response.As <OkObjectResult>().Value.Should().BeEquivalentTo( new OdsOrganisationModel { OdsCode = buyerOrganisation.OdsCode, OrganisationId = null, OrganisationName = buyerOrganisation.OrganisationName, PrimaryRoleId = buyerOrganisation.PrimaryRoleId, }); }