Ejemplo n.º 1
0
        public async Task GivenACompaniesHouseRegistereOfficeAddressClient_WhenGettingARegisteredOfficeAddress(CompaniesHouseRegisteredOfficeAddressTestCase testCase)
        {
            var registeredOfficeAddress = RegisteredOfficeAddressBuilder.Build(testCase);
            var resource = new RegisteredOfficeAddressResourceBuilder(registeredOfficeAddress).Create();

            var uri = new Uri("https://wibble.com/company/wobble/registered-office-address");

            HttpMessageHandler handler = new StubHttpMessageHandler(uri, resource);

            var uriBuilder = new Mock <IRegisteredOfficeAddressUriBuilder>();

            uriBuilder.Setup(x => x.Build(It.IsAny <string>())).Returns(uri);

            var client = new CompaniesHouseRegisteredOfficeAddressClient(new HttpClient(handler), uriBuilder.Object);

            var result = await client.GetRegisteredOfficeAddress("abc");

            result.Data.ShouldBeEquivalentTo(registeredOfficeAddress, opt => opt.Excluding(x => x.Country));

            result.Data.Country.GetEnumMemberValue().Should().Be(registeredOfficeAddress.Country);
        }
 public static OfficeAddress Build(CompaniesHouseRegisteredOfficeAddressTestCase testCase) =>
 new Fixture()
 .Build <OfficeAddress>()
 .With(x => x.Country, testCase.Country)
 .Create();