public async Task CheckAllFiles(string filename1, string filename2) { var testFile1 = new TestFile(filename1, "class C1 { int n = true; }"); var testFile2 = new TestFile(filename2, "class C2 { int n = true; }"); SharedOmniSharpTestHost.AddFilesToWorkspace(testFile1, testFile2); var messages = new List <DiagnosticMessage>(); var emitter = new DiagnosticTestEmitter(messages); var forwarder = new DiagnosticEventForwarder(emitter); var service = new CSharpDiagnosticService(SharedOmniSharpTestHost.Workspace, forwarder, this.LoggerFactory); var controller = new DiagnosticsService(SharedOmniSharpTestHost.Workspace, forwarder, service); var response = await controller.Handle(new DiagnosticsRequest()); await emitter.Emitted; Assert.Single(messages); var message = messages.First(); Assert.Equal(2, message.Results.Count()); var a = message.Results.First(x => x.FileName == filename1); Assert.Single(a.QuickFixes); Assert.Equal(filename1, a.FileName); var b = message.Results.First(x => x.FileName == filename2); Assert.Single(b.QuickFixes); Assert.Equal(filename2, b.FileName); }
public async Task CheckAllFiles() { var workspace = await TestHelpers.CreateSimpleWorkspace(new Dictionary <string, string> { { "a.cs", "class C1 { int n = true; }" }, { "b.cs", "class C2 { int n = true; }" }, }); var fakeLoggerFactory = new FakeLoggerFactory(); var messages = new List <OmniSharp.Models.DiagnosticMessage>(); var emitter = new DiagnosticTestEmitter(messages); var forwarder = new DiagnosticEventForwarder(emitter); var service = new CSharpDiagnosticService(workspace, forwarder, fakeLoggerFactory); var controller = new DiagnosticsService(workspace, forwarder, service); var response = await controller.Handle(new OmniSharp.Models.DiagnosticsRequest()); await emitter.Emitted; Assert.Equal(1, messages.Count); var message = messages.First(); Assert.Equal(2, message.Results.Count()); var a = message.Results.First(x => x.FileName == "a.cs"); Assert.Equal(1, a.QuickFixes.Count()); Assert.Equal("a.cs", a.FileName); var b = message.Results.First(x => x.FileName == "b.cs"); Assert.Equal(1, b.QuickFixes.Count()); Assert.Equal("b.cs", b.FileName); }
public async Task CodeCheckSpecifiedFileOnly(string filename) { var testFile = new TestFile(filename, "class C { int n = true; }"); SharedOmniSharpTestHost.AddFilesToWorkspace(testFile); var messages = new List <DiagnosticMessage>(); var emitter = new DiagnosticTestEmitter(messages); var forwarder = new DiagnosticEventForwarder(emitter) { IsEnabled = true }; var service = new CSharpDiagnosticService(SharedOmniSharpTestHost.Workspace, forwarder, this.LoggerFactory); service.QueueDiagnostics(filename); await emitter.Emitted; Assert.Single(messages); var message = messages.First(); Assert.Single(message.Results); var result = message.Results.First(); Assert.Single(result.QuickFixes); Assert.Equal(filename, result.FileName); }
public async Task CodeCheckSpecifiedFileOnly() { var workspace = await TestHelpers.CreateSimpleWorkspace(new Dictionary <string, string> { { "a.cs", "class C { int n = true; }" } }); var fakeLoggerFactory = new FakeLoggerFactory(); var messages = new List <OmniSharp.Models.DiagnosticMessage>(); var emitter = new DiagnosticTestEmitter(messages); var forwarder = new DiagnosticEventForwarder(emitter); forwarder.IsEnabled = true; var service = new CSharpDiagnosticService(workspace, forwarder, fakeLoggerFactory); service.QueueDiagnostics("a.cs"); await emitter.Emitted; Assert.Equal(1, messages.Count); var message = messages.First(); Assert.Equal(1, message.Results.Count()); var result = message.Results.First(); Assert.Equal(1, result.QuickFixes.Count()); Assert.Equal("a.cs", result.FileName); }
public async Task EnablesWhenEndPointIsHit(string filename1, string filename2) { var testFile1 = new TestFile(filename1, "class C1 { int n = true; }"); var testFile2 = new TestFile(filename2, "class C2 { int n = true; }"); SharedOmniSharpTestHost.AddFilesToWorkspace(testFile1, testFile2); var messages = new List <DiagnosticMessage>(); var emitter = new DiagnosticTestEmitter(messages); var forwarder = new DiagnosticEventForwarder(emitter); var service = new CSharpDiagnosticService(SharedOmniSharpTestHost.Workspace, forwarder, this.LoggerFactory); var controller = new DiagnosticsService(SharedOmniSharpTestHost.Workspace, forwarder, service); var response = await controller.Handle(new DiagnosticsRequest()); Assert.True(forwarder.IsEnabled); }
public async Task EnablesWhenEndPointIsHit(string filename1, string filename2) { SharedOmniSharpTestHost.ClearWorkspace(); var testFile1 = new TestFile(filename1, "class C1 { int n = true; }"); var testFile2 = new TestFile(filename2, "class C2 { int n = true; }"); SharedOmniSharpTestHost.AddFilesToWorkspace(testFile1, testFile2); var emitter = new DiagnosticTestEmitter(); var forwarder = new DiagnosticEventForwarder(emitter); var service = CreateDiagnosticService(forwarder); var controller = new DiagnosticsService(forwarder, service); var response = await controller.Handle(new DiagnosticsRequest()); Assert.True(forwarder.IsEnabled); }
public async Task EnablesWhenEndPointIsHit() { var workspace = await TestHelpers.CreateSimpleWorkspace(new Dictionary <string, string> { { "a.cs", "class C1 { int n = true; }" }, { "b.cs", "class C2 { int n = true; }" }, }); var fakeLoggerFactory = new FakeLoggerFactory(); var messages = new List <OmniSharp.Models.DiagnosticMessage>(); var emitter = new DiagnosticTestEmitter(messages); var forwarder = new DiagnosticEventForwarder(emitter); var service = new CSharpDiagnosticService(workspace, forwarder, fakeLoggerFactory); var controller = new DiagnosticsService(workspace, forwarder, service); var response = await controller.Handle(new OmniSharp.Models.DiagnosticsRequest()); Assert.Equal(true, forwarder.IsEnabled); }
public async Task CheckAllFiles(string filename1, string filename2) { SharedOmniSharpTestHost.ClearWorkspace(); var testFile1 = new TestFile(filename1, "class C1 { int n = true; }"); var testFile2 = new TestFile(filename2, "class C2 { int n = true; }"); SharedOmniSharpTestHost.AddFilesToWorkspace(testFile1, testFile2); var emitter = new DiagnosticTestEmitter(); var forwarder = new DiagnosticEventForwarder(emitter); var service = CreateDiagnosticService(forwarder); var controller = new DiagnosticsService(forwarder, service); var response = await controller.Handle(new DiagnosticsRequest()); await emitter.ExpectForEmitted(msg => msg.Results .Any(r => r.FileName == filename1 && r.QuickFixes.Count() == 1)); await emitter.ExpectForEmitted(msg => msg.Results .Any(r => r.FileName == filename2 && r.QuickFixes.Count() == 1)); }
public async Task CodeCheckSpecifiedFileOnly(string filename) { SharedOmniSharpTestHost.ClearWorkspace(); var testFile = new TestFile(filename, "class C { int n = true; }"); var emitter = new DiagnosticTestEmitter(); var forwarder = new DiagnosticEventForwarder(emitter) { IsEnabled = true }; var service = CreateDiagnosticService(forwarder); SharedOmniSharpTestHost.AddFilesToWorkspace(testFile); var controller = new DiagnosticsService(forwarder, service); var response = await controller.Handle(new DiagnosticsRequest { FileName = testFile.FileName }); await emitter.ExpectForEmitted(msg => msg.Results.Any(m => m.FileName == filename)); }