public void GetHotelPerformanceView() { moq::Mock <HotelPerformanceViewService.HotelPerformanceViewServiceClient> mockGrpcClient = new moq::Mock <HotelPerformanceViewService.HotelPerformanceViewServiceClient>(moq::MockBehavior.Strict); GetHotelPerformanceViewRequest request = new GetHotelPerformanceViewRequest { ResourceNameAsHotelPerformanceViewName = gagvr::HotelPerformanceViewName.FromCustomer("[CUSTOMER]"), }; gagvr::HotelPerformanceView expectedResponse = new gagvr::HotelPerformanceView { ResourceNameAsHotelPerformanceViewName = gagvr::HotelPerformanceViewName.FromCustomer("[CUSTOMER]"), }; mockGrpcClient.Setup(x => x.GetHotelPerformanceView(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); HotelPerformanceViewServiceClient client = new HotelPerformanceViewServiceClientImpl(mockGrpcClient.Object, null); gagvr::HotelPerformanceView response = client.GetHotelPerformanceView(request.ResourceName); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task GetHotelPerformanceViewAsync() { moq::Mock <HotelPerformanceViewService.HotelPerformanceViewServiceClient> mockGrpcClient = new moq::Mock <HotelPerformanceViewService.HotelPerformanceViewServiceClient>(moq::MockBehavior.Strict); GetHotelPerformanceViewRequest request = new GetHotelPerformanceViewRequest { ResourceNameAsHotelPerformanceViewName = gagvr::HotelPerformanceViewName.FromCustomer("[CUSTOMER]"), }; gagvr::HotelPerformanceView expectedResponse = new gagvr::HotelPerformanceView { ResourceNameAsHotelPerformanceViewName = gagvr::HotelPerformanceViewName.FromCustomer("[CUSTOMER]"), }; mockGrpcClient.Setup(x => x.GetHotelPerformanceViewAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::HotelPerformanceView>(stt::Task.FromResult(expectedResponse), null, null, null, null)); HotelPerformanceViewServiceClient client = new HotelPerformanceViewServiceClientImpl(mockGrpcClient.Object, null); gagvr::HotelPerformanceView responseCallSettings = await client.GetHotelPerformanceViewAsync(request.ResourceName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); gagvr::HotelPerformanceView responseCancellationToken = await client.GetHotelPerformanceViewAsync(request.ResourceName, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }