public void Can_Deserialize_RelationAttribute_Xml() { //Arrange var xml = new XElement("RelationAttribute", new XAttribute("id", "31"), new XAttribute("name", "Tillverkarrelation"), new XAttribute("nameParserClass", "foo"), new XElement("Value", new XCData("foo")), new XElement("Value", new XCData("bar"))); var expected = RelationAttribute.New("Tillverkarrelation", new[] { "foo", "bar" }, 31, "foo"); var rad = new RelationAttributeDeserializer(); //Act var actual = (RelationAttribute)rad.Deserialize(xml); //Assert Assert.That(actual.Name, Is.EqualTo(expected.Name)); Assert.That(actual.DefinitionId, Is.EqualTo(expected.DefinitionId)); Assert.That(actual.NameParserClass, Is.EqualTo(expected.NameParserClass)); Assert.That(actual.Values.ElementAt(0), Is.EqualTo(expected.Values.ElementAt(0))); Assert.That(actual.Values.ElementAt(1), Is.EqualTo(expected.Values.ElementAt(1))); }
public void Throws_InvalidOperationException_If_Element_Name_Is_Not_RelationAttribute() { //Arrange var rad = new RelationAttributeDeserializer(); //Act rad.Deserialize(new XElement("foo")); }
public void Throws_ArgumentNullException_If_Element_Is_Null() { //Arrange var rad = new RelationAttributeDeserializer(); //Act Assert.Throws <ArgumentNullException>(() => rad.Deserialize(null)); }
public void Deserialize_Returns_Correct_Object_With_Less_Data_Input() { //Arrange var xml = new XElement("RelationAttribute", new XAttribute("name", "foo")); var des = new RelationAttributeDeserializer(); //Act var actual = (RelationAttribute)des.Deserialize(xml); //Assert Assert.That(actual, Is.Not.Null); Assert.That(actual.Name, Is.EqualTo("foo")); }