public void GetUserLocationView() { moq::Mock <UserLocationViewService.UserLocationViewServiceClient> mockGrpcClient = new moq::Mock <UserLocationViewService.UserLocationViewServiceClient>(moq::MockBehavior.Strict); GetUserLocationViewRequest request = new GetUserLocationViewRequest { ResourceNameAsUserLocationViewName = gagvr::UserLocationViewName.FromCustomerCountryCriterionIsTargetingLocation("[CUSTOMER_ID]", "[COUNTRY_CRITERION_ID]", "[IS_TARGETING_LOCATION]"), }; gagvr::UserLocationView expectedResponse = new gagvr::UserLocationView { ResourceNameAsUserLocationViewName = gagvr::UserLocationViewName.FromCustomerCountryCriterionIsTargetingLocation("[CUSTOMER_ID]", "[COUNTRY_CRITERION_ID]", "[IS_TARGETING_LOCATION]"), CountryCriterionId = 7801114990940938649L, TargetingLocation = false, }; mockGrpcClient.Setup(x => x.GetUserLocationView(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); UserLocationViewServiceClient client = new UserLocationViewServiceClientImpl(mockGrpcClient.Object, null); gagvr::UserLocationView response = client.GetUserLocationView(request.ResourceName); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void GetUserLocationViewRequestObject() { moq::Mock <UserLocationViewService.UserLocationViewServiceClient> mockGrpcClient = new moq::Mock <UserLocationViewService.UserLocationViewServiceClient>(moq::MockBehavior.Strict); GetUserLocationViewRequest request = new GetUserLocationViewRequest { ResourceNameAsUserLocationViewName = gagvr::UserLocationViewName.FromCustomerUserLocationView("[CUSTOMER]", "[USER_LOCATION_VIEW]"), }; gagvr::UserLocationView expectedResponse = new gagvr::UserLocationView { ResourceNameAsUserLocationViewName = gagvr::UserLocationViewName.FromCustomerUserLocationView("[CUSTOMER]", "[USER_LOCATION_VIEW]"), CountryCriterionId = 7801114990940938649L, TargetingLocation = false, }; mockGrpcClient.Setup(x => x.GetUserLocationView(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); UserLocationViewServiceClient client = new UserLocationViewServiceClientImpl(mockGrpcClient.Object, null); gagvr::UserLocationView response = client.GetUserLocationView(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task GetUserLocationViewRequestObjectAsync() { moq::Mock <UserLocationViewService.UserLocationViewServiceClient> mockGrpcClient = new moq::Mock <UserLocationViewService.UserLocationViewServiceClient>(moq::MockBehavior.Strict); GetUserLocationViewRequest request = new GetUserLocationViewRequest { ResourceNameAsUserLocationViewName = gagvr::UserLocationViewName.FromCustomerCountryCriterionIsTargetingLocation("[CUSTOMER_ID]", "[COUNTRY_CRITERION_ID]", "[IS_TARGETING_LOCATION]"), }; gagvr::UserLocationView expectedResponse = new gagvr::UserLocationView { ResourceNameAsUserLocationViewName = gagvr::UserLocationViewName.FromCustomerCountryCriterionIsTargetingLocation("[CUSTOMER_ID]", "[COUNTRY_CRITERION_ID]", "[IS_TARGETING_LOCATION]"), CountryCriterionId = 7801114990940938649L, TargetingLocation = false, }; mockGrpcClient.Setup(x => x.GetUserLocationViewAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::UserLocationView>(stt::Task.FromResult(expectedResponse), null, null, null, null)); UserLocationViewServiceClient client = new UserLocationViewServiceClientImpl(mockGrpcClient.Object, null); gagvr::UserLocationView responseCallSettings = await client.GetUserLocationViewAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); gagvr::UserLocationView responseCancellationToken = await client.GetUserLocationViewAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }