예제 #1
0
        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);
        }
예제 #2
0
        public void WorkManagerInvokedWithHasDateShouldDeleteOnlySpecificEntities()
        {
            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)
            });
            dummyLoggerScrapHeap.LoggingStream.Subscribe(x => deleted++);

            Assert.AreEqual(2, deleted);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #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);
        }