public void Can_Generate_Api_Xml_With_All_Controls()
        {
            //Arrange

            var expected =
                new XElement("SearchControls",
                             new XAttribute("excludeBin", "true"),
                             new XAttribute("excludeDocument", "true"),
                             new XAttribute("returnAllAttributes", "true"),
                             new XAttribute("allowPaging", "true"),
                             new XAttribute("pageSize", "2"),
                             new XAttribute("countLimit", "5"),
                             new XElement("AttributesToReturn",
                                          new XElement("Attribute", new XAttribute("name", "Artikelnummer")),
                                          new XElement("Attribute", new XAttribute("name", "Sammanslagna dataattribut"))),
                             new XElement("LanguagesToReturn",
                                          new XElement("Language", new XAttribute("id", "10")),
                                          new XElement("Language", new XAttribute("id", "11"))),
                             new XElement("ReferenceControls",
                                          new XAttribute("channelId", "3"),
                                          new XAttribute("resolveAttributes", "true"),
                                          new XAttribute("resolveSpecialCharacters", "true"),
                                          new XAttribute("valueOnly", "true"))).ToString();

            var builder = new SearchControlBuilder();

            builder
            .AddRequestFilters(
                Filter.ExcludeBin(),
                Filter.ExcludeDocument(),
                Filter.ReturnAllAttributes(true),
                Filter.AllowPaging(),
                Filter.PageSize(2),
                Filter.CountLimit(5))
            .ReturnAttributes(
                AttributeToReturn.WithName("Artikelnummer"),
                AttributeToReturn.WithName("Sammanslagna dataattribut")
                )
            .ReturnLanguages(
                LanguageToReturn.WithLanguageId(10),
                LanguageToReturn.WithLanguageId(11)
                )
            .ConfigureReferenceHandling(
                ReferenceOptions.UseChannel(3),
                ReferenceOptions.ResolveAttributes(),
                ReferenceOptions.ResolveSpecialCharacters(),
                ReferenceOptions.ReturnValuesOnly());

            var searchControl = builder.Build();

            //Act
            var actual = searchControl.ToAdsml().ToString();

            Console.WriteLine(actual);

            //Assert
            Assert.That(actual, Is.EqualTo(expected));
        }
Exemple #2
0
        public void Can_Generate_A_AllowPaging_Filter_Tag()
        {
            //Arrange
            var expected = new XAttribute("allowPaging", "true");

            //Act
            var actual = Filter.AllowPaging();

            //Assert
            Assert.That(actual.ToAdsml().ToString(), Is.EqualTo(expected.ToString()));
        }