Exemplo n.º 1
0
        public async void FilePathChanged_FileInWatchedFolderRenamed_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(folderPath);
                    await Task.Delay(100);

                    var newName = $"new-test-{Guid.NewGuid()}.txt";

                    engine.FilePathChanged += args =>
                    {
                        var expectedPath = Path.GetFullPath($".\\{folderPath}\\{newName}");
                        tcs.TrySetResult(expectedPath == args.Path);
                    };

                    file.Rename(newName);

                    Assert.True(await tcs.Task);
                }
            }
        }
Exemplo n.º 2
0
        public async void FilePathChanged_FileRenamed_Raised()
        {
            var engine = SearchEngineFactory.New();
            var tcs    = new TaskCompletionSource <bool>();

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

                var newName = $"new-test-{Guid.NewGuid()}.txt";

                engine.FilePathChanged += args =>
                {
                    tcs.TrySetResult(Path.GetFullPath(".\\" + newName) == args.Path);
                };

                file.Rename(newName);

                Assert.True(await tcs.Task);
            }
        }