示例#1
0
        public void Serializable_works()
        {
            //Arrange
            MockFileData data = new MockFileData("Text Contents");

            //Act
            var    serializer = new XmlSerializer(data.GetType());
            Stream stream     = new MemoryStream();

            serializer.Serialize(stream, data);

            //Assert
            Assert.True(true);
        }
示例#2
0
        public void Serializable_can_deserialize()
        {
            //Arrange
            string textContentStr = "Text Contents";

            //Act
            MockFileData data = new MockFileData(textContentStr);

            var    serializer = new XmlSerializer(data.GetType());
            Stream stream     = new MemoryStream();

            serializer.Serialize(stream, data);

            stream.Seek(0, SeekOrigin.Begin);

            MockFileData deserialized = (MockFileData)serializer.Deserialize(stream);

            //Assert
            Assert.Equal(deserialized.TextContents, textContentStr);
        }