public async void PathWatchingEnded_EmptyWatchedFolderRemoved_Raised()
        {
            var engine = SearchEngineFactory.New();
            var tcs    = new TaskCompletionSource <bool>();

            using (var folder = new TestFolder())
            {
                var folderPath = folder.Path;
                using (var file = new TestFile("foo", folderPath))
                {
                    engine.Add(folder.Path);
                    await Task.Delay(100);

                    engine.PathWatchingEnded += args =>
                    {
                        tcs.TrySetResult(Path.GetFullPath(folderPath) == args.Path);
                    };

                    file.Delete();
                    folder.Delete();

                    Assert.True(await tcs.Task);
                }
            }
        }
Exemple #2
0
        public async void FileRemovingEvents_FileInFolderRemoved_Raised(string eventName)
        {
            var engine = SearchEngineFactory.New();
            var tcs    = new TaskCompletionSource <bool>();

            using (var folder = new TestFolder())
            {
                var folderPath = folder.Path;
                using (var subFolder = new TestFolder(folderPath))
                {
                    var subFolderPath = subFolder.Path;
                    using (var file = new TestFile("foo", subFolderPath))
                    {
                        var filePath = file.Path;

                        engine.Add(folderPath);
                        await Task.Delay(100);

                        engine.AddHandler(eventName, args =>
                        {
                            tcs.TrySetResult(Path.GetFullPath(filePath) == args.Path);
                        });

                        file.Delete();

                        Assert.True(await tcs.Task);
                    }
                }
            }
        }
Exemple #3
0
        public void DeleteFromNotExistingFile()
        {
            // Setup
            var fileSystem = new TestFileSystem();
            var file       = new TestFile(fileSystem, "\\this\\is\\a\\file.txt");

            // Execute
            file.Delete();
        }
Exemple #4
0
        public void DeleteNotExistingFile()
        {
            // Setup
            var fileSystem = new TestFileSystem();

            fileSystem.StageDirectory("\\this\\is\\a");
            var file = new TestFile(fileSystem, "\\this\\is\\a\\file.txt");

            // Execute
            file.Delete();

            // Assert
            Assert.IsFalse(file.Exists);
        }
Exemple #5
0
        public void DeleteFile()
        {
            // Setup
            var fileSystem = new TestFileSystem();
            var file       = new TestFile(fileSystem, "\\this\\is\\a\\file.txt");
            var stream     = new MemoryStream();

            file.Create(stream);

            // Execute
            file.Delete();

            // Assert
            Assert.IsFalse(file.Exists);
        }
Exemple #6
0
        public void DeleteNotExistingFile()
        {
            // Setup
            var fileSystem = new TestFileSystem();
            fileSystem.StageDirectory("\\this\\is\\a");
            var file = new TestFile(fileSystem, "\\this\\is\\a\\file.txt");

            // Execute
            file.Delete();

            // Assert
            Assert.IsFalse(file.Exists);
        }
Exemple #7
0
        public void DeleteFromNotExistingFile()
        {
            // Setup
            var fileSystem = new TestFileSystem();
            var file = new TestFile(fileSystem, "\\this\\is\\a\\file.txt");

            // Execute
            file.Delete();
        }
Exemple #8
0
        public void DeleteFile()
        {
            // Setup
            var fileSystem = new TestFileSystem();
            var file = new TestFile(fileSystem, "\\this\\is\\a\\file.txt");
            var stream = new MemoryStream();
            file.Create(stream);

            // Execute
            file.Delete();

            // Assert
            Assert.IsFalse(file.Exists);
        }