コード例 #1
0
        public async stt::Task GetDisplayKeywordViewAsync()
        {
            moq::Mock <DisplayKeywordViewService.DisplayKeywordViewServiceClient> mockGrpcClient = new moq::Mock <DisplayKeywordViewService.DisplayKeywordViewServiceClient>(moq::MockBehavior.Strict);
            GetDisplayKeywordViewRequest request = new GetDisplayKeywordViewRequest
            {
                ResourceNameAsDisplayKeywordViewName = gagvr::DisplayKeywordViewName.FromCustomerDisplayKeywordView("[CUSTOMER]", "[DISPLAY_KEYWORD_VIEW]"),
            };
            gagvr::DisplayKeywordView expectedResponse = new gagvr::DisplayKeywordView
            {
                ResourceNameAsDisplayKeywordViewName = gagvr::DisplayKeywordViewName.FromCustomerDisplayKeywordView("[CUSTOMER]", "[DISPLAY_KEYWORD_VIEW]"),
            };

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

            Assert.AreEqual(expectedResponse, responseCallSettings);
            gagvr::DisplayKeywordView responseCancellationToken = await client.GetDisplayKeywordViewAsync(request.ResourceName, st::CancellationToken.None);

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public async Task GetDisplayKeywordViewAsync2()
        {
            Mock <DisplayKeywordViewService.DisplayKeywordViewServiceClient> mockGrpcClient = new Mock <DisplayKeywordViewService.DisplayKeywordViewServiceClient>(MockBehavior.Strict);
            GetDisplayKeywordViewRequest request = new GetDisplayKeywordViewRequest
            {
                ResourceName = new DisplayKeywordViewName("[CUSTOMER]", "[DISPLAY_KEYWORD_VIEW]").ToString(),
            };
            DisplayKeywordView expectedResponse = new DisplayKeywordView
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetDisplayKeywordViewAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <DisplayKeywordView>(Task.FromResult(expectedResponse), null, null, null, null));
            DisplayKeywordViewServiceClient client = new DisplayKeywordViewServiceClientImpl(mockGrpcClient.Object, null);
            DisplayKeywordView response            = await client.GetDisplayKeywordViewAsync(request);

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