public void LoadModelFromXml() { using (var reader = XmlReader.Create("model.xml")) { var model = serializer.Deserialize(reader); // model.xml has 3 nodes Assert.Equal(3, model.Nodes.Count()); } }
public void ModelXmlSerializer_Deserialize() { // Arrange var modelSerializer = new ModelXmlSerializer(); var contentToSerialize = "<?xml version=\"1.0\" encoding=\"utf-8\"?><ModelToSerialize xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Name>Name</Name><Surname>Surname</Surname></ModelToSerialize>"; var modelExpected = new ModelToSerialize() { Name = "Name", Surname = "Surname" }; //Act var response = modelSerializer.Deserialize <ModelToSerialize>(contentToSerialize); //Assert Assert.NotNull(response); Assert.Equal(modelExpected.Name, response.Name); Assert.Equal(modelExpected.Surname, response.Surname); }