Пример #1
0
        public void Deletes_folders_exclude_specified_folder()
        {
            //given
            var folderToSkip  = "database";
            var aFileInFolder = "read.me";

            var folderPath = Path.Combine(_basePath, folderToSkip);

            Directory.CreateDirectory(folderPath);

            var filePath = Path.Combine(folderPath, aFileInFolder);

            File.WriteAllText(filePath, "Please, please! Do not delete me!");

            var keepOnUpdate = new FileList(new[] { folderToSkip });

            var operation = new ClearBinaries(_basePath, keepOnUpdate);

            //when
            operation.Execute(_context);

            //then
            Assert.That(Directory.Exists(folderPath), Is.True, "Directory was removed");
            Assert.That(File.Exists(filePath), Is.True, "File in directory was removed");
        }
Пример #2
0
        public void Should_not_fail_if_directory_not_found()
        {
            //given
            var fakePath  = Folder.Combine(_nugetFeedFolder, "this_folder_does_not_exists");
            var operation = new ClearBinaries(fakePath, FileList.Empty);

            //when
            //then
            Assert.DoesNotThrow(() => operation.Execute(_context));
        }
Пример #3
0
        public void Should_not_fail_if_directory_not_found()
        {
            //given
            var fakePath = Folder.Combine(_nugetFeedFolder, "this_folder_does_not_exists");

            _context.Folders = new ServiceFolders {
                DeployFolder = (FullPath)fakePath
            };
            var operation = new ClearBinaries();

            //when
            //then
            Assert.DoesNotThrow(() => operation.Execute(_context));
        }
Пример #4
0
        public void Deletes_files_exclude_specified_file()
        {
            //given
            const string fileToSkip = "Codestellation.Galaxy.Host.exe.config";

            _context.KeepOnUpdate = new FileList(new[] { fileToSkip });
            var operation = new ClearBinaries();

            //when
            operation.Execute(_context);

            //then
            var file = Directory
                       .GetFiles(_basePath, "*.*", SearchOption.AllDirectories)
                       .Select(Path.GetFileName)
                       .SingleOrDefault();

            Assert.That(file, Is.StringEnding(fileToSkip));
        }