public async stt::Task GetUserListRequestObjectAsync() { moq::Mock <UserListService.UserListServiceClient> mockGrpcClient = new moq::Mock <UserListService.UserListServiceClient>(moq::MockBehavior.Strict); GetUserListRequest request = new GetUserListRequest { ResourceNameAsUserListName = gagvr::UserListName.FromCustomerUserList("[CUSTOMER_ID]", "[USER_LIST_ID]"), }; gagvr::UserList expectedResponse = new gagvr::UserList { ResourceNameAsUserListName = gagvr::UserListName.FromCustomerUserList("[CUSTOMER_ID]", "[USER_LIST_ID]"), MembershipStatus = gagve::UserListMembershipStatusEnum.Types.UserListMembershipStatus.Open, SizeRangeForDisplay = gagve::UserListSizeRangeEnum.Types.UserListSizeRange.Unknown, SizeRangeForSearch = gagve::UserListSizeRangeEnum.Types.UserListSizeRange.OneHundredThousandToThreeHundredThousand, Type = gagve::UserListTypeEnum.Types.UserListType.CrmBased, ClosingReason = gagve::UserListClosingReasonEnum.Types.UserListClosingReason.Unused, AccessReason = gagve::AccessReasonEnum.Types.AccessReason.Affiliated, AccountUserListStatus = gagve::UserListAccessStatusEnum.Types.UserListAccessStatus.Disabled, CrmBasedUserList = new gagvc::CrmBasedUserListInfo(), SimilarUserList = new gagvc::SimilarUserListInfo(), RuleBasedUserList = new gagvc::RuleBasedUserListInfo(), LogicalUserList = new gagvc::LogicalUserListInfo(), BasicUserList = new gagvc::BasicUserListInfo(), MatchRatePercentage = 696939998, Id = -6774108720365892680L, ReadOnly = false, UserListName = gagvr::UserListName.FromCustomerUserList("[CUSTOMER_ID]", "[USER_LIST_ID]"), Description = "description2cf9da67", IntegrationCode = "integration_codeb56c28f6", MembershipLifeSpan = 8593891943371112615L, SizeForDisplay = -3774093290138442712L, SizeForSearch = 7931927642168968409L, EligibleForSearch = false, EligibleForDisplay = true, }; mockGrpcClient.Setup(x => x.GetUserListAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::UserList>(stt::Task.FromResult(expectedResponse), null, null, null, null)); UserListServiceClient client = new UserListServiceClientImpl(mockGrpcClient.Object, null); gagvr::UserList responseCallSettings = await client.GetUserListAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); gagvr::UserList responseCancellationToken = await client.GetUserListAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task GetUserListAsync2() { Mock <UserListService.UserListServiceClient> mockGrpcClient = new Mock <UserListService.UserListServiceClient>(MockBehavior.Strict); GetUserListRequest request = new GetUserListRequest { ResourceName = new UserListName("[CUSTOMER]", "[USER_LIST]").ToString(), }; UserList expectedResponse = new UserList { ResourceName = "resourceName2625949903", }; mockGrpcClient.Setup(x => x.GetUserListAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <UserList>(Task.FromResult(expectedResponse), null, null, null, null)); UserListServiceClient client = new UserListServiceClientImpl(mockGrpcClient.Object, null); UserList response = await client.GetUserListAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }