Exemplo n.º 1
0
        public void TwoDirectoriesAreWatched()
        {
            MockFileMove mover    = new MockFileMove();
            Settings     settings = GetTestSettings();

            string watchFolder = Path.Combine(GetWorkingDirectory(), TestContext.TestName + "_2");

            settings.WatchFolders.Add(watchFolder);
            Directory.CreateDirectory(watchFolder);

            VideoMover videoMover = new VideoMover(settings, mover, TestLogger);

            videoMover.Enable();

            string from = Path.Combine(GetWorkingDirectory(), "TestFiles", "Video.zip");
            string to   = Path.Combine(settings.WatchFolders.First(), "Video.zip");

            File.Copy(from, to);

            from = Path.Combine(GetWorkingDirectory(), "TestFiles", "Video.zip");
            to   = Path.Combine(settings.WatchFolders.Last(), "Video.zip");
            File.Move(from, to);


            Thread.Sleep(4000);

            Assert.AreEqual(2, mover.Calls, "Calls");
            Assert.AreEqual(2, mover.Destination.Count(), "Destinations");
        }
Exemplo n.º 2
0
        public void ArchiveWithoutVideoIsIgnored()
        {
            MockFileMove mover = new MockFileMove();

            VideoMover videoMover = new VideoMover(GetTestSettings(), mover, TestLogger);

            videoMover.Enable();

            string from = Path.Combine(GetWorkingDirectory(), "TestFiles", "Without.zip");
            string to   = Path.Combine(GetWorkingDirectory(), "Without.zip");

            File.Move(from, to);

            Thread.Sleep(4000);
            Assert.IsTrue(File.Exists(to));
            Assert.IsFalse(mover.WasCalled);
        }
Exemplo n.º 3
0
        protected override void OnStart(string[] args)
        {
            EventLog log = new EventLog("Application", Environment.MachineName, "VideoMover");

            try
            {
                var settings = GetConfigSettings();
                _videoMover = new VideoMover(settings, new FileMover(), new EventLogger(log), DebugFlag());
                _videoMover.Enable();

                EventLog.WriteEntry("VideoMover enabled successfully: " + settings.ToString());
            }
            catch (ConfigurationException ex)
            {
                EventLog.WriteEntry("Error initialising configuration." + ex);
            }
        }
Exemplo n.º 4
0
        public void ArchiveWithVideoIsExtracted()
        {
            MockFileMove mover    = new MockFileMove();
            Settings     settings = GetTestSettings();

            VideoMover videoMover = new VideoMover(settings, mover, TestLogger);

            videoMover.Enable();

            string from = Path.Combine(GetWorkingDirectory(), "TestFiles", "With.zip");
            string to   = Path.Combine(settings.WatchFolders.First(), "With.zip");

            File.Move(from, to);

            Thread.Sleep(4000);

            Assert.IsTrue(mover.WasCalled);
            Assert.AreEqual(settings.MovieFolder, mover.Destination.First());
        }
Exemplo n.º 5
0
        public void OnStartFileIsMoved()
        {
            var settings = GetTestSettings();

            Directory.CreateDirectory(Path.Combine(settings.SeriesFolder, "Friends"));
            Directory.CreateDirectory(Path.Combine(settings.WatchFolders.First()));

            MockFileMove mover = new MockFileMove();

            VideoMover videoMover = new VideoMover(settings, mover, TestLogger);

            AddTestFile("sesame.street.s01e02.avi", settings.WatchFolders.First());

            videoMover.Enable();

            Thread.Sleep(2000);

            Assert.IsTrue(mover.WasCalled);
            Assert.AreEqual(settings.DefaultSeriesFolder, mover.Destination.First());
        }