Пример #1
0
        public async void GetProduct_ReturnsProduct()
        {
            //Arrange
            var mockLogger             = new Mock <ILogger <ProductApi> >();
            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 GetProductResponse
                {
                    Product = new Core.Abstractions.Api.ProductApi.GetProduct.Product
                    {
                        ProductNumber = "ST-1401"
                    }
                })
            });

            var baseAddress = "BaseAddress";

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

            //Act
            var response = await sut.GetProduct(new GetProductRequest());

            //Assert
            mockHttpRequestFactory.Verify(x => x.Get(It.IsAny <string>(), It.IsAny <Dictionary <string, string> >(), It.IsAny <string>()));
            response.Product.ProductNumber.Should().Be("ST-1401");
        }