Exemplo n.º 1
0
        public void TestRename(string directory, string newFileName, string additionalFolders)
        {
            var  scheduler  = new SimpleTestScheduler();
            var  source     = new TempFileSource();
            long sourceSize = source.FileInfo.Length;

            string destinatioPath = newFileName;
            string rootFolderPath = source.Path;

            if (directory != null)
            {
                destinatioPath = Path.Combine(additionalFolders == null ? directory : Path.Combine(directory, additionalFolders),
                                              destinatioPath);
                rootFolderPath = Path.Combine(rootFolderPath, directory);
            }

            string fullDestinationPath = Path.Combine(source.Path, destinatioPath);

            Assert.IsFalse(File.Exists(destinatioPath));

            scheduler.Builder.Append(new SourceRenamer(f => destinatioPath));

            scheduler.Execute(source);

            Assert.IsTrue(File.Exists(fullDestinationPath));
            Assert.AreEqual(sourceSize, new FileInfo(fullDestinationPath).Length);

            File.Delete(fullDestinationPath);
            if (directory != null)
            {
                Directory.Delete(rootFolderPath, true);
            }
        }
Exemplo n.º 2
0
        private static void TestFileMovement(string destinationFile, SimpleTestScheduler scheduler, IFileSource source,
                                             long sourceSize, string destinatioPath)
        {
            Assert.AreEqual(false, File.Exists(destinationFile));

            scheduler.Execute(source);

            Assert.IsTrue(File.Exists(destinationFile));
            Assert.AreEqual(sourceSize, new FileInfo(destinationFile).Length);

            Directory.Delete(destinatioPath, true);
        }
Exemplo n.º 3
0
        public void TestDeleteSource()
        {
            var scheduler = new SimpleTestScheduler();
            var source    = new TempFileSource();

            scheduler.Builder.Append(new SourceDeleter());

            Assert.AreEqual(true, File.Exists(source.FileInfo.FullName));

            scheduler.Execute(source);

            Assert.AreEqual(false, File.Exists(source.FileInfo.FullName));
        }
Exemplo n.º 4
0
        private static void TestBasicClone(IFileSource source, string newFilePath, SimpleTestScheduler scheduler,
                                           string newFolderPath)
        {
            Assert.AreEqual(true, File.Exists(source.FileInfo.FullName));
            Assert.AreEqual(false, File.Exists(newFilePath));

            scheduler.Execute(source);

            Assert.AreEqual(true, File.Exists(source.FileInfo.FullName));
            Assert.AreEqual(true, File.Exists(newFilePath));

            Directory.Delete(newFolderPath, true);
        }
Exemplo n.º 5
0
        public void TestExecute()
        {
            var scheduler = new SimpleTestScheduler();

            const int executorsCount = 5;
            var       processors     = new DebugProcessor[executorsCount];

            for (int i = 0; i < processors.Length; i++)
            {
                processors[i] = new DebugProcessor(new MockDataProcessor());
            }

            CheckExecutionCount(0, processors);

            scheduler.Builder.Append(new MultiProcessor(processors));

            scheduler.Execute(new MockFileSource());

            CheckExecutionCount(1, processors);

            scheduler.Execute(new MockFileSource());

            CheckExecutionCount(2, processors);
        }
        private static void TestEval(Func <IFileSource, bool> evalFunc, bool useSourceB = false)
        {
            var scheduler = new SimpleTestScheduler();
            int execCount = 0;

            scheduler.Scheduler.LifeCycleEvent += Executed;

            scheduler.Builder.Append(useSourceB
                                ? new ConditionalProcessor(evalFunc, null, new MockDataProcessor())
                                : new ConditionalProcessor(evalFunc, new MockDataProcessor(), null));

            scheduler.Execute(new MockFileSource());

            Assert.AreEqual(1, execCount);

            void Executed(object sender, SchedulerLifeCycleEventArgs schedulerLifeCycleEventArgs)
            {
                execCount++;
            }
        }
Exemplo n.º 7
0
 private static void AppendDeleteAndExecute(SimpleTestScheduler scheduler, IFileSource source)
 {
     scheduler.Builder.Append(new SourceDeleter());
     scheduler.Execute(source);
 }