Exemple #1
0
        public void FileBackup_BackupDirectory_OnBaseFiles_ShouldCreateAZipFile()
        {
            var fileBackup = new FileBackup()
            {
                SaveDirectory = new DirectoryInfo(BasePath)
            };

            Assert.AreEqual(true, fileBackup.LoadDirectory());
            Assert.AreEqual(FileBackupStatus.Loaded, fileBackup.Status);
            Assert.AreEqual(1, fileBackup.Characters.Count);

            var saveName = $"bu{DateTime.Now:yy-MM-dd-mm-ss}";

            var filePath = $"{saveName}.zip";

            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }

            Console.WriteLine(filePath);

            Assert.AreEqual(true, fileBackup.BackUpDirectory($"{saveName}").Result);
            Assert.AreEqual(true, File.Exists($"{saveName}.zip"));
        }
Exemple #2
0
        public void FileBackup_LoadDirectory_OnRandomPath_ShouldReturnFalse()
        {
            var fileBackup = new FileBackup()
            {
                SaveDirectory = new DirectoryInfo($"{BasePath}/NIMP")
            };

            Assert.AreEqual(false, fileBackup.LoadDirectory());
            Assert.AreEqual(FileBackupStatus.Error, fileBackup.Status);
        }
Exemple #3
0
        public void FileBackup_LoadDirectory_OnBaseFiles_ShouldDetect1Character()
        {
            var fileBackup = new FileBackup()
            {
                SaveDirectory = new DirectoryInfo(BasePath)
            };

            Assert.AreEqual(true, fileBackup.LoadDirectory());
            Assert.AreEqual(FileBackupStatus.Loaded, fileBackup.Status);
            Assert.AreEqual(1, fileBackup.Characters.Count);
            Assert.AreEqual("Bamboulorc", fileBackup.Characters.First());
        }
Exemple #4
0
        public void FileBackup_RestoreDirectory_OnBaseFiles_ShouldRestoreThemProperly()
        {
            var fileBackup = new FileBackup()
            {
                SaveDirectory = new DirectoryInfo(BasePath)
            };

            Assert.AreEqual(true, fileBackup.LoadDirectory());
            Assert.AreEqual(FileBackupStatus.Loaded, fileBackup.Status);
            Assert.AreEqual(1, fileBackup.Characters.Count);

            var saveName = $"bu{DateTime.Now:yy-MM-dd-mm-ss}";

            var filePath = $"{saveName}.zip";

            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }


            Assert.AreEqual(true, fileBackup.BackUpDirectory($"{saveName}").Result);
            Assert.AreEqual(true, File.Exists(filePath));

            new DirectoryInfo(BasePath).Delete(true);
            var reloadFb = new FileBackup()
            {
                SaveDirectory = new DirectoryInfo(BasePath)
            };

            Assert.AreEqual(false, reloadFb.LoadDirectory());
            Assert.AreEqual(true, fileBackup.RestoreDirectory(source: filePath).Result);

            Assert.AreEqual(true, reloadFb.LoadDirectory());
            Assert.AreEqual(FileBackupStatus.Loaded, reloadFb.Status);
            Assert.AreEqual(1, reloadFb.Characters.Count);
            Assert.AreEqual("Bamboulorc", reloadFb.Characters.First());
        }