public void GetLandingPageView() { moq::Mock <LandingPageViewService.LandingPageViewServiceClient> mockGrpcClient = new moq::Mock <LandingPageViewService.LandingPageViewServiceClient>(moq::MockBehavior.Strict); GetLandingPageViewRequest request = new GetLandingPageViewRequest { ResourceNameAsLandingPageViewName = gagvr::LandingPageViewName.FromCustomerLandingPageView("[CUSTOMER]", "[LANDING_PAGE_VIEW]"), }; gagvr::LandingPageView expectedResponse = new gagvr::LandingPageView { ResourceNameAsLandingPageViewName = gagvr::LandingPageViewName.FromCustomerLandingPageView("[CUSTOMER]", "[LANDING_PAGE_VIEW]"), UnexpandedFinalUrl = "unexpanded_final_url7d6e0a3e", }; mockGrpcClient.Setup(x => x.GetLandingPageView(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); LandingPageViewServiceClient client = new LandingPageViewServiceClientImpl(mockGrpcClient.Object, null); gagvr::LandingPageView response = client.GetLandingPageView(request.ResourceName); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void GetLandingPageView() { moq::Mock <LandingPageViewService.LandingPageViewServiceClient> mockGrpcClient = new moq::Mock <LandingPageViewService.LandingPageViewServiceClient>(moq::MockBehavior.Strict); GetLandingPageViewRequest request = new GetLandingPageViewRequest { ResourceNameAsLandingPageViewName = gagvr::LandingPageViewName.FromCustomerUnexpandedFinalUrlFingerprint("[CUSTOMER_ID]", "[UNEXPANDED_FINAL_URL_FINGERPRINT]"), }; gagvr::LandingPageView expectedResponse = new gagvr::LandingPageView { ResourceNameAsLandingPageViewName = gagvr::LandingPageViewName.FromCustomerUnexpandedFinalUrlFingerprint("[CUSTOMER_ID]", "[UNEXPANDED_FINAL_URL_FINGERPRINT]"), UnexpandedFinalUrl = "unexpanded_final_url7d6e0a3e", }; mockGrpcClient.Setup(x => x.GetLandingPageView(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); LandingPageViewServiceClient client = new LandingPageViewServiceClientImpl(mockGrpcClient.Object, null); gagvr::LandingPageView response = client.GetLandingPageView(request.ResourceName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task GetLandingPageViewRequestObjectAsync() { moq::Mock <LandingPageViewService.LandingPageViewServiceClient> mockGrpcClient = new moq::Mock <LandingPageViewService.LandingPageViewServiceClient>(moq::MockBehavior.Strict); GetLandingPageViewRequest request = new GetLandingPageViewRequest { ResourceNameAsLandingPageViewName = gagvr::LandingPageViewName.FromCustomerLandingPageView("[CUSTOMER]", "[LANDING_PAGE_VIEW]"), }; gagvr::LandingPageView expectedResponse = new gagvr::LandingPageView { ResourceNameAsLandingPageViewName = gagvr::LandingPageViewName.FromCustomerLandingPageView("[CUSTOMER]", "[LANDING_PAGE_VIEW]"), UnexpandedFinalUrl = "unexpanded_final_url7d6e0a3e", }; mockGrpcClient.Setup(x => x.GetLandingPageViewAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::LandingPageView>(stt::Task.FromResult(expectedResponse), null, null, null, null)); LandingPageViewServiceClient client = new LandingPageViewServiceClientImpl(mockGrpcClient.Object, null); gagvr::LandingPageView responseCallSettings = await client.GetLandingPageViewAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); gagvr::LandingPageView responseCancellationToken = await client.GetLandingPageViewAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }