<NME> FilesChangedFacts.cs
<BEF> ADDFILE
<MSG> Merge pull request #987 from rchande/fileWatching

Listen for file renames
<DFF> @@ -0,0 +1,59 @@
+﻿using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+using OmniSharp.FileWatching;
+using OmniSharp.Models.FilesChanged;
+using OmniSharp.Roslyn.CSharp.Services.Files;
+using TestUtility;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace OmniSharp.Roslyn.CSharp.Tests
+{
+    public class OnFilesChangedFacts : AbstractSingleRequestHandlerTestFixture<OnFilesChangedService>
+    {
+        public OnFilesChangedFacts(ITestOutputHelper testOutput) : base(testOutput)
+        {
+        }
+
+        protected override string EndpointName => OmniSharpEndpoints.FilesChanged;
+
+        [Fact]
+        public async Task TestFileAddedToMSBuildWorkspaceOnCreation()
+        {
+            using (var testProject = await TestAssets.Instance.GetTestProjectAsync("ProjectAndSolution"))
+            using (var host = CreateOmniSharpHost(testProject.Directory))
+            {
+                var watcher = host.GetExport<IFileSystemWatcher>();
+
+                var path = Path.GetDirectoryName(host.Workspace.CurrentSolution.Projects.First().FilePath);
+                var filePath = Path.Combine(path, "FileName.cs");
+                File.WriteAllText(filePath, "text");
+                var handler = GetRequestHandler(host);
+                await handler.Handle(new[] { new FilesChangedRequest() { FileName = filePath, ChangeType = FileChangeType.Create } });
+
+                Assert.Contains(host.Workspace.CurrentSolution.Projects.First().Documents, d => d.Name == filePath);
+            }
+        }
+
+        [Fact]
+        public void TestMultipleDirectoryWatchers()
+        {
+            using (var host = CreateEmptyOmniSharpHost())
+            {
+                var watcher = host.GetExport<IFileSystemWatcher>();
+
+                bool firstWatcherCalled = false;
+                bool secondWatcherCalled = false;
+                watcher.WatchDirectory("", (path, changeType) => { firstWatcherCalled = true; });
+                watcher.WatchDirectory("", (path, changeType) => { secondWatcherCalled = true; });
+
+                var handler = GetRequestHandler(host);
+                handler.Handle(new[] { new FilesChangedRequest() { FileName = "FileName.cs", ChangeType = FileChangeType.Create } });
+
+                Assert.True(firstWatcherCalled);
+                Assert.True(secondWatcherCalled);
+            }
+        }
+    }
+}

{'addition_count': 59, 'commit_subject': 'Merge pull request #987 from rchande/fileWatching', 'deletion_count': 0, 'file_extension': '.cs', 'lang': 'Roslyn', 'license': 'mit', 'repo_name': 'OmniSharp/omnisharp-roslyn'}