public async void GetShopperHistory_Serialize_Deserialize() { // Arrange var expectedShopperHistoryDto = new ShopperHistoryDto() { CustomerId = 123, Products = new List <ShopperHistoryProductDto>() { new ShopperHistoryProductDto() { Name = "a", Price = 1, Quantity = 2 } } }; var httpClient = FakeHttpClient.Create_WithContent("[{\"customerId\": 123,\"products\": [{\"name\": \"a\",\"price\": 1,\"quantity\": 2}]}]"); var sut = new ResourceServiceHttpHttpClient(httpClient, _mockOptions); // Act var result = await sut.GetShopperHistory(); //Assert var shopperHistory = result.ToList(); Assert.True(shopperHistory.Count.Equals(1)); Assert.Equal(expectedShopperHistoryDto.CustomerId, shopperHistory.First().CustomerId); Assert.True(shopperHistory.First().Products.Count.Equals(1)); Assert.Equal(expectedShopperHistoryDto.Products.First().Name, shopperHistory.First().Products.First().Name); Assert.Equal(expectedShopperHistoryDto.Products.First().Price, shopperHistory.First().Products.First().Price); Assert.Equal(expectedShopperHistoryDto.Products.First().Quantity, shopperHistory.First().Products.First().Quantity); }
public async void TrolleyCalculator_Serialize_Deserialize() { // Arrange var expectedResult = new decimal(1); var httpClient = FakeHttpClient.Create_WithContent(expectedResult.ToString(CultureInfo.InvariantCulture)); var trolleyTotalRequest = new TrolleyTotalRequest() { RequestedItems = new List <RequestedItem>() { new RequestedItem() }, Specials = new List <Special>() { new Special() { Inventory = new List <SpecialInventory>() { new SpecialInventory() } } }, Products = new List <Product>() { new Product() } }; var sut = new ResourceServiceHttpHttpClient(httpClient, _mockOptions); // Act var result = await sut.TrolleyCalculator(trolleyTotalRequest); //Assert Assert.Equal(expectedResult, result); }
public async void GetProducts_Serialize_Deserialize() { // Arrange var httpClient = FakeHttpClient.Create_WithContent("[{\"name\":\"a\",\"price\":0}]"); var sut = new ResourceServiceHttpHttpClient(httpClient, _mockOptions); // Act var result = await sut.GetProducts(); //Assert var products = result.ToList(); Assert.True(products.Count.Equals(1)); Assert.Equal("a", products.First().Name); }