public async stt::Task GetIndexRequestObjectAsync() { moq::Mock <DatastoreAdmin.DatastoreAdminClient> mockGrpcClient = new moq::Mock <DatastoreAdmin.DatastoreAdminClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetIndexRequest request = new GetIndexRequest { ProjectId = "project_id43ad98b0", IndexId = "index_id3caa18b6", }; Index expectedResponse = new Index { ProjectId = "project_id43ad98b0", IndexId = "index_id3caa18b6", Kind = "kindf7aa39d9", Ancestor = Index.Types.AncestorMode.None, Properties = { new Index.Types.IndexedProperty(), }, State = Index.Types.State.Deleting, }; mockGrpcClient.Setup(x => x.GetIndexAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Index>(stt::Task.FromResult(expectedResponse), null, null, null, null)); DatastoreAdminClient client = new DatastoreAdminClientImpl(mockGrpcClient.Object, null); Index responseCallSettings = await client.GetIndexAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Index responseCancellationToken = await client.GetIndexAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetIndexRequestObject() { moq::Mock <DatastoreAdmin.DatastoreAdminClient> mockGrpcClient = new moq::Mock <DatastoreAdmin.DatastoreAdminClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetIndexRequest request = new GetIndexRequest { ProjectId = "project_id43ad98b0", IndexId = "index_id3caa18b6", }; Index expectedResponse = new Index { ProjectId = "project_id43ad98b0", IndexId = "index_id3caa18b6", Kind = "kindf7aa39d9", Ancestor = Index.Types.AncestorMode.None, Properties = { new Index.Types.IndexedProperty(), }, State = Index.Types.State.Deleting, }; mockGrpcClient.Setup(x => x.GetIndex(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); DatastoreAdminClient client = new DatastoreAdminClientImpl(mockGrpcClient.Object, null); Index response = client.GetIndex(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }