コード例 #1
0
        public async Task InvokeMethodGrpcAsync_AppCallback_RepeatedField()
        {
            // Configure Client
            var httpClient = new AppCallbackClient(new DaprAppCallbackService());
            var daprClient = new DaprClientBuilder()
                             .UseGrpcChannelOptions(new GrpcChannelOptions()
            {
                HttpClient = httpClient,
            })
                             .UseJsonSerializationOptions(this.jsonSerializerOptions)
                             .Build();

            var testRun = new TestRun();

            testRun.Tests.Add(new TestCase()
            {
                Name = "test1"
            });
            testRun.Tests.Add(new TestCase()
            {
                Name = "test2"
            });
            testRun.Tests.Add(new TestCase()
            {
                Name = "test3"
            });

            var response = await daprClient.InvokeMethodGrpcAsync <TestRun, TestRun>("test", "TestRun", testRun);

            response.Tests.Count.Should().Be(3);
            response.Tests[0].Name.Should().Be("test1");
            response.Tests[1].Name.Should().Be("test2");
            response.Tests[2].Name.Should().Be("test3");
        }
コード例 #2
0
        public async Task InvokeMethodGrpcAsync_AppCallback_RepeatedField()
        {
            // Configure Client
            var httpClient = new AppCallbackClient(new DaprAppCallbackService());
            var daprClient = CreateTestClientGrpc(httpClient);

            var testRun = new TestRun();

            testRun.Tests.Add(new TestCase()
            {
                Name = "test1"
            });
            testRun.Tests.Add(new TestCase()
            {
                Name = "test2"
            });
            testRun.Tests.Add(new TestCase()
            {
                Name = "test3"
            });

            var response = await daprClient.InvokeMethodGrpcAsync <TestRun, TestRun>("test", "TestRun", testRun);

            response.Tests.Count.Should().Be(3);
            response.Tests[0].Name.Should().Be("test1");
            response.Tests[1].Name.Should().Be("test2");
            response.Tests[2].Name.Should().Be("test3");
        }
コード例 #3
0
        public async Task InvokeMethodGrpcAsync_AppCallback_UnexpectedMethod()
        {
            // Configure Client
            var httpClient = new AppCallbackClient(new DaprAppCallbackService());
            var daprClient = CreateTestClientGrpc(httpClient);

            var request = new Request()
            {
                RequestParameter = "Look, I was invoked!"
            };

            var response = await daprClient.InvokeMethodGrpcAsync <Request, Response>("test", "not-existing", request);

            response.Name.Should().Be("unexpected");
        }
コード例 #4
0
        public async Task InvokeMethodGrpcAsync_AppCallback_UnexpectedMethod()
        {
            // Configure Client
            var httpClient = new AppCallbackClient(new DaprAppCallbackService());
            var daprClient = new DaprClientBuilder()
                             .UseGrpcChannelOptions(new GrpcChannelOptions()
            {
                HttpClient = httpClient,
            })
                             .UseJsonSerializationOptions(this.jsonSerializerOptions)
                             .Build();

            var request = new Request()
            {
                RequestParameter = "Look, I was invoked!"
            };

            var response = await daprClient.InvokeMethodGrpcAsync <Request, Response>("test", "not-existing", request);

            response.Name.Should().Be("unexpected");
        }
コード例 #5
0
        public async Task InvokeMethodAsync_AppCallback_SayHello()
        {
            // Configure Client
            var jsonOptions = new JsonSerializerOptions {
                PropertyNamingPolicy = JsonNamingPolicy.CamelCase
            };
            var httpClient = new AppCallbackClient(new DaprAppCallbackService(jsonOptions));
            var daprClient = new DaprClientBuilder()
                             .UseGrpcChannelOptions(new GrpcChannelOptions {
                HttpClient = httpClient
            })
                             .UseJsonSerializationOptions(jsonOptions)
                             .Build();

            var request = new Request()
            {
                RequestParameter = "Look, I was invoked!"
            };

            var response = await daprClient.InvokeMethodAsync <Request, Response>("test", "SayHello", request);

            response.Name.Should().Be("Hello Look, I was invoked!");
        }