public async stt::Task GetDetailPlacementViewRequestObjectAsync() { moq::Mock <DetailPlacementViewService.DetailPlacementViewServiceClient> mockGrpcClient = new moq::Mock <DetailPlacementViewService.DetailPlacementViewServiceClient>(moq::MockBehavior.Strict); GetDetailPlacementViewRequest request = new GetDetailPlacementViewRequest { ResourceNameAsDetailPlacementViewName = gagvr::DetailPlacementViewName.FromCustomerAdGroupBase64Placement("[CUSTOMER_ID]", "[AD_GROUP_ID]", "[BASE64_PLACEMENT]"), }; gagvr::DetailPlacementView expectedResponse = new gagvr::DetailPlacementView { ResourceNameAsDetailPlacementViewName = gagvr::DetailPlacementViewName.FromCustomerAdGroupBase64Placement("[CUSTOMER_ID]", "[AD_GROUP_ID]", "[BASE64_PLACEMENT]"), PlacementType = gagve::PlacementTypeEnum.Types.PlacementType.Website, Placement = "placementb440552a", DisplayName = "display_name137f65c2", GroupPlacementTargetUrl = "group_placement_target_urlb7f47882", TargetUrl = "target_url95bdaf9b", }; mockGrpcClient.Setup(x => x.GetDetailPlacementViewAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::DetailPlacementView>(stt::Task.FromResult(expectedResponse), null, null, null, null)); DetailPlacementViewServiceClient client = new DetailPlacementViewServiceClientImpl(mockGrpcClient.Object, null); gagvr::DetailPlacementView responseCallSettings = await client.GetDetailPlacementViewAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); gagvr::DetailPlacementView responseCancellationToken = await client.GetDetailPlacementViewAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task GetDetailPlacementViewAsync2() { Mock <DetailPlacementViewService.DetailPlacementViewServiceClient> mockGrpcClient = new Mock <DetailPlacementViewService.DetailPlacementViewServiceClient>(MockBehavior.Strict); GetDetailPlacementViewRequest request = new GetDetailPlacementViewRequest { ResourceName = new DetailPlacementViewName("[CUSTOMER]", "[DETAIL_PLACEMENT_VIEW]").ToString(), }; DetailPlacementView expectedResponse = new DetailPlacementView { ResourceName = "resourceName2625949903", }; mockGrpcClient.Setup(x => x.GetDetailPlacementViewAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <DetailPlacementView>(Task.FromResult(expectedResponse), null, null, null, null)); DetailPlacementViewServiceClient client = new DetailPlacementViewServiceClientImpl(mockGrpcClient.Object, null); DetailPlacementView response = await client.GetDetailPlacementViewAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }