public async Task CommitAsync3() { Mock <Spanner.SpannerClient> mockGrpcClient = new Mock <Spanner.SpannerClient>(MockBehavior.Strict); CommitRequest request = new CommitRequest { SessionAsSessionName = new SessionName("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"), Mutations = { }, }; CommitResponse expectedResponse = new CommitResponse(); mockGrpcClient.Setup(x => x.CommitAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <CommitResponse>(Task.FromResult(expectedResponse), null, null, null, null)); SpannerClient client = new SpannerClientImpl(mockGrpcClient.Object, null); CommitResponse response = await client.CommitAsync(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task CommitAsync() { Mock <Spanner.SpannerClient> mockGrpcClient = new Mock <Spanner.SpannerClient>(MockBehavior.Strict); CommitRequest expectedRequest = new CommitRequest { SessionAsSessionName = new SessionName("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"), TransactionId = ByteString.CopyFromUtf8("28"), Mutations = { }, }; CommitResponse expectedResponse = new CommitResponse(); mockGrpcClient.Setup(x => x.CommitAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <CommitResponse>(Task.FromResult(expectedResponse), null, null, null, null)); SpannerClient client = new SpannerClientImpl(mockGrpcClient.Object, null); SessionName session = new SessionName("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"); ByteString transactionId = ByteString.CopyFromUtf8("28"); IEnumerable <Mutation> mutations = new List <Mutation>(); CommitResponse response = await client.CommitAsync(session, transactionId, mutations); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }