Beispiel #1
0
        public async Task AddMutateJobOperationsAsync()
        {
            Mock <MutateJobService.MutateJobServiceClient> mockGrpcClient = new Mock <MutateJobService.MutateJobServiceClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            AddMutateJobOperationsRequest expectedRequest = new AddMutateJobOperationsRequest
            {
                ResourceName     = new MutateJobName("[CUSTOMER]", "[MUTATE_JOB]").ToString(),
                SequenceToken    = "sequenceToken-868155397",
                MutateOperations = { },
            };
            AddMutateJobOperationsResponse expectedResponse = new AddMutateJobOperationsResponse
            {
                TotalOperations   = 1685086151L,
                NextSequenceToken = "nextSequenceToken388644551",
            };

            mockGrpcClient.Setup(x => x.AddMutateJobOperationsAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <AddMutateJobOperationsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            MutateJobServiceClient client = new MutateJobServiceClientImpl(mockGrpcClient.Object, null);
            string formattedResourceName  = new MutateJobName("[CUSTOMER]", "[MUTATE_JOB]").ToString();
            string sequenceToken          = "sequenceToken-868155397";
            IEnumerable <MutateOperation>  mutateOperations = new List <MutateOperation>();
            AddMutateJobOperationsResponse response         = await client.AddMutateJobOperationsAsync(formattedResourceName, sequenceToken, mutateOperations);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Beispiel #2
0
        public async Task GetMutateJobAsync()
        {
            Mock <MutateJobService.MutateJobServiceClient> mockGrpcClient = new Mock <MutateJobService.MutateJobServiceClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            GetMutateJobRequest expectedRequest = new GetMutateJobRequest
            {
                ResourceName = new MutateJobName("[CUSTOMER]", "[MUTATE_JOB]").ToString(),
            };
            MutateJob expectedResponse = new MutateJob
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetMutateJobAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <MutateJob>(Task.FromResult(expectedResponse), null, null, null, null));
            MutateJobServiceClient client   = new MutateJobServiceClientImpl(mockGrpcClient.Object, null);
            string    formattedResourceName = new MutateJobName("[CUSTOMER]", "[MUTATE_JOB]").ToString();
            MutateJob response = await client.GetMutateJobAsync(formattedResourceName);

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