public async stt::Task GetCustomerManagerLinkRequestObjectAsync() { moq::Mock <CustomerManagerLinkService.CustomerManagerLinkServiceClient> mockGrpcClient = new moq::Mock <CustomerManagerLinkService.CustomerManagerLinkServiceClient>(moq::MockBehavior.Strict); GetCustomerManagerLinkRequest request = new GetCustomerManagerLinkRequest { ResourceNameAsCustomerManagerLinkName = gagvr::CustomerManagerLinkName.FromCustomerManagerCustomerManagerLink("[CUSTOMER_ID]", "[MANAGER_CUSTOMER_ID]", "[MANAGER_LINK_ID]"), }; gagvr::CustomerManagerLink expectedResponse = new gagvr::CustomerManagerLink { ResourceNameAsCustomerManagerLinkName = gagvr::CustomerManagerLinkName.FromCustomerManagerCustomerManagerLink("[CUSTOMER_ID]", "[MANAGER_CUSTOMER_ID]", "[MANAGER_LINK_ID]"), Status = gagve::ManagerLinkStatusEnum.Types.ManagerLinkStatus.Inactive, ManagerCustomer = "manager_customer3075601e", ManagerLinkId = 1955158851327798968L, }; mockGrpcClient.Setup(x => x.GetCustomerManagerLinkAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::CustomerManagerLink>(stt::Task.FromResult(expectedResponse), null, null, null, null)); CustomerManagerLinkServiceClient client = new CustomerManagerLinkServiceClientImpl(mockGrpcClient.Object, null); gagvr::CustomerManagerLink responseCallSettings = await client.GetCustomerManagerLinkAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); gagvr::CustomerManagerLink responseCancellationToken = await client.GetCustomerManagerLinkAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task GetCustomerManagerLinkAsync2() { Mock <CustomerManagerLinkService.CustomerManagerLinkServiceClient> mockGrpcClient = new Mock <CustomerManagerLinkService.CustomerManagerLinkServiceClient>(MockBehavior.Strict); GetCustomerManagerLinkRequest request = new GetCustomerManagerLinkRequest { ResourceName = new CustomerManagerLinkName("[CUSTOMER]", "[CUSTOMER_MANAGER_LINK]").ToString(), }; CustomerManagerLink expectedResponse = new CustomerManagerLink { ResourceName = "resourceName2625949903", }; mockGrpcClient.Setup(x => x.GetCustomerManagerLinkAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <CustomerManagerLink>(Task.FromResult(expectedResponse), null, null, null, null)); CustomerManagerLinkServiceClient client = new CustomerManagerLinkServiceClientImpl(mockGrpcClient.Object, null); CustomerManagerLink response = await client.GetCustomerManagerLinkAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }