public async stt::Task GetPublisherAccountRequestObjectAsync() { moq::Mock <AdMobApi.AdMobApiClient> mockGrpcClient = new moq::Mock <AdMobApi.AdMobApiClient>(moq::MockBehavior.Strict); GetPublisherAccountRequest request = new GetPublisherAccountRequest { Name = "name1c9368b0", }; PublisherAccount expectedResponse = new PublisherAccount { PublisherAccountName = PublisherAccountName.FromPublisher("[PUBLISHER]"), PublisherId = "publisher_ideacb0426", ReportingTimeZone = "reporting_time_zonee4c984d5", CurrencyCode = "currency_code7f81e352", }; mockGrpcClient.Setup(x => x.GetPublisherAccountAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <PublisherAccount>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AdMobApiClient client = new AdMobApiClientImpl(mockGrpcClient.Object, null); PublisherAccount responseCallSettings = await client.GetPublisherAccountAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); PublisherAccount responseCancellationToken = await client.GetPublisherAccountAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetPublisherAccount() { moq::Mock <AdMobApi.AdMobApiClient> mockGrpcClient = new moq::Mock <AdMobApi.AdMobApiClient>(moq::MockBehavior.Strict); GetPublisherAccountRequest request = new GetPublisherAccountRequest { Name = "name1c9368b0", }; PublisherAccount expectedResponse = new PublisherAccount { PublisherAccountName = PublisherAccountName.FromPublisher("[PUBLISHER]"), PublisherId = "publisher_ideacb0426", ReportingTimeZone = "reporting_time_zonee4c984d5", CurrencyCode = "currency_code7f81e352", }; mockGrpcClient.Setup(x => x.GetPublisherAccount(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); AdMobApiClient client = new AdMobApiClientImpl(mockGrpcClient.Object, null); PublisherAccount response = client.GetPublisherAccount(request.Name); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }