public void Can_Generate_Api_Xml() { //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")))))).ToString(); //Act var modReq = new ModifyRequest("/foo/bar", new List <ModificationItem> { ModificationItem.New( Modifications.AddValue, StructureAttribute.New(31, new StructureValue(10, "foo")) ) }); 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 Validate_Throws_ApiSerializationValidationException_When_Modifications_Is_Empty() { //Arrange var modReq = new ModifyRequest("foo", new List <ModificationItem>()); //Act modReq.ToAdsml(); //Assert Assert.Fail("Expected exception not thrown."); }
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 Validate_Throws_ApiSerializationValidationException_When_Context_Is_Empty() { //Arrange var modReq = new ModifyRequest(string.Empty, new List <ModificationItem> { ModificationItem.New( Modifications.AddValue, StructureAttribute.New(31, new StructureValue(10, "foo")) ) }); //Act modReq.ToAdsml(); //Assert Assert.Fail("Expected exception not thrown."); }