public async stt::Task UpdateGroupAsync() { moq::Mock <GroupService.GroupServiceClient> mockGrpcClient = new moq::Mock <GroupService.GroupServiceClient>(moq::MockBehavior.Strict); UpdateGroupRequest request = new UpdateGroupRequest { Group = new Group(), }; Group expectedResponse = new Group { GroupName = GroupName.FromProjectGroup("[PROJECT]", "[GROUP]"), DisplayName = "display_name137f65c2", ParentName = "parent_name91315215", Filter = "filtere47ac9b2", IsCluster = true, }; mockGrpcClient.Setup(x => x.UpdateGroupAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Group>(stt::Task.FromResult(expectedResponse), null, null, null, null)); GroupServiceClient client = new GroupServiceClientImpl(mockGrpcClient.Object, null); Group responseCallSettings = await client.UpdateGroupAsync(request.Group, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Group responseCancellationToken = await client.UpdateGroupAsync(request.Group, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task UpdateGroupAsync() { Mock <GroupService.GroupServiceClient> mockGrpcClient = new Mock <GroupService.GroupServiceClient>(MockBehavior.Strict); UpdateGroupRequest expectedRequest = new UpdateGroupRequest { Group = new Group(), }; Group expectedResponse = new Group { GroupName = new GroupName("[PROJECT]", "[GROUP]"), DisplayName = "displayName1615086568", ParentNameAsGroupName = new GroupName("[PROJECT]", "[GROUP]"), Filter = "filter-1274492040", IsCluster = false, }; mockGrpcClient.Setup(x => x.UpdateGroupAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <Group>(Task.FromResult(expectedResponse), null, null, null, null)); GroupServiceClient client = new GroupServiceClientImpl(mockGrpcClient.Object, null); Group group = new Group(); Group response = await client.UpdateGroupAsync(group); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }