public async stt::Task UpdateGroupAsync() { moq::Mock <ErrorGroupService.ErrorGroupServiceClient> mockGrpcClient = new moq::Mock <ErrorGroupService.ErrorGroupServiceClient>(moq::MockBehavior.Strict); UpdateGroupRequest request = new UpdateGroupRequest { Group = new ErrorGroup(), }; ErrorGroup expectedResponse = new ErrorGroup { ErrorGroupName = new ErrorGroupName("[PROJECT]", "[GROUP]"), GroupId = "group_id4f9a930e", TrackingIssues = { new TrackingIssue(), }, }; mockGrpcClient.Setup(x => x.UpdateGroupAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <ErrorGroup>(stt::Task.FromResult(expectedResponse), null, null, null, null)); ErrorGroupServiceClient client = new ErrorGroupServiceClientImpl(mockGrpcClient.Object, null); ErrorGroup responseCallSettings = await client.UpdateGroupAsync(request.Group, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); ErrorGroup responseCancellationToken = await client.UpdateGroupAsync(request.Group, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task UpdateGroupAsync2() { Mock <ErrorGroupService.ErrorGroupServiceClient> mockGrpcClient = new Mock <ErrorGroupService.ErrorGroupServiceClient>(MockBehavior.Strict); UpdateGroupRequest request = new UpdateGroupRequest { Group = new ErrorGroup(), }; ErrorGroup expectedResponse = new ErrorGroup { GroupName = new GroupName("[PROJECT]", "[GROUP]"), GroupId = "groupId506361563", }; mockGrpcClient.Setup(x => x.UpdateGroupAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <ErrorGroup>(Task.FromResult(expectedResponse), null, null, null, null)); ErrorGroupServiceClient client = new ErrorGroupServiceClientImpl(mockGrpcClient.Object, null); ErrorGroup response = await client.UpdateGroupAsync(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }