public void WorkManagerInvokedWithDeleteNothingShouldDeleteNoFiles()
        {
            int deleted = 0;
            var dummyLoggerScrapHeap = new DummyLoggerScrapHeap();

            WorkManager workManager = new WorkManager(new MockFileSystemIterator(), dummyLoggerScrapHeap);
            workManager.Delete("source", new List<AbstractCommand>() { new DeleteNothing() });
            dummyLoggerScrapHeap.LoggingStream.Subscribe(x => deleted++);

            Assert.AreEqual(0, deleted);
        }
        public void WorkManagerInvokedWithHasDateAndDirectoriesOnlyShouldDeleteOnlySpecificEntities()
        {
            int deleted = 0;
            var dummyLoggerScrapHeap = new DummyLoggerScrapHeap();

            WorkManager workManager = new WorkManager(new MockFileSystemIterator(), dummyLoggerScrapHeap);
            workManager.Delete("source", new List<AbstractCommand>()
            {
                new HasDate(x => x.Year == 2011 && x.Month == 3 && x.Day == 13),
                new DirectoriesOnly()
            });
            dummyLoggerScrapHeap.LoggingStream.Subscribe(x => deleted++);

            Assert.AreEqual(1, deleted);
        }
        public void WorkManagerInvokedWithFileExtensionTxtShouldDeleteOnlySpecificEntities()
        {
            int deleted = 0;
            var dummyLoggerScrapHeap = new DummyLoggerScrapHeap();

            WorkManager workManager = new WorkManager(new MockFileSystemIterator(), dummyLoggerScrapHeap);
            workManager.Delete("source", new List<AbstractCommand>()
            {
                new FileExtension("txt")
            });
            dummyLoggerScrapHeap.LoggingStream.Subscribe(x => deleted++);

            Assert.AreEqual(1, deleted);
        }
        public void WorkManagerInvokedWithNoFilterShouldDeleteAllFiles()
        {
            int deleted = 0;
            var dummyLoggerScrapHeap = new DummyLoggerScrapHeap();

            WorkManager workManager = new WorkManager(new MockFileSystemIterator(), dummyLoggerScrapHeap);
            workManager.Delete("source");
            dummyLoggerScrapHeap.LoggingStream.Subscribe(x => deleted++);

            Assert.AreEqual(3, deleted);
        }
Exemple #5
0
 /// <summary>
 /// This overload is useful if you take care of the command instantiation yourself
 /// (e.g. when you use the Blockbuster API inside your own application)
 /// </summary>
 /// <param name="directory">Directory to delete</param>
 /// <param name="commands">The list of commands to be used for the cleanup</param>
 public void CleanUp(string directory, IEnumerable<AbstractCommand> commands)
 {
     var workManager = new WorkManager();
     workManager.Delete(directory, commands);
 }