Esempio n. 1
0
        public void FileWasCreated()
        {
            var file = Path.Combine(watcherTempDirectory, $"{Guid.NewGuid():N}.txt");

            var events = CollectEvents(() => File.WriteAllText(file, "Hello"), 1);

            events.Should().BeEquivalentTo(FileChangedEvent.CreatedOrUpdated(file));
        }
Esempio n. 2
0
        public void FileWasUpdatedAndDeleted()
        {
            var events = CollectEvents(() =>
            {
                File.WriteAllText(filePath, "Hello");
                Thread.Sleep(QuietTimeMs * 2);
                File.Delete(filePath);
            }, 2);

            events.Should().BeEquivalentTo(FileChangedEvent.CreatedOrUpdated(filePath), FileChangedEvent.Deleted(filePath));
        }
Esempio n. 3
0
        public void FileWasCreatedAndMoved()
        {
            var events = CollectEvents(() =>
            {
                var anotherFilePath = Path.Combine(watcherTempDirectory, $"{Guid.NewGuid():N}");
                File.Move(filePath, anotherFilePath);
                Thread.Sleep(QuietTimeMs * 2);
                File.WriteAllText(anotherFilePath, "Hello");
                Thread.Sleep(QuietTimeMs * 2);
            }, 2);

            events.Should().BeEquivalentTo(FileChangedEvent.CreatedOrUpdated(filePath), FileChangedEvent.Deleted(filePath));
        }
Esempio n. 4
0
        public void FileWasCreatedAndDeleted()
        {
            var file = Path.Combine(watcherTempDirectory, $"{Guid.NewGuid():N}.txt");

            var events = CollectEvents(() =>
            {
                File.WriteAllText(file, "Hello");
                Thread.Sleep(QuietTimeMs * 2);
                File.Delete(file);
            }, 2);

            events.Should().BeEquivalentTo(FileChangedEvent.CreatedOrUpdated(file), FileChangedEvent.Deleted(file));
        }
Esempio n. 5
0
        public void FileWasCreatedAndRenamed_EscapeFromWatchDirectory()
        {
            var sourceFileName      = Path.Combine(watcherTempDirectory, $"{Guid.NewGuid():N}.txt");
            var destinationFileName = Path.Combine(tempDirectory, $"{Guid.NewGuid():N}.txt");

            var events = CollectEvents(() =>
            {
                File.WriteAllText(sourceFileName, "Hello");
                Thread.Sleep(QuietTimeMs * 2);
                File.Move(sourceFileName, destinationFileName);
            }, 2);

            events.Should().BeEquivalentTo(FileChangedEvent.CreatedOrUpdated(sourceFileName), FileChangedEvent.Deleted(sourceFileName));
        }
Esempio n. 6
0
        public void FileWasCreatedAndDirectoryWasRenamed_EntryToWatchDirectory()
        {
            var fileName = $"{Guid.NewGuid():N}.txt";

            var sourceDirectory = Path.Combine(tempDirectory, $"{Guid.NewGuid():N}");
            var sourceFile      = Path.Combine(sourceDirectory, fileName);

            Directory.CreateDirectory(sourceDirectory);
            var destinationDirectory = Path.Combine(watcherTempDirectory, $"{Guid.NewGuid():N}");
            var destinationFile      = Path.Combine(destinationDirectory, fileName);

            var events = CollectEvents(() =>
            {
                File.WriteAllText(sourceFile, "Hello");
                Thread.Sleep(QuietTimeMs * 2);
                Directory.Move(sourceDirectory, destinationDirectory);
            }, 1);

            events.Should().BeEquivalentTo(FileChangedEvent.CreatedOrUpdated(destinationFile));
        }