public async stt::Task ComputeThreatListDiffRequestObjectAsync() { moq::Mock <WebRiskServiceV1Beta1.WebRiskServiceV1Beta1Client> mockGrpcClient = new moq::Mock <WebRiskServiceV1Beta1.WebRiskServiceV1Beta1Client>(moq::MockBehavior.Strict); ComputeThreatListDiffRequest request = new ComputeThreatListDiffRequest { ThreatType = ThreatType.Malware, VersionToken = proto::ByteString.CopyFromUtf8("version_token1850f275"), Constraints = new ComputeThreatListDiffRequest.Types.Constraints(), }; ComputeThreatListDiffResponse expectedResponse = new ComputeThreatListDiffResponse { RecommendedNextDiff = new wkt::Timestamp(), ResponseType = ComputeThreatListDiffResponse.Types.ResponseType.Diff, Additions = new ThreatEntryAdditions(), Removals = new ThreatEntryRemovals(), NewVersionToken = proto::ByteString.CopyFromUtf8("new_version_tokenc8bdd85d"), Checksum = new ComputeThreatListDiffResponse.Types.Checksum(), }; mockGrpcClient.Setup(x => x.ComputeThreatListDiffAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <ComputeThreatListDiffResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); WebRiskServiceV1Beta1Client client = new WebRiskServiceV1Beta1ClientImpl(mockGrpcClient.Object, null); ComputeThreatListDiffResponse responseCallSettings = await client.ComputeThreatListDiffAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); ComputeThreatListDiffResponse responseCancellationToken = await client.ComputeThreatListDiffAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task ComputeThreatListDiffAsync() { Mock <WebRiskServiceV1Beta1.WebRiskServiceV1Beta1Client> mockGrpcClient = new Mock <WebRiskServiceV1Beta1.WebRiskServiceV1Beta1Client>(MockBehavior.Strict); ComputeThreatListDiffRequest expectedRequest = new ComputeThreatListDiffRequest { ThreatType = ThreatType.Unspecified, VersionToken = ByteString.CopyFromUtf8("-46"), Constraints = new ComputeThreatListDiffRequest.Types.Constraints(), }; ComputeThreatListDiffResponse expectedResponse = new ComputeThreatListDiffResponse { NewVersionToken = ByteString.CopyFromUtf8("115"), }; mockGrpcClient.Setup(x => x.ComputeThreatListDiffAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <ComputeThreatListDiffResponse>(Task.FromResult(expectedResponse), null, null, null, null)); WebRiskServiceV1Beta1Client client = new WebRiskServiceV1Beta1ClientImpl(mockGrpcClient.Object, null); ThreatType threatType = ThreatType.Unspecified; ByteString versionToken = ByteString.CopyFromUtf8("-46"); ComputeThreatListDiffRequest.Types.Constraints constraints = new ComputeThreatListDiffRequest.Types.Constraints(); ComputeThreatListDiffResponse response = await client.ComputeThreatListDiffAsync(threatType, versionToken, constraints); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }