public void GetMediaFile() { moq::Mock <MediaFileService.MediaFileServiceClient> mockGrpcClient = new moq::Mock <MediaFileService.MediaFileServiceClient>(moq::MockBehavior.Strict); GetMediaFileRequest request = new GetMediaFileRequest { ResourceNameAsMediaFileName = gagvr::MediaFileName.FromCustomerMediaFile("[CUSTOMER]", "[MEDIA_FILE]"), }; gagvr::MediaFile expectedResponse = new gagvr::MediaFile { ResourceNameAsMediaFileName = gagvr::MediaFileName.FromCustomerMediaFile("[CUSTOMER]", "[MEDIA_FILE]"), Id = -6774108720365892680L, Image = new gagvr::MediaImage(), MediaBundle = new gagvr::MediaBundle(), Type = gagve::MediaTypeEnum.Types.MediaType.DynamicImage, MimeType = gagve::MimeTypeEnum.Types.MimeType.ImagePng, SourceUrl = "source_url5da5c845", MediaFileName = gagvr::MediaFileName.FromCustomerMediaFile("[CUSTOMER]", "[MEDIA_FILE]"), FileSize = 2493931593823374883L, Audio = new gagvr::MediaAudio(), Video = new gagvr::MediaVideo(), }; mockGrpcClient.Setup(x => x.GetMediaFile(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); MediaFileServiceClient client = new MediaFileServiceClientImpl(mockGrpcClient.Object, null); gagvr::MediaFile response = client.GetMediaFile(request.ResourceName); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task GetMediaFileRequestObjectAsync() { moq::Mock <MediaFileService.MediaFileServiceClient> mockGrpcClient = new moq::Mock <MediaFileService.MediaFileServiceClient>(moq::MockBehavior.Strict); GetMediaFileRequest request = new GetMediaFileRequest { ResourceNameAsMediaFileName = gagvr::MediaFileName.FromCustomerMediaFile("[CUSTOMER]", "[MEDIA_FILE]"), }; gagvr::MediaFile expectedResponse = new gagvr::MediaFile { ResourceNameAsMediaFileName = gagvr::MediaFileName.FromCustomerMediaFile("[CUSTOMER]", "[MEDIA_FILE]"), Id = -6774108720365892680L, Image = new gagvr::MediaImage(), MediaBundle = new gagvr::MediaBundle(), Type = gagve::MediaTypeEnum.Types.MediaType.DynamicImage, MimeType = gagve::MimeTypeEnum.Types.MimeType.ImagePng, SourceUrl = "source_url5da5c845", MediaFileName = gagvr::MediaFileName.FromCustomerMediaFile("[CUSTOMER]", "[MEDIA_FILE]"), FileSize = 2493931593823374883L, Audio = new gagvr::MediaAudio(), Video = new gagvr::MediaVideo(), }; mockGrpcClient.Setup(x => x.GetMediaFileAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::MediaFile>(stt::Task.FromResult(expectedResponse), null, null, null, null)); MediaFileServiceClient client = new MediaFileServiceClientImpl(mockGrpcClient.Object, null); gagvr::MediaFile responseCallSettings = await client.GetMediaFileAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); gagvr::MediaFile responseCancellationToken = await client.GetMediaFileAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }