Ejemplo n.º 1
0
        public async stt::Task GetDatabaseResourceNamesAsync()
        {
            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);
            GetDatabaseRequest request = new GetDatabaseRequest
            {
                DatabaseName = DatabaseName.FromProjectDatabase("[PROJECT]", "[DATABASE]"),
            };
            Database expectedResponse = new Database
            {
                DatabaseName    = DatabaseName.FromProjectDatabase("[PROJECT]", "[DATABASE]"),
                LocationId      = "location_iddaa574e2",
                Type            = Database.Types.DatabaseType.Unspecified,
                ConcurrencyMode = Database.Types.ConcurrencyMode.OptimisticWithEntityGroups,
                Etag            = "etage8ad7218",
            };

            mockGrpcClient.Setup(x => x.GetDatabaseAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Database>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            FirestoreAdminClient client = new FirestoreAdminClientImpl(mockGrpcClient.Object, null);
            Database             responseCallSettings = await client.GetDatabaseAsync(request.DatabaseName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Database responseCancellationToken = await client.GetDatabaseAsync(request.DatabaseName, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 2
0
        public void GetDatabaseResourceNames()
        {
            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);
            GetDatabaseRequest request = new GetDatabaseRequest
            {
                DatabaseName = DatabaseName.FromProjectDatabase("[PROJECT]", "[DATABASE]"),
            };
            Database expectedResponse = new Database
            {
                DatabaseName    = DatabaseName.FromProjectDatabase("[PROJECT]", "[DATABASE]"),
                LocationId      = "location_iddaa574e2",
                Type            = Database.Types.DatabaseType.Unspecified,
                ConcurrencyMode = Database.Types.ConcurrencyMode.OptimisticWithEntityGroups,
                Etag            = "etage8ad7218",
            };

            mockGrpcClient.Setup(x => x.GetDatabase(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            FirestoreAdminClient client   = new FirestoreAdminClientImpl(mockGrpcClient.Object, null);
            Database             response = client.GetDatabase(request.DatabaseName);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }