public async stt::Task GetManagedPlacementViewAsync() { moq::Mock <ManagedPlacementViewService.ManagedPlacementViewServiceClient> mockGrpcClient = new moq::Mock <ManagedPlacementViewService.ManagedPlacementViewServiceClient>(moq::MockBehavior.Strict); GetManagedPlacementViewRequest request = new GetManagedPlacementViewRequest { ResourceNameAsManagedPlacementViewName = gagvr::ManagedPlacementViewName.FromCustomerAdGroupCriterion("[CUSTOMER_ID]", "[AD_GROUP_ID]", "[CRITERION_ID]"), }; gagvr::ManagedPlacementView expectedResponse = new gagvr::ManagedPlacementView { ResourceNameAsManagedPlacementViewName = gagvr::ManagedPlacementViewName.FromCustomerAdGroupCriterion("[CUSTOMER_ID]", "[AD_GROUP_ID]", "[CRITERION_ID]"), }; mockGrpcClient.Setup(x => x.GetManagedPlacementViewAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::ManagedPlacementView>(stt::Task.FromResult(expectedResponse), null, null, null, null)); ManagedPlacementViewServiceClient client = new ManagedPlacementViewServiceClientImpl(mockGrpcClient.Object, null); gagvr::ManagedPlacementView responseCallSettings = await client.GetManagedPlacementViewAsync(request.ResourceName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); gagvr::ManagedPlacementView responseCancellationToken = await client.GetManagedPlacementViewAsync(request.ResourceName, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async stt::Task GetManagedPlacementViewRequestObjectAsync() { moq::Mock <ManagedPlacementViewService.ManagedPlacementViewServiceClient> mockGrpcClient = new moq::Mock <ManagedPlacementViewService.ManagedPlacementViewServiceClient>(moq::MockBehavior.Strict); GetManagedPlacementViewRequest request = new GetManagedPlacementViewRequest { ResourceNameAsManagedPlacementViewName = gagvr::ManagedPlacementViewName.FromCustomerManagedPlacementView("[CUSTOMER]", "[MANAGED_PLACEMENT_VIEW]"), }; gagvr::ManagedPlacementView expectedResponse = new gagvr::ManagedPlacementView { ResourceNameAsManagedPlacementViewName = gagvr::ManagedPlacementViewName.FromCustomerManagedPlacementView("[CUSTOMER]", "[MANAGED_PLACEMENT_VIEW]"), }; mockGrpcClient.Setup(x => x.GetManagedPlacementViewAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::ManagedPlacementView>(stt::Task.FromResult(expectedResponse), null, null, null, null)); ManagedPlacementViewServiceClient client = new ManagedPlacementViewServiceClientImpl(mockGrpcClient.Object, null); gagvr::ManagedPlacementView responseCallSettings = await client.GetManagedPlacementViewAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); gagvr::ManagedPlacementView responseCancellationToken = await client.GetManagedPlacementViewAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task GetManagedPlacementViewAsync2() { Mock <ManagedPlacementViewService.ManagedPlacementViewServiceClient> mockGrpcClient = new Mock <ManagedPlacementViewService.ManagedPlacementViewServiceClient>(MockBehavior.Strict); GetManagedPlacementViewRequest request = new GetManagedPlacementViewRequest { ResourceName = new ManagedPlacementViewName("[CUSTOMER]", "[MANAGED_PLACEMENT_VIEW]").ToString(), }; ManagedPlacementView expectedResponse = new ManagedPlacementView { ResourceName = "resourceName2625949903", }; mockGrpcClient.Setup(x => x.GetManagedPlacementViewAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <ManagedPlacementView>(Task.FromResult(expectedResponse), null, null, null, null)); ManagedPlacementViewServiceClient client = new ManagedPlacementViewServiceClientImpl(mockGrpcClient.Object, null); ManagedPlacementView response = await client.GetManagedPlacementViewAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }