Exemplo n.º 1
0
        public void ParseCompletionInvalidJson()
        {
            var productParser = new ProductParser();
            var jsonStr       = @"[""suit""]";

            Assert.Throws <InvalidOperationException>(() => productParser.ParseProductCompletion(jsonStr));
        }
Exemplo n.º 2
0
        public void ParseCompletionSuccess()
        {
            var productParser   = new ProductParser();
            var origSuggestions = new List <string>()
            {
                "suitcase",
                "suits season 8",
                "suitcases with wheels",
                "suit bag",
                "suit travel bag",
                "suitcase lock",
                "suitcase organizer",
                "suit bags for men",
                "suits",
                "suit hanger"
            };
            var jsonStr    = @"[""suit"",[""suitcase"",""suits season 8"",""suitcases with wheels"",""suit bag"",""suit travel bag"",""suitcase lock"",""suitcase organizer"",""suit bags for men"",""suits"",""suit hanger""],[{""nodes"":[{""name"":""Luggage & Travel Gear"",""alias"":""fashion-luggage""}]},{},{},{},{},{},{},{},{},{}],[],""3XPFVRN05ZSW""]";
            var suggestion = productParser.ParseProductCompletion(jsonStr).ToHashSet();

            foreach (var item in origSuggestions)
            {
                Assert.True(suggestion.Contains(item), $"{item} is not in result");
            }
        }