public async stt::Task UpdateDocumentAsync() { moq::Mock <Firestore.FirestoreClient> mockGrpcClient = new moq::Mock <Firestore.FirestoreClient>(moq::MockBehavior.Strict); UpdateDocumentRequest request = new UpdateDocumentRequest { Document = new Document(), UpdateMask = new DocumentMask(), }; Document expectedResponse = new Document { Name = "name1c9368b0", Fields = { { "key8a0b6e3c", new Value() }, }, CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), }; mockGrpcClient.Setup(x => x.UpdateDocumentAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Document>(stt::Task.FromResult(expectedResponse), null, null, null, null)); FirestoreClient client = new FirestoreClientImpl(mockGrpcClient.Object, null); Document responseCallSettings = await client.UpdateDocumentAsync(request.Document, request.UpdateMask, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Document responseCancellationToken = await client.UpdateDocumentAsync(request.Document, request.UpdateMask, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task UpdateDocumentAsync2() { Mock <Firestore.FirestoreClient> mockGrpcClient = new Mock <Firestore.FirestoreClient>(MockBehavior.Strict); UpdateDocumentRequest request = new UpdateDocumentRequest { Document = new Document(), UpdateMask = new DocumentMask(), }; Document expectedResponse = new Document { Name = "name3373707", }; mockGrpcClient.Setup(x => x.UpdateDocumentAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <Document>(Task.FromResult(expectedResponse), null, null, null, null)); FirestoreClient client = new FirestoreClientImpl(mockGrpcClient.Object, null); Document response = await client.UpdateDocumentAsync(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }