Exemple #1
0
        public async stt::Task GetBatchRequestObjectAsync()
        {
            moq::Mock <BatchController.BatchControllerClient> mockGrpcClient = new moq::Mock <BatchController.BatchControllerClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetBatchRequest request = new GetBatchRequest
            {
                BatchName = BatchName.FromProjectLocationBatch("[PROJECT]", "[LOCATION]", "[BATCH]"),
            };
            Batch expectedResponse = new Batch
            {
                BatchName     = BatchName.FromProjectLocationBatch("[PROJECT]", "[LOCATION]", "[BATCH]"),
                Uuid          = "uuid6f877cef",
                CreateTime    = new wkt::Timestamp(),
                PysparkBatch  = new PySparkBatch(),
                SparkBatch    = new SparkBatch(),
                SparkRBatch   = new SparkRBatch(),
                SparkSqlBatch = new SparkSqlBatch(),
                RuntimeInfo   = new RuntimeInfo(),
                State         = Batch.Types.State.Failed,
                StateMessage  = "state_message46cf28c0",
                StateTime     = new wkt::Timestamp(),
                Creator       = "creator253324ee",
                Labels        =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                RuntimeConfig     = new RuntimeConfig(),
                EnvironmentConfig = new EnvironmentConfig(),
                Operation         = "operation615a23f7",
                StateHistory      =
                {
                    new Batch.Types.StateHistory(),
                },
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Batch responseCancellationToken = await client.GetBatchAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Exemple #2
0
        public void DeleteBatchResourceNames()
        {
            moq::Mock <BatchController.BatchControllerClient> mockGrpcClient = new moq::Mock <BatchController.BatchControllerClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            DeleteBatchRequest request = new DeleteBatchRequest
            {
                BatchName = BatchName.FromProjectLocationBatch("[PROJECT]", "[LOCATION]", "[BATCH]"),
            };
            wkt::Empty expectedResponse = new wkt::Empty {
            };

            mockGrpcClient.Setup(x => x.DeleteBatch(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            BatchControllerClient client = new BatchControllerClientImpl(mockGrpcClient.Object, null);

            client.DeleteBatch(request.BatchName);
            mockGrpcClient.VerifyAll();
        }
Exemple #3
0
        public async stt::Task DeleteBatchResourceNamesAsync()
        {
            moq::Mock <BatchController.BatchControllerClient> mockGrpcClient = new moq::Mock <BatchController.BatchControllerClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            DeleteBatchRequest request = new DeleteBatchRequest
            {
                BatchName = BatchName.FromProjectLocationBatch("[PROJECT]", "[LOCATION]", "[BATCH]"),
            };
            wkt::Empty expectedResponse = new wkt::Empty {
            };

            mockGrpcClient.Setup(x => x.DeleteBatchAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            BatchControllerClient client = new BatchControllerClientImpl(mockGrpcClient.Object, null);
            await client.DeleteBatchAsync(request.BatchName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            await client.DeleteBatchAsync(request.BatchName, st::CancellationToken.None);

            mockGrpcClient.VerifyAll();
        }