public void HandleAggregatableResponsesForSingleLanguage() { var request = new TestRequestPacket() { Seq = 99, Command = OmniSharpEndpoints.FindSymbols, Arguments = JsonConvert.SerializeObject(new FindSymbolsRequest { Language = LanguageNames.CSharp }) }; var writer = new TestTextWriter( value => { var packet = JsonConvert.DeserializeObject <EventPacket>(value); Assert.Equal("started", packet.Event); }, value => { var packet = JsonConvert.DeserializeObject <ResponsePacket>(value); Assert.Equal(request.Seq, packet.Request_seq); Assert.Equal(request.Command, packet.Command); Assert.True(packet.Success); Assert.True(packet.Running); Assert.Null(packet.Message); var quickFixResponse = ((JObject)packet.Body).ToObject <QuickFixResponse>(); Assert.Equal(3, quickFixResponse.QuickFixes.Count()); Assert.Equal("AAAFakeFindSymbolsService", quickFixResponse.QuickFixes.ElementAt(0).Text); Assert.Equal("BBBFakeFindSymbolsService", quickFixResponse.QuickFixes.ElementAt(1).Text); Assert.Equal("CCCFakeFindSymbolsService", quickFixResponse.QuickFixes.ElementAt(2).Text); } ); var exports = new ExportDescriptorProvider[] { MefValueProvider.From <IRequestHandler>( new BBBFakeFindSymbolsService(), new Dictionary <string, object> { ["EndpointName"] = OmniSharpEndpoints.FindSymbols, ["Language"] = LanguageNames.CSharp }), MefValueProvider.From <IRequestHandler>( new CCCFakeFindSymbolsService(), new Dictionary <string, object> { ["EndpointName"] = OmniSharpEndpoints.FindSymbols, ["Language"] = LanguageNames.CSharp }), MefValueProvider.From <IRequestHandler>( new AAAFakeFindSymbolsService(), new Dictionary <string, object> { ["EndpointName"] = OmniSharpEndpoints.FindSymbols, ["Language"] = LanguageNames.CSharp }), }; using (StdioServerFacts.BuildTestServerAndStart(new StringReader(JsonConvert.SerializeObject(request) + "\r\n"), writer, additionalExports: exports)) { Assert.True(writer.Completion.WaitOne(TimeSpan.FromSeconds(60)), "Timeout"); Assert.Null(writer.Exception); } }
public void HandleNonAggregatableResponses() { var request = new TestRequestPacket() { Seq = 99, Command = OmniSharpEndpoints.GotoDefinition, Arguments = JsonConvert.SerializeObject(new GotoDefinitionRequest { FileName = "foo.cs" }) }; var writer = new TestTextWriter( value => { var packet = JsonConvert.DeserializeObject <EventPacket>(value); Assert.Equal("started", packet.Event); }, value => { var packet = JsonConvert.DeserializeObject <ResponsePacket>(value); Assert.Equal(request.Seq, packet.Request_seq); Assert.Equal(request.Command, packet.Command); Assert.True(packet.Success); Assert.True(packet.Running); Assert.Null(packet.Message); var gotoDefinitionResponse = ((JObject)packet.Body).ToObject <GotoDefinitionResponse>(); Assert.Equal("ZZZFake.cs", gotoDefinitionResponse.FileName); } ); var exports = new ExportDescriptorProvider[] { MefValueProvider.From <IProjectSystem>(new FakeProjectSystem()), MefValueProvider.From <IRequestHandler>( new FakeGotoDefinitionService("ZZZFake", false), new Dictionary <string, object> { ["EndpointName"] = OmniSharpEndpoints.GotoDefinition, ["Language"] = LanguageNames.CSharp }), MefValueProvider.From <IRequestHandler>( new FakeGotoDefinitionService("AAAFake", true), new Dictionary <string, object> { ["EndpointName"] = OmniSharpEndpoints.GotoDefinition, ["Language"] = LanguageNames.CSharp }), }; using (StdioServerFacts.BuildTestServerAndStart(new StringReader(JsonConvert.SerializeObject(request) + "\r\n"), writer, additionalExports: exports)) { Assert.True(writer.Completion.WaitOne(TimeSpan.FromSeconds(60)), "Timeout"); Assert.Null(writer.Exception); } }