Example #1
0
        public void ApplyDifferenceDeleteFolderTopFolder()
        {
            ApplyDifferenceCreateFolderTopFolder();
            string           folderToDelete   = "Nagesh";
            FolderRepository dbRepository     = new FolderRepository($@"{Utils.GetSetupDir()}\DbFolder");
            FolderRepository uploadRepository = new FolderRepository(
                $@"{Utils.GetSetupDir()}\UploadFolder");

            uploadRepository.Delete($@"{folderToDelete}", true);
            List <Storage> output  = Utils.Compare(dbRepository, uploadRepository, "");
            Storage        storage = output[0];

            dbRepository.ApplyChanges(
                "",
                output);
            List <Storage> dbStorageList = dbRepository.PopulateStorageList(
                "");

            foreach (Storage myStorage in dbStorageList)
            {
                if (myStorage.Name == folderToDelete)
                {
                    Assert.Fail($"{folderToDelete} should not show up as it should be deleted");
                }
            }
        }
Example #2
0
        public void ApplyDifferenceCreateFile()
        {
            string           fileToAdd        = "Bhanu.txt";
            FolderRepository dbRepository     = new FolderRepository($@"{Utils.GetSetupDir()}\DbFolder");
            FolderRepository uploadRepository = new FolderRepository(
                $@"{Utils.GetSetupDir()}\UploadFolder");

            uploadRepository.Create("Folder1", fileToAdd, false);
            List <Storage> output  = Utils.Compare(dbRepository, uploadRepository, "Folder1");
            Storage        storage = output[0];

            dbRepository.ApplyChanges(
                "Folder1",
                output);
            List <Storage> dbStorageList = dbRepository.PopulateStorageList(
                "Folder1");
            bool isFound = false;

            foreach (Storage myStorage in dbStorageList)
            {
                if (myStorage.Name == fileToAdd)
                {
                    Assert.AreEqual(false, myStorage.IsFolder, "Incorrect type");
                    isFound = true;
                }
            }
            Assert.IsTrue(isFound, $"{fileToAdd} cannot be found in the db");
        }
Example #3
0
        public void ApplyDifferenceDeleteFileTopFolder()
        {
            //ApplyDifferenceCreateFileTopFolder();
            string           fileToDelete     = "File1.txt";
            FolderRepository dbRepository     = new FolderRepository($@"{Utils.GetSetupDir()}\DbFolder");
            FolderRepository uploadRepository = new FolderRepository(
                $@"{Utils.GetSetupDir()}\UploadFolder");

            uploadRepository.Delete(fileToDelete, false);
            List <Storage> output  = Utils.Compare(dbRepository, uploadRepository, "");
            Storage        storage = output[0];

            dbRepository.ApplyChanges(
                "",
                output);
            List <Storage> dbStorageList = dbRepository.PopulateStorageList(
                "");

            foreach (Storage myStorage in dbStorageList)
            {
                if (myStorage.Name == fileToDelete)
                {
                    Assert.Fail($"The file {fileToDelete} should be deleted but it is still present");
                }
            }
        }
Example #4
0
        public void ApplyDifferenceCreateFolderTopFolder()
        {
            string           folderToAdd      = "Nagesh";
            FolderRepository dbRepository     = new FolderRepository($@"{Utils.GetSetupDir()}\DbFolder");
            FolderRepository uploadRepository = new FolderRepository(
                $@"{Utils.GetSetupDir()}\UploadFolder");

            uploadRepository.Create("", folderToAdd, true);
            List <Storage> output  = Utils.Compare(dbRepository, uploadRepository, "");
            Storage        storage = output[0];

            dbRepository.ApplyChanges(
                "",
                output);
            List <Storage> dbStorageList = dbRepository.PopulateStorageList(
                "");
            bool isFound = false;

            foreach (Storage myStorage in dbStorageList)
            {
                if (myStorage.Name == folderToAdd)
                {
                    isFound = true;
                    break;
                }
            }
            if (!isFound)
            {
                Assert.Fail($"{folderToAdd} was supposed to be present but not found");
            }
        }
Example #5
0
        public void DeleteFolder()
        {
            FolderRepository folderRepository = new FolderRepository($@"{Utils.GetSetupDir()}\UploadFolder");
            //folderRepository.Create("Folder1", "Bhanu", true);
            List <Storage> storageList =
                folderRepository.PopulateStorageList("Folder1");

            folderRepository.Delete("Folder1", true);

            bool isPresent = true;

            foreach (Storage storage in storageList)
            {
                if ((storage.IsFolder) && (storage.Name == "Folder1"))
                {
                    isPresent = false;
                    break;
                }
            }
            Assert.IsTrue(isPresent, "Folder1 is not in the list");

            //Storage input = new Storage
            //{
            //    Name = "Nagesh",
            //    IsFolder = true
            //};

            //Assert.IsTrue(folderRepository.Exist("Folder1", input), "Folder not in the list");
            //Assert.Inconclusive("Not Implemented Yet!");
        }
Example #6
0
        public void PopulateStorage()
        {
            FolderRepository folderRepository = new FolderRepository($@"{Utils.GetSetupDir()}\UploadFolder");
            List <Storage>   storageList      =
                folderRepository.PopulateStorageList("Folder1");

            Assert.AreEqual(2, storageList.Count, "There should only be two elements in the list");
        }
Example #7
0
        public void DeleteFile()
        {
            FolderRepository folderRepository = new FolderRepository($@"{Utils.GetSetupDir()}\UploadFolder");
            List <Storage>   storageList      =
                folderRepository.PopulateStorageList("File1.txt");

            folderRepository.Delete("File1.txt", false);

            bool isPresent = true;

            foreach (Storage storage in storageList)
            {
                if ((storage.IsFolder) && (storage.Name == "File1.txt"))
                {
                    isPresent = false;
                    break;
                }
            }
            Assert.IsTrue(isPresent, "File1.txt is not in the list");
        }