public async stt::Task GetProductGroupViewAsync() { moq::Mock <ProductGroupViewService.ProductGroupViewServiceClient> mockGrpcClient = new moq::Mock <ProductGroupViewService.ProductGroupViewServiceClient>(moq::MockBehavior.Strict); GetProductGroupViewRequest request = new GetProductGroupViewRequest { ResourceNameAsProductGroupViewName = gagvr::ProductGroupViewName.FromCustomerAdgroupCriterion("[CUSTOMER_ID]", "[ADGROUP_ID]", "[CRITERION_ID]"), }; gagvr::ProductGroupView expectedResponse = new gagvr::ProductGroupView { ResourceNameAsProductGroupViewName = gagvr::ProductGroupViewName.FromCustomerAdgroupCriterion("[CUSTOMER_ID]", "[ADGROUP_ID]", "[CRITERION_ID]"), }; mockGrpcClient.Setup(x => x.GetProductGroupViewAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::ProductGroupView>(stt::Task.FromResult(expectedResponse), null, null, null, null)); ProductGroupViewServiceClient client = new ProductGroupViewServiceClientImpl(mockGrpcClient.Object, null); gagvr::ProductGroupView responseCallSettings = await client.GetProductGroupViewAsync(request.ResourceName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); gagvr::ProductGroupView responseCancellationToken = await client.GetProductGroupViewAsync(request.ResourceName, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task GetProductGroupViewAsync2() { Mock <ProductGroupViewService.ProductGroupViewServiceClient> mockGrpcClient = new Mock <ProductGroupViewService.ProductGroupViewServiceClient>(MockBehavior.Strict); GetProductGroupViewRequest request = new GetProductGroupViewRequest { ResourceName = new ProductGroupViewName("[CUSTOMER]", "[PRODUCT_GROUP_VIEW]").ToString(), }; ProductGroupView expectedResponse = new ProductGroupView { ResourceName = "resourceName2625949903", }; mockGrpcClient.Setup(x => x.GetProductGroupViewAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <ProductGroupView>(Task.FromResult(expectedResponse), null, null, null, null)); ProductGroupViewServiceClient client = new ProductGroupViewServiceClientImpl(mockGrpcClient.Object, null); ProductGroupView response = await client.GetProductGroupViewAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }