public void DeleteWithBackupTest()
        {
            var file = GetCsvFile();

            FileSystemUtils.DeleteWithBackup(fileName, false);
            Assert.IsFalse(FileSystemUtils.FileExists(fileName));
            Assert.IsFalse(FileSystemUtils.FileExists(fileName + ".bak"));

            SerializedFilesLib.SaveSettingFile(file, () => false);
            Assert.IsTrue(FileSystemUtils.FileExists(fileName));
            FileSystemUtils.DeleteWithBackup(fileName, false);
            Assert.IsFalse(FileSystemUtils.FileExists(fileName));
            Assert.IsTrue(FileSystemUtils.FileExists(fileName + ".bak"));
        }
        public void SaveCsvFileTest()
        {
            var file = GetCsvFile();

            file.ByteOrderMark = false;
            Assert.IsFalse(FileSystemUtils.FileExists(fileName));
            var asked = false;

            SerializedFilesLib.SaveSettingFile(file, () => true);
            file.ByteOrderMark = true;

            Assert.IsTrue(FileSystemUtils.FileExists(fileName));
            SerializedFilesLib.SaveSettingFile(file, () =>
            {
                asked = true;
                return(true);
            });
            Assert.IsTrue(asked);
        }
        public void SaveAndLoadCsvFileTest()
        {
            var file = GetCsvFile();

            Assert.IsFalse(FileSystemUtils.FileExists(fileName));
            SerializedFilesLib.SaveSettingFile(file, () => true);
            Assert.IsTrue(FileSystemUtils.FileExists(fileName));
            var test = SerializedFilesLib.LoadCsvFile(fileName);

            Assert.AreNotSame(file, test);
            Assert.IsInstanceOfType(test, typeof(CsvFile));

            // FileName and ID are not serialized
            test.FileName = file.FileName;
            test.ID       = file.ID;
            file.AllPropertiesEqual(test);
            // Test Properties that are not tested

            Assert.AreEqual(file.MappingCollection.Count, test.MappingCollection.Count, "FieldMapping");
            Assert.AreEqual(TrimmingOption.Unquoted, test.TrimmingOption, "TrimmingOption");
            Assert.IsTrue(file.MappingCollection.CollectionEqual(test.MappingCollection), "Mapping");
            Assert.IsTrue(file.FileFormat.Equals(test.FileFormat), "FileFormat");
        }