public void GetIndex() { moq::Mock <FirestoreAdmin.FirestoreAdminClient> mockGrpcClient = new moq::Mock <FirestoreAdmin.FirestoreAdminClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetIndexRequest request = new GetIndexRequest { IndexName = IndexName.FromProjectDatabaseCollectionIndex("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"), }; Index expectedResponse = new Index { IndexName = IndexName.FromProjectDatabaseCollectionIndex("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"), QueryScope = Index.Types.QueryScope.Unspecified, Fields = { new Index.Types.IndexField(), }, State = Index.Types.State.Ready, }; mockGrpcClient.Setup(x => x.GetIndex(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); FirestoreAdminClient client = new FirestoreAdminClientImpl(mockGrpcClient.Object, null); Index response = client.GetIndex(request.Name); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task GetIndexRequestObjectAsync() { moq::Mock <FirestoreAdmin.FirestoreAdminClient> mockGrpcClient = new moq::Mock <FirestoreAdmin.FirestoreAdminClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetIndexRequest request = new GetIndexRequest { IndexName = IndexName.FromProjectDatabaseCollectionIndex("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"), }; Index expectedResponse = new Index { IndexName = IndexName.FromProjectDatabaseCollectionIndex("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"), QueryScope = Index.Types.QueryScope.Unspecified, Fields = { new Index.Types.IndexField(), }, State = Index.Types.State.Ready, }; mockGrpcClient.Setup(x => x.GetIndexAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Index>(stt::Task.FromResult(expectedResponse), null, null, null, null)); FirestoreAdminClient client = new FirestoreAdminClientImpl(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 DeleteIndexResourceNames() { moq::Mock<FirestoreAdmin.FirestoreAdminClient> mockGrpcClient = new moq::Mock<FirestoreAdmin.FirestoreAdminClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock<lro::Operations.OperationsClient>().Object); DeleteIndexRequest request = new DeleteIndexRequest { IndexName = IndexName.FromProjectDatabaseCollectionIndex("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeleteIndex(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(expectedResponse); FirestoreAdminClient client = new FirestoreAdminClientImpl(mockGrpcClient.Object, null); client.DeleteIndex(request.IndexName); mockGrpcClient.VerifyAll(); }
public async stt::Task DeleteIndexResourceNamesAsync() { moq::Mock<FirestoreAdmin.FirestoreAdminClient> mockGrpcClient = new moq::Mock<FirestoreAdmin.FirestoreAdminClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock<lro::Operations.OperationsClient>().Object); DeleteIndexRequest request = new DeleteIndexRequest { IndexName = IndexName.FromProjectDatabaseCollectionIndex("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeleteIndexAsync(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall<wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null)); FirestoreAdminClient client = new FirestoreAdminClientImpl(mockGrpcClient.Object, null); await client.DeleteIndexAsync(request.IndexName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); await client.DeleteIndexAsync(request.IndexName, st::CancellationToken.None); mockGrpcClient.VerifyAll(); }