コード例 #1
0
        public async Task UpdateAlertPolicyAsync2()
        {
            Mock <AlertPolicyService.AlertPolicyServiceClient> mockGrpcClient = new Mock <AlertPolicyService.AlertPolicyServiceClient>(MockBehavior.Strict);
            UpdateAlertPolicyRequest request = new UpdateAlertPolicyRequest
            {
                AlertPolicy = new AlertPolicy(),
            };
            AlertPolicy expectedResponse = new AlertPolicy
            {
                Name        = "name3373707",
                DisplayName = "displayName1615086568",
            };

            mockGrpcClient.Setup(x => x.UpdateAlertPolicyAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <AlertPolicy>(Task.FromResult(expectedResponse), null, null, null, null));
            AlertPolicyServiceClient client = new AlertPolicyServiceClientImpl(mockGrpcClient.Object, null);
            AlertPolicy response            = await client.UpdateAlertPolicyAsync(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }