public void OnlineDiscoveryByService()
 {
     RunWith10SecTimeout(async() =>
     {
         var server1          = ConnectEchoServer();
         var server2          = ConnectEchoServer();
         var client           = ConnectEchoClient();
         var discoveryResults =
             await client.DiscoveryInvoker.DiscoverOnlineAsync(
                 ServiceDiscoveryQuery.Create(EchoUnaryMethod.Reference.Service));
         discoveryResults.Count.ShouldBe(2);
         foreach (var discoveryResult in discoveryResults)
         {
             discoveryResult.Title.ShouldBe("Sample Echo Service");
             discoveryResult.ProvidedService.ApplicationId.ShouldBe("plexus.interop.testing.EchoServer");
             discoveryResult.ProviderConnectionId.ShouldBeOneOf(server1.ConnectionId, server2.ConnectionId);
             discoveryResult.Methods.Count.ShouldBe(4);
             var serverStreamingMethod = discoveryResult.Methods.FirstOrDefault(x =>
                                                                                string.Equals(x.ProvidedMethod.Name, "ServerStreaming"));
             serverStreamingMethod.ShouldNotBeNull();
             serverStreamingMethod.ProviderConnectionId.ShouldBeOneOf(server1.ConnectionId,
                                                                      server2.ConnectionId);
             serverStreamingMethod.Title.ShouldBe("Sample Server Streaming Method");
             var unaryMethod =
                 discoveryResult.Methods.FirstOrDefault(x => string.Equals(x.ProvidedMethod.Name, "Unary"));
             unaryMethod.ShouldNotBeNull();
             unaryMethod.Options.ShouldContain(o => o.Id.Equals("interop.ProvidedMethodOptions.title") && o.Value.Equals("Sample Unary Method"));
             unaryMethod.Options.ShouldContain(o => o.Id.Equals("plexus.interop.testing.string_option") && o.Value.Equals("some string"));
             unaryMethod.Options.ShouldContain(o => o.Id.Equals("plexus.interop.testing.enum_option") && o.Value.Equals("VALUE_TWO"));
         }
     });
 }
Exemplo n.º 2
0
 public void OnlineDiscoveryByService()
 {
     RunWith10SecTimeout(async() =>
     {
         using (await StartTestBrokerAsync())
         {
             var server1          = ConnectEchoServer();
             var server2          = ConnectEchoServer();
             var client           = ConnectEchoClient();
             var discoveryResults = await client.DiscoverOnlineAsync(ServiceDiscoveryQuery.Create(EchoUnaryMethod.Reference.Service));
             discoveryResults.Count.ShouldBe(2);
             foreach (var discoveryResult in discoveryResults)
             {
                 discoveryResult.Title.ShouldBe("Sample Echo Service");
                 discoveryResult.ProvidedService.ApplicationId.ShouldBe("plexus.interop.testing.EchoServer");
                 discoveryResult.ProviderConnectionId.ShouldBeOneOf(server1.ConnectionId, server2.ConnectionId);
                 discoveryResult.Methods.Count.ShouldBe(4);
                 var serverStreamingMethod = discoveryResult.Methods.FirstOrDefault(x =>
                                                                                    string.Equals(x.ProvidedMethod.Name, "ServerStreaming"));
                 serverStreamingMethod.ShouldNotBeNull();
                 serverStreamingMethod.ProviderConnectionId.ShouldBeOneOf(server1.ConnectionId, server2.ConnectionId);
                 serverStreamingMethod.Title.ShouldBe("Sample Server Streaming Method");
             }
         }
     });
 }
 public void DiscoveryByService()
 {
     RunWith10SecTimeout(async() =>
     {
         ConnectEchoServer();
         ConnectEchoServer();
         var client           = ConnectEchoClient();
         var discoveryResults =
             await client.DiscoveryInvoker.DiscoverAsync(
                 ServiceDiscoveryQuery.Create(EchoUnaryMethod.Reference.Service));
         discoveryResults.Count.ShouldBe(1);
         foreach (var discoveryResult in discoveryResults)
         {
             discoveryResult.Title.ShouldBe("Sample Echo Service");
             discoveryResult.ProvidedService.ApplicationId.ShouldBe("plexus.interop.testing.EchoServer");
             discoveryResult.ProvidedService.ConnectionId.HasValue.ShouldBeFalse();
             discoveryResult.Methods.Count.ShouldBe(4);
             var serverStreamingMethod = discoveryResult.Methods.FirstOrDefault(x =>
                                                                                string.Equals(x.ProvidedMethod.Name, "DuplexStreaming"));
             serverStreamingMethod.ShouldNotBeNull();
             serverStreamingMethod.Title.ShouldBe("Sample Duplex Streaming Method");
             serverStreamingMethod.ProvidedMethod.ProvidedService.ConnectionId.HasValue.ShouldBeFalse();
         }
     });
 }