Ejemplo n.º 1
0
        private FileInfo GetOrCreateDatabaseFile()
        {
            if (!Directory.Exists(fileDirectory))
            {
                Directory.CreateDirectory(fileDirectory);
            }

            var file = new FileInfo(fileDirectory + fileName);

            if (!file.Exists)
            {
                XmlSerializerUtil.SerializeToFile(new PersonList(), file.FullName);
            }

            return(file);
        }
Ejemplo n.º 2
0
        public void SerializeToFile_Equals_DeserializeFromFile()
        {
            // arrange
            var tmpFilePath  = Path.Combine(Environment.CurrentDirectory, "PersonList.xml");
            var expectedList = getTestPersonList();

            //String expectedString = getTestXmlArrayString();

            // act
            XmlSerializerUtil.SerializeToFile(expectedList, tmpFilePath);
            var deserializePersonList = XmlSerializerUtil.DeserializeFromFile <PersonList>(tmpFilePath);

            // asset
            Assert.IsTrue(File.Exists(tmpFilePath));
            deserializePersonList.ShouldBeEquivalentTo(expectedList);

            // clean
            File.Delete(tmpFilePath);
        }
Ejemplo n.º 3
0
 public void SavePersonList(ObservableCollection <Person> list)
 {
     XmlSerializerUtil.SerializeToFile(new PersonList(list), GetOrCreateDatabaseFile().FullName);
 }