public async stt::Task GetVideoAsync() { moq::Mock <VideoService.VideoServiceClient> mockGrpcClient = new moq::Mock <VideoService.VideoServiceClient>(moq::MockBehavior.Strict); GetVideoRequest request = new GetVideoRequest { ResourceNameAsVideoName = gagvr::VideoName.FromCustomerVideo("[CUSTOMER]", "[VIDEO]"), }; gagvr::Video expectedResponse = new gagvr::Video { ResourceNameAsVideoName = gagvr::VideoName.FromCustomerVideo("[CUSTOMER]", "[VIDEO]"), Id = "id74b70bb8", ChannelId = "channel_id856ceb72", DurationMillis = 4964327688054496886L, Title = "title17dbd3d5", }; mockGrpcClient.Setup(x => x.GetVideoAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::Video>(stt::Task.FromResult(expectedResponse), null, null, null, null)); VideoServiceClient client = new VideoServiceClientImpl(mockGrpcClient.Object, null); gagvr::Video responseCallSettings = await client.GetVideoAsync(request.ResourceName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); gagvr::Video responseCancellationToken = await client.GetVideoAsync(request.ResourceName, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetVideo2() { Mock <VideoService.VideoServiceClient> mockGrpcClient = new Mock <VideoService.VideoServiceClient>(MockBehavior.Strict); GetVideoRequest request = new GetVideoRequest { ResourceName = new VideoName("[CUSTOMER]", "[VIDEO]").ToString(), }; Video expectedResponse = new Video { ResourceName = "resourceName2625949903", }; mockGrpcClient.Setup(x => x.GetVideo(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); VideoServiceClient client = new VideoServiceClientImpl(mockGrpcClient.Object, null); Video response = client.GetVideo(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task GetVideoAsync2() { Mock <VideoService.VideoServiceClient> mockGrpcClient = new Mock <VideoService.VideoServiceClient>(MockBehavior.Strict); GetVideoRequest request = new GetVideoRequest { ResourceName = new VideoName("[CUSTOMER]", "[VIDEO]").ToString(), }; Video expectedResponse = new Video { ResourceName = "resourceName2625949903", }; mockGrpcClient.Setup(x => x.GetVideoAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <Video>(Task.FromResult(expectedResponse), null, null, null, null)); VideoServiceClient client = new VideoServiceClientImpl(mockGrpcClient.Object, null); Video response = await client.GetVideoAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void GetVideo() { moq::Mock <VideoService.VideoServiceClient> mockGrpcClient = new moq::Mock <VideoService.VideoServiceClient>(moq::MockBehavior.Strict); GetVideoRequest request = new GetVideoRequest { ResourceNameAsVideoName = gagvr::VideoName.FromCustomerVideo("[CUSTOMER]", "[VIDEO]"), }; gagvr::Video expectedResponse = new gagvr::Video { ResourceNameAsVideoName = gagvr::VideoName.FromCustomerVideo("[CUSTOMER]", "[VIDEO]"), Id = "id74b70bb8", ChannelId = "channel_id856ceb72", DurationMillis = 4964327688054496886L, Title = "title17dbd3d5", }; mockGrpcClient.Setup(x => x.GetVideo(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); VideoServiceClient client = new VideoServiceClientImpl(mockGrpcClient.Object, null); gagvr::Video response = client.GetVideo(request.ResourceName); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }