public static ResourceBuilders.Officer Build(CompaniesHouseOfficerByAppointmentTestCase testCase) { var fixture = new Fixture(); fixture.Customizations.Add(new UniversalDateSpecimenBuilder <ResourceBuilders.Officer>(x => x.AppointedOn)); fixture.Customizations.Add(new UniversalDateSpecimenBuilder <ResourceBuilders.Officer>(x => x.ResignedOn)); return(fixture .Build <ResourceBuilders.Officer>() .With(x => x.OfficerRole, testCase.OfficerRole) .Create()); }
public async Task GivenACompaniesHouseOffficerAppointmentClient_WhenGettingAnOfficerByAppointmentId(CompaniesHouseOfficerByAppointmentTestCase testCase) { var officersAppointment = OfficerBuilder.Build(testCase); var resource = OfficersResourceBuilder.CreateSingle(officersAppointment); var uri = new Uri("https://wibble.com/company/wobble/registered-office-address"); HttpMessageHandler handler = new StubHttpMessageHandler(uri, resource); var uriBuilder = new Mock <IOfficersAppointmentUriBuilder>(); uriBuilder.Setup(x => x.Build(It.IsAny <string>(), It.IsAny <string>())).Returns(uri); var client = new CompaniesHouseOfficerByByAppointmentClient(new HttpClient(handler), uriBuilder.Object); var result = await client.GetOfficerByAppointmentIdAsync("abc", "1"); result.Data.ShouldBeEquivalentTo(officersAppointment); }