public void CanGenerateApiXmlWithLookupControl()
        {
            //Arrange
            var expected =
                new XElement("CreateRequest",
                             new XAttribute("name", "fooPath"),
                             new XAttribute("type", "fooObjectTypeName"),
                             new XElement("LookupControls",
                                          new XElement("AttributesToReturn",
                                                       new XElement("Attribute",
                                                                    new XAttribute("name", "fooAttributeName")))),
                             new XElement("AttributesToSet",
                                          new XElement("StructureAttribute",
                                                       new XAttribute("id", "215"),
                                                       new XAttribute("name", "fooAttributeName"),
                                                       new XElement("StructureValue",
                                                                    new XAttribute("langId", "10"),
                                                                    new XAttribute("scope", "global"),
                                                                    new XCData("fooValue")))));

            var value = new StructureValue {
                LanguageId = 10, Value = "fooValue"
            };
            var attribute = new StructureAttribute {
                DefinitionId = 215,
                Name         = "fooAttributeName",
                Values       = new List <StructureValue> {
                    value
                }
            };

            var lcb = new LookupControlBuilder();

            lcb.ReturnAttributes(AttributeToReturn.WithName("fooAttributeName"));
            var lc = lcb.Build();

            var create = new CreateRequest("fooObjectTypeName", "fooPath", null, attribute)
            {
                LookupControl = lc
            };

            //Act
            var actual  = create.ToAdsml();
            var request = new BatchRequest(create);

            Console.WriteLine(actual);

            //Assert
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.ToString(), Is.EqualTo(expected.ToString()));
            Assert.DoesNotThrow(() => request.ToAdsml().ValidateAdsmlDocument("adsml.xsd"));
        }
        public void CanGenerateApiXmlWithRequestFilters()
        {
            //Arrange
            var expected =
                new XElement("CreateRequest",
                             new XAttribute("name", "fooPath"),
                             new XAttribute("type", "fooObjectTypeName"),
                             new XAttribute("returnNoAttributes", "true"),
                             new XAttribute("failOnError", "true"),
                             new XAttribute("updateIfExists", "true"),
                             new XElement("AttributesToSet",
                                          new XElement("StructureAttribute",
                                                       new XAttribute("id", "215"),
                                                       new XAttribute("name", "fooAttributeName"),
                                                       new XElement("StructureValue",
                                                                    new XAttribute("langId", "10"),
                                                                    new XAttribute("scope", "global"),
                                                                    new XCData("fooValue")))));

            var value = new StructureValue {
                LanguageId = 10, Value = "fooValue"
            };
            var attribute = new StructureAttribute {
                DefinitionId = 215,
                Name         = "fooAttributeName",
                Values       = new List <StructureValue> {
                    value
                }
            };

            var create = new CreateRequest("fooObjectTypeName", "fooPath", null, attribute)
            {
                RequestFilters =
                    new List <ICreateRequestFilter> {
                    Filter.ReturnNoAttributes(),
                Filter.FailOnError(),
                Filter.UpdateIfExists()
                }
            };

            //Act
            var actual  = create.ToAdsml();
            var request = new BatchRequest(create);

            //Assert
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.ToString(), Is.EqualTo(expected.ToString()));
            Assert.DoesNotThrow(() => request.ToAdsml().ValidateAdsmlDocument("adsml.xsd"));
        }