Esempio n. 1
0
        public async Task DeleteJobAsync()
        {
            Mock <CloudScheduler.CloudSchedulerClient> mockGrpcClient = new Mock <CloudScheduler.CloudSchedulerClient>(MockBehavior.Strict);
            DeleteJobRequest expectedRequest = new DeleteJobRequest
            {
                JobName = new JobName("[PROJECT]", "[LOCATION]", "[JOB]"),
            };
            Empty expectedResponse = new Empty();

            mockGrpcClient.Setup(x => x.DeleteJobAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Empty>(Task.FromResult(expectedResponse), null, null, null, null));
            CloudSchedulerClient client = new CloudSchedulerClientImpl(mockGrpcClient.Object, null);
            JobName name = new JobName("[PROJECT]", "[LOCATION]", "[JOB]");
            await client.DeleteJobAsync(name);

            mockGrpcClient.VerifyAll();
        }
Esempio n. 2
0
        public void DeleteJob()
        {
            Mock <CloudScheduler.CloudSchedulerClient> mockGrpcClient = new Mock <CloudScheduler.CloudSchedulerClient>(MockBehavior.Strict);
            DeleteJobRequest expectedRequest = new DeleteJobRequest
            {
                JobName = new JobName("[PROJECT]", "[LOCATION]", "[JOB]"),
            };
            Empty expectedResponse = new Empty();

            mockGrpcClient.Setup(x => x.DeleteJob(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            CloudSchedulerClient client = new CloudSchedulerClientImpl(mockGrpcClient.Object, null);
            JobName name = new JobName("[PROJECT]", "[LOCATION]", "[JOB]");

            client.DeleteJob(name);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 3
0
        public void GetJob2()
        {
            Mock <CloudScheduler.CloudSchedulerClient> mockGrpcClient = new Mock <CloudScheduler.CloudSchedulerClient>(MockBehavior.Strict);
            GetJobRequest request = new GetJobRequest
            {
                Name = new JobName("[PROJECT]", "[LOCATION]", "[JOB]").ToString(),
            };
            Job expectedResponse = new Job
            {
                Name        = "name2-1052831874",
                Description = "description-1724546052",
                Schedule    = "schedule-697920873",
                TimeZone    = "timeZone36848094",
            };

            mockGrpcClient.Setup(x => x.GetJob(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            CloudSchedulerClient client = new CloudSchedulerClientImpl(mockGrpcClient.Object, null);
            Job response = client.GetJob(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 4
0
        public async Task RunJobAsync2()
        {
            Mock <CloudScheduler.CloudSchedulerClient> mockGrpcClient = new Mock <CloudScheduler.CloudSchedulerClient>(MockBehavior.Strict);
            RunJobRequest request = new RunJobRequest
            {
                Name = new JobName("[PROJECT]", "[LOCATION]", "[JOB]").ToString(),
            };
            Job expectedResponse = new Job
            {
                Name        = "name2-1052831874",
                Description = "description-1724546052",
                Schedule    = "schedule-697920873",
                TimeZone    = "timeZone36848094",
            };

            mockGrpcClient.Setup(x => x.RunJobAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Job>(Task.FromResult(expectedResponse), null, null, null, null));
            CloudSchedulerClient client = new CloudSchedulerClientImpl(mockGrpcClient.Object, null);
            Job response = await client.RunJobAsync(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 5
0
        public async Task UpdateJobAsync2()
        {
            Mock <CloudScheduler.CloudSchedulerClient> mockGrpcClient = new Mock <CloudScheduler.CloudSchedulerClient>(MockBehavior.Strict);
            UpdateJobRequest request = new UpdateJobRequest
            {
                Job = new Job(),
            };
            Job expectedResponse = new Job
            {
                Name        = "name3373707",
                Description = "description-1724546052",
                Schedule    = "schedule-697920873",
                TimeZone    = "timeZone36848094",
            };

            mockGrpcClient.Setup(x => x.UpdateJobAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Job>(Task.FromResult(expectedResponse), null, null, null, null));
            CloudSchedulerClient client = new CloudSchedulerClientImpl(mockGrpcClient.Object, null);
            Job response = await client.UpdateJobAsync(request);

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