public void Can_Build_Advanced_LinkRequest()
        {
            //Arrange
            string expected =
                new XElement("LinkRequest",
                             new XAttribute("name", "/foo"),
                             new XAttribute("targetLocation", "/bar"),
                             new XAttribute("returnNoAttributes", "true"),
                             new XElement("CopyControls",
                                          new XAttribute("copyLocalAttributes", "true"),
                                          new XElement("LookupControls",
                                                       new XElement("LanguagesToReturn",
                                                                    new XElement("Language",
                                                                                 new XAttribute("id", "10")))))).ToString();

            _builder.SourceContext("/foo")
            .TargetPath("/bar")
            .ReturnNoAttributes()
            .ConfigureCopyControls()
            .CopyLocalAttributesFromSource()
            .ConfigureLookupControls()
            .ReturnLanguages(LanguageToReturn.WithLanguageId(10));

            //Act
            var    request = _builder.Build();
            string actual  = _builder.Build().ToAdsml().ToString();

            //Assert
            Assert.That(request.SourcePath, Is.EqualTo(_builder.Source));
            Assert.That(request.TargetPath, Is.EqualTo(_builder.Target));
            Assert.That(request.RequestFilters.Count(), Is.EqualTo(_builder.RequestFilters.Count()));
            Assert.That(actual, Is.EqualTo(expected));
        }
Exemplo n.º 2
0
        public void CanGenerateApiXmlWithLookupControl()
        {
            //Arrange
            string expexcted =
                new XElement("LookupRequest",
                             new XAttribute("name", "/Schema/Attribute Sets/Översättningsattribut"),
                             new XElement("LookupControls",
                                          new XElement("AttributesToReturn",
                                                       new XAttribute("namelist", "members")),
                                          new XElement("LanguagesToReturn",
                                                       new XElement("Language",
                                                                    new XAttribute("id", "10"))))).ToString();

            var lookupBuilder = new LookupControlBuilder();

            lookupBuilder.AttributeNamelist("members").ReturnLanguages(LanguageToReturn.WithLanguageId(10));

            //Act
            var req          = new LookupRequest("/Schema/Attribute Sets/Översättningsattribut", lookupBuilder.Build());
            var actual       = req.ToAdsml();
            var batchRequest = new BatchRequest(req);

            Console.WriteLine(actual);

            //Assert
            Assert.That(actual.ToString(), Is.EqualTo(expexcted));
            Assert.DoesNotThrow(() => batchRequest.ToAdsml().ValidateAdsmlDocument("adsml.xsd"));
        }
        public void Can_Configure_ReferenceControls()
        {
            //Arrange
            var expected =
                new XElement("LookupControls",
                             new XAttribute("returnRelationsAsAttributes", "true"),
                             new XElement("AttributesToReturn",
                                          new XElement("Attribute", new XAttribute("name", "Artikelnummer"))),
                             new XElement("LanguagesToReturn",
                                          new XElement("Language", new XAttribute("id", "10"))),
                             new XElement("ReferenceControls", new XAttribute("valueOnly", "true")));

            var builder = new LookupControlBuilder();

            //Act
            builder.AddRequestFilters(Filter.ReturnRelationsAsAttributes())
            .ReturnAttributes(AttributeToReturn.WithName("Artikelnummer"))
            .ReturnLanguages(LanguageToReturn.WithLanguageId(10))
            .ConfigureReferenceHandling(ReferenceOptions.ReturnValuesOnly());

            var request = builder.Build().ToAdsml();

            //Assert
            Assert.That(request.ToString(), Is.EqualTo(expected.ToString()));
        }
        public void CanBuildCreateRequest()
        {
            //Arrange
            var builder = new CreateRequestBuilder();

            //Act
            builder
            .NewContextName("/foo/bar")
            .ObjectTypeToCreate("baz")
            .ReturnNoAttributes()
            .FailOnError()
            .UpdateIfExists()
            .AttributesToSet(
                StructureAttribute.New(215, new StructureValue(10, "169010"))
                )
            .ConfigureLookupControls()
            .ReturnAttributes(AttributeToReturn.WithName("Artikelnummer"))
            .ReturnLanguages(LanguageToReturn.WithLanguageId(10))
            .ConfigureReferenceHandling(
                ReferenceOptions.ReturnValuesOnly()
                );

            var request = new BatchRequest(builder.Build());

            //Assert
            Assert.That(builder.Build(), Is.Not.Null);
            Assert.DoesNotThrow(() => request.ToAdsml().ValidateAdsmlDocument("adsml.xsd"));
        }
Exemplo n.º 5
0
        public void Can_Combine_All_Api_Commands()
        {
            //Arrange
            var aqlBuilder = new AqlQueryBuilder();

            //Act
            aqlBuilder.BasePath("/foo/bar")
            .SearchRequestFilters(Filter.ReturnNoAttributes())
            .QueryType(AqlQueryTypes.Below)
            .ObjectTypeToFind(12)
            .QueryString("#215 = \"foo\"")
            .ConfigureSearchControls()
            .AddRequestFilters(
                Filter.ExcludeBin(),
                Filter.ExcludeDocument(),
                Filter.CountLimit(1))
            .ReturnAttributes(AttributeToReturn.WithName("Artikelnummer"))
            .ReturnLanguages(LanguageToReturn.WithLanguageId(10))
            .ConfigureReferenceHandling(
                ReferenceOptions.ResolveAttributes(),
                ReferenceOptions.ResolveSpecialCharacters(),
                ReferenceOptions.UseChannel(3),
                ReferenceOptions.ReturnValuesOnly());

            Console.WriteLine(aqlBuilder.Build().ToAdsml().ToString());
            var request = new BatchRequest(aqlBuilder.Build());

            //Assert
            Assert.DoesNotThrow(() => aqlBuilder.Build());
            Assert.DoesNotThrow(() => request.ToAdsml().ValidateAdsmlDocument("adsml.xsd"));
        }
        public void CanConfigureLookupControls()
        {
            //Act
            _builder.ConfigureLookupControls().ReturnLanguages(LanguageToReturn.WithLanguageId(10));

            //Assert
            Assert.That(_builder.LookupControlBuilder, Is.Not.Null);
        }
        public void Validate_Throws_ASVE_If_LanguageId_Is_Negative()
        {
            //Arrange
            var ltr = LanguageToReturn.WithLanguageId(-1);

            //Act
            ltr.Validate();
        }
        public void Can_Create_New_LanguageToReturn_With_Static_Factorymethod()
        {
            //Act
            var ltr = LanguageToReturn.WithLanguageId(10);

            //Assert
            Assert.That(ltr, Is.Not.Null);
        }
        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));
        }
        public void Can_Generate_Api_Xml()
        {
            //Arrange
            var expected = new XElement("Language", new XAttribute("id", "10")).ToString();
            var ltr      = LanguageToReturn.WithLanguageId(10);

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

            //Assert
            Assert.That(actual, Is.EqualTo(expected));
        }
        public void Can_Generate_Api_Xml()
        {
            //Arrange
            var expected = new XElement("LanguagesToReturn", new XElement("Language", new XAttribute("id", "10")));
            var asc      = new LanguageControl(LanguageToReturn.WithLanguageId(10));

            //Act
            var actual = asc.ToAdsml();

            //Assert
            Assert.That(actual.ToString(), Is.EqualTo(expected.ToString()));
        }
Exemplo n.º 12
0
        public void Can_Generate_Api_Xml_With_LookupControls()
        {
            //Arrange
            string expected =
                new XElement("ModifyRequest",
                             new XAttribute("name", "/foo/bar"),
                             new XElement("ModificationItem",
                                          new XAttribute("operation", "addValue"),
                                          new XElement("AttributeDetails",
                                                       new XElement("StructureAttribute",
                                                                    new XAttribute("id", "31"),
                                                                    new XElement("StructureValue",
                                                                                 new XAttribute("langId", "10"),
                                                                                 new XAttribute("scope", "global"),
                                                                                 new XCData("foo"))))),
                             new XElement("LookupControls",
                                          new XElement("AttributesToReturn",
                                                       new XElement("Attribute",
                                                                    new XAttribute("name", "Artikelnummer"))),
                                          new XElement("LanguagesToReturn",
                                                       new XElement("Language",
                                                                    new XAttribute("id", "10"))))).ToString();

            var lookupBuilder = new LookupControlBuilder();

            lookupBuilder.ReturnAttributes(AttributeToReturn.WithName("Artikelnummer"))
            .ReturnLanguages(LanguageToReturn.WithLanguageId(10));

            //Act
            var modReq = new ModifyRequest("/foo/bar", new List <ModificationItem> {
                ModificationItem.New(
                    Modifications.AddValue,
                    StructureAttribute.New(31, new StructureValue(10, "foo"))
                    )
            })
            {
                LookupControl = lookupBuilder.Build()
            };

            var actual  = modReq.ToAdsml();
            var request = new BatchRequest(modReq);

            Console.WriteLine(actual.ToString());

            //Assert
            Assert.That(actual.ToString(), Is.EqualTo(expected));
            Assert.DoesNotThrow(() => request.ToAdsml().ValidateAdsmlDocument("adsml.xsd"));
        }
        public void Can_Generate_Api_Xml_With_Outer_Node_XAttributes()
        {
            //Arrange
            var expected = new XElement("LanguagesToReturn", new XAttribute("foo", "bar"),
                                        new XElement("Language", new XAttribute("id", "10")));

            var asc = new LanguageControl(LanguageToReturn.WithLanguageId(10))
            {
                OuterNodeAttributes = new List <XAttribute> {
                    new XAttribute("foo", "bar")
                }
            };

            //Act
            var actual = asc.ToAdsml();

            //Assert
            Assert.That(actual.ToString(), Is.EqualTo(expected.ToString()));
        }
        public void Can_Generate_Api_Xml_With_LanguagesToReturn()
        {
            //Arrange
            var expected =
                new XElement("SearchControls",
                             new XElement("LanguagesToReturn",
                                          new XElement("Language", new XAttribute("id", "10"))));

            var builder = new SearchControlBuilder();

            builder.ReturnLanguages(LanguageToReturn.WithLanguageId(10));

            var controls = builder.Build();

            //Act
            var actual = controls.ToAdsml();

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

            Console.WriteLine(actual.ToString());
        }