Exemplo n.º 1
0
        public void JobDirectoryHasChanged_FileAddedInWorkingDir_ReturnsFalse()
        {
            CreateTestJobDirectories();

            File.WriteAllText(Path.Combine(_testJobWorkingDir, "test4.txt"), "test");

            var sourceDirectoryFileMap  = BaseJobRunner.GetJobDirectoryFileMap(_testJobSourceDir);
            var workingDirectoryFileMap = BaseJobRunner.GetJobDirectoryFileMap(_testJobWorkingDir);
            var cachedDirectoryFileMap  = sourceDirectoryFileMap;

            Assert.False(BaseJobRunner.JobDirectoryHasChanged(sourceDirectoryFileMap, workingDirectoryFileMap, cachedDirectoryFileMap, _mockLogger.Object));

            _mockLogger.VerifyAll();
        }
Exemplo n.º 2
0
        public void JobDirectoryHasChanged_IsCaseInsensitive()
        {
            CreateTestJobDirectories();

            // create a case mismatch
            File.Move(Path.Combine(_testJobWorkingDir, "test1.txt"), Path.Combine(_testJobWorkingDir, "TEST1.TXT"));

            var sourceDirectoryFileMap  = BaseJobRunner.GetJobDirectoryFileMap(_testJobSourceDir);
            var workingDirectoryFileMap = BaseJobRunner.GetJobDirectoryFileMap(_testJobWorkingDir);
            var cachedDirectoryFileMap  = sourceDirectoryFileMap;

            Assert.False(BaseJobRunner.JobDirectoryHasChanged(sourceDirectoryFileMap, workingDirectoryFileMap, cachedDirectoryFileMap, _mockLogger.Object));

            _mockLogger.VerifyAll();
        }
Exemplo n.º 3
0
        public void JobDirectoryHasChanged_NoChanges_CachedEntries_ReturnsFalse()
        {
            using (CreateTestJobDirectories())
            {
                var sourceDirectoryFileMap = BaseJobRunner.GetJobDirectoryFileMap(_testJobSourceDir);
                Assert.Equal(8, sourceDirectoryFileMap.Count);
                var workingDirectoryFileMap = BaseJobRunner.GetJobDirectoryFileMap(_testJobWorkingDir);
                Assert.Equal(8, workingDirectoryFileMap.Count);
                var cachedDirectoryFileMap = workingDirectoryFileMap;

                Assert.False(BaseJobRunner.JobDirectoryHasChanged(sourceDirectoryFileMap, workingDirectoryFileMap, cachedDirectoryFileMap, _mockLogger.Object));

                _mockLogger.VerifyAll();
            }
        }
Exemplo n.º 4
0
        public void JobDirectoryHasChanged_FileAddedInRootDir_ReturnsTrue()
        {
            CreateTestJobDirectories();

            File.WriteAllText(Path.Combine(_testJobSourceDir, "test4.txt"), "test");

            var sourceDirectoryFileMap  = BaseJobRunner.GetJobDirectoryFileMap(_testJobSourceDir);
            var workingDirectoryFileMap = BaseJobRunner.GetJobDirectoryFileMap(_testJobWorkingDir);
            var cachedDirectoryFileMap  = workingDirectoryFileMap;

            _mockLogger.Setup(p => p.LogInformation("Job directory change detected: Job file 'test4.txt' exists in source directory but not in working directory."));

            Assert.True(BaseJobRunner.JobDirectoryHasChanged(sourceDirectoryFileMap, workingDirectoryFileMap, cachedDirectoryFileMap, _mockLogger.Object));

            _mockLogger.VerifyAll();
        }
Exemplo n.º 5
0
        public void JobDirectoryHasChanged_FileModifiedInRootDir_ReturnsTrue()
        {
            CreateTestJobDirectories();

            File.WriteAllText(Path.Combine(_testJobSourceDir, "test2.txt"), "update");

            var sourceDirectoryFileMap  = BaseJobRunner.GetJobDirectoryFileMap(_testJobSourceDir);
            var workingDirectoryFileMap = BaseJobRunner.GetJobDirectoryFileMap(_testJobWorkingDir);
            var cachedDirectoryFileMap  = workingDirectoryFileMap;

            _mockLogger.Setup(p => p.LogInformation("Job directory change detected: Job file 'test2.txt' timestamp differs between source and working directories."));

            Assert.True(BaseJobRunner.JobDirectoryHasChanged(sourceDirectoryFileMap, workingDirectoryFileMap, cachedDirectoryFileMap, _mockLogger.Object));

            _mockLogger.VerifyAll();
        }
Exemplo n.º 6
0
        public void JobDirectoryHasChanged_FileDeleted_ReturnsTrue()
        {
            CreateTestJobDirectories();

            File.Delete(Path.Combine(_testJobSourceDir, "test2.txt"));

            var sourceDirectoryFileMap  = BaseJobRunner.GetJobDirectoryFileMap(_testJobSourceDir);
            var workingDirectoryFileMap = BaseJobRunner.GetJobDirectoryFileMap(_testJobWorkingDir);
            var cachedDirectoryFileMap  = workingDirectoryFileMap;

            _mockLogger.Setup(p => p.LogInformation("Job directory change detected: Job file 'test2.txt' has been deleted."));

            Assert.True(BaseJobRunner.JobDirectoryHasChanged(sourceDirectoryFileMap, workingDirectoryFileMap, cachedDirectoryFileMap, _mockLogger.Object));

            _mockLogger.VerifyAll();
        }