Example #1
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));
        }
        public void WatchingFileWasDeletedAndNonWatchingWasCreatedAndRenamedToWatching()
        {
            var events = CollectEvents(() =>
            {
                File.Delete(filePath);
                var anotherFilePath = Path.Combine(watcherTempDirectory, $"{Guid.NewGuid():N}");
                File.WriteAllText(anotherFilePath, "Hello");
                Thread.Sleep(QuietTimeMs * 2);
                File.Move(anotherFilePath, filePath);
                Thread.Sleep(QuietTimeMs * 2);
            }, 3);

            events.Should().BeEquivalentTo(
                FileChangedEvent.CreatedOrUpdated(filePath),
                FileChangedEvent.Deleted(filePath),
                FileChangedEvent.CreatedOrUpdated(filePath)
                );
        }
Example #3
0
        public void FileWasCreateAndRenamed()
        {
            var sourceFile      = Path.Combine(watcherTempDirectory, $"{Guid.NewGuid():N}.txt");
            var destinationFile = Path.Combine(watcherTempDirectory, $"{Guid.NewGuid():N}.txt");

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

            events.Should().BeEquivalentTo(
                FileChangedEvent.CreatedOrUpdated(sourceFile),
                FileChangedEvent.Deleted(sourceFile),
                FileChangedEvent.CreatedOrUpdated(destinationFile)
                );
        }
        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));
        }