Ejemplo n.º 1
0
        //send to website (through web client)
        //send to parser
        private async Task <Clothes[]> GetResults(ClothesQuery query)
        {
            string      content  = BuildSearchRequestBody(query);
            WebResponse response = await _webClient.Post(_baseUrl, content);

            CheckIfReponseIsSuccessful(response);

            return(await _searchResultsParser.Parse(response.Content));
        }
        public async Task ParserShouldReturnListSkirts()
        {
            //arrange
            var parser = new AsosSearchResultsParser();

            //act
            var result = await parser.Parse(_testHtml);

            var checkClothes = result.First();

            //assert
            result.Length.Should().Be(72);

            checkClothes.ProductId.Should().Be("product-12286529");
            checkClothes.Name.Should().Be("ASOS DESIGN soft denim maxi skirt with ruching detail");
            checkClothes.Price.Should().Be("£30.00");
            checkClothes.ImageSrc.Should().Be("//images.asos-media.com/products/asos-design-soft-denim-maxi-skirt-with-ruching-detail/12286529-1-black?$n_480w$&wid=476&fit=constrain");
            checkClothes.Href.Should().Be("https://www.asos.com/asos-design/asos-design-soft-denim-maxi-skirt-with-ruching-detail/prd/12286529?colourwayid=16516492&SearchQuery=&cid=2639");
        }