public void DeserializeSimpleTestClassWithoutAttributes_FileAndObjectExists_FileIsDeserializedToObjectCorrectly()
        {
            // Arrange
            SimpleTestClassWithoutAttributes testClass = new SimpleTestClassWithoutAttributes();
            string fileName = this.applicationPath + "\\FileHandling\\TestFiles\\SimpleTestClassWithoutAttributesFile.xml";

            // Act
            testClass = XmlDeserializer.Deserialize <SimpleTestClassWithoutAttributes>(fileName);

            // Assert
            Assert.IsTrue(
                testClass.HouseNumber == 4 && testClass.City == "Baierbach",
                "The deserialized object contains the expected Data.");
        }
        public void DeserializeTestFileWithMultipleEntries_FileAndObjectExists_FileIsDeserializedToObjectCorrectly()
        {
            // Arrange
            SimpleTestClassDirectory simpleTestClassDirectory = new SimpleTestClassDirectory();
            string fileName = this.applicationPath + "\\FileHandling\\TestFiles\\TestFileWithMultipleEntries.xml";

            // Act
            simpleTestClassDirectory = XmlDeserializer.Deserialize <SimpleTestClassDirectory>(fileName);

            SimpleTestClassWithoutAttributes firstElement  = simpleTestClassDirectory.TestClasses[0];
            SimpleTestClassWithoutAttributes secondElement = simpleTestClassDirectory.TestClasses[1];

            // Assert
            Assert.IsTrue(
                firstElement.City == "Baierbach" && secondElement.City == "Stephanskirchen",
                "The deserialized object contains the expected Data.");
        }
Esempio n. 3
0
        public void XmlSerializeSimpleClassToFile_SimpleTestClassExists_FileIsCreated()
        {
            // Arrange
            SimpleTestClassWithoutAttributes testClass = new SimpleTestClassWithoutAttributes()
            {
                HouseNumber = 4,
                StreetName  = "Edlinger Str.",
                City        = "Baierbach"
            };

            string fileName = this.applicationPath + "\\simpleTestClass.xml";

            // Act
            XmlSerializer.Serialize(testClass, fileName);

            // Assert
            Assert.IsTrue(File.Exists(fileName), "The *.xml File was created");

            // CleanUp
            File.Delete(fileName);
        }