示例#1
0
        public async stt::Task GetAdScheduleViewRequestObjectAsync()
        {
            moq::Mock <AdScheduleViewService.AdScheduleViewServiceClient> mockGrpcClient = new moq::Mock <AdScheduleViewService.AdScheduleViewServiceClient>(moq::MockBehavior.Strict);
            GetAdScheduleViewRequest request = new GetAdScheduleViewRequest
            {
                ResourceNameAsAdScheduleViewName = gagvr::AdScheduleViewName.FromCustomerAdScheduleView("[CUSTOMER]", "[AD_SCHEDULE_VIEW]"),
            };
            gagvr::AdScheduleView expectedResponse = new gagvr::AdScheduleView
            {
                ResourceNameAsAdScheduleViewName = gagvr::AdScheduleViewName.FromCustomerAdScheduleView("[CUSTOMER]", "[AD_SCHEDULE_VIEW]"),
            };

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

            Assert.AreEqual(expectedResponse, responseCallSettings);
            gagvr::AdScheduleView responseCancellationToken = await client.GetAdScheduleViewAsync(request, st::CancellationToken.None);

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public async Task GetAdScheduleViewAsync2()
        {
            Mock <AdScheduleViewService.AdScheduleViewServiceClient> mockGrpcClient = new Mock <AdScheduleViewService.AdScheduleViewServiceClient>(MockBehavior.Strict);
            GetAdScheduleViewRequest request = new GetAdScheduleViewRequest
            {
                ResourceName = new AdScheduleViewName("[CUSTOMER]", "[AD_SCHEDULE_VIEW]").ToString(),
            };
            AdScheduleView expectedResponse = new AdScheduleView
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetAdScheduleViewAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <AdScheduleView>(Task.FromResult(expectedResponse), null, null, null, null));
            AdScheduleViewServiceClient client = new AdScheduleViewServiceClientImpl(mockGrpcClient.Object, null);
            AdScheduleView response            = await client.GetAdScheduleViewAsync(request);

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