コード例 #1
0
        public async void GetCustomer_Person_ReturnsCustomer()
        {
            //Arrange
            var mockLogger             = new Mock <ILogger <CustomerApi> >();
            var mockHttpRequestFactory = new Mock <IHttpRequestFactory>();

            mockHttpRequestFactory.Setup(x => x.Get(
                                             It.IsAny <string>(), It.IsAny <Dictionary <string, string> >(), It.IsAny <string>()
                                             )
                                         )
            .ReturnsAsync(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new JsonContent(new GetCustomer.GetCustomerResponse
                {
                    Customer = GetCustomer_Person()
                })
            });

            var baseAddress = "BaseAddress";

            var sut = new CustomerApi(
                mockLogger.Object,
                mockHttpRequestFactory.Object,
                baseAddress
                );

            //Act
            var response = await sut.GetCustomerAsync(new GetCustomer.GetCustomerRequest());

            //Assert
            mockHttpRequestFactory.Verify(x => x.Get(It.IsAny <string>(), It.IsAny <Dictionary <string, string> >(), It.IsAny <string>()));

            response.Customer.AccountNumber.Should().Be("AW00011000");
        }