public void CreateTopicResourceNames() { moq::Mock <Publisher.PublisherClient> mockGrpcClient = new moq::Mock <Publisher.PublisherClient>(moq::MockBehavior.Strict); Topic request = new Topic { TopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"), }; Topic expectedResponse = new Topic { TopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"), Labels = { { "key8a0b6e3c", "value60c16320" }, }, MessageStoragePolicy = new MessageStoragePolicy(), KmsKeyName = "kms_key_name06bd122b", SchemaSettings = new SchemaSettings(), SatisfiesPzs = false, MessageRetentionDuration = new wkt::Duration(), }; mockGrpcClient.Setup(x => x.CreateTopic(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); PublisherServiceApiClient client = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null); Topic response = client.CreateTopic(request.TopicName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task CreateTopicResourceNamesAsync() { moq::Mock <Publisher.PublisherClient> mockGrpcClient = new moq::Mock <Publisher.PublisherClient>(moq::MockBehavior.Strict); Topic request = new Topic { TopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"), }; Topic expectedResponse = new Topic { TopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"), Labels = { { "key8a0b6e3c", "value60c16320" }, }, MessageStoragePolicy = new MessageStoragePolicy(), KmsKeyName = "kms_key_name06bd122b", SchemaSettings = new SchemaSettings(), SatisfiesPzs = false, MessageRetentionDuration = new wkt::Duration(), }; mockGrpcClient.Setup(x => x.CreateTopicAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Topic>(stt::Task.FromResult(expectedResponse), null, null, null, null)); PublisherServiceApiClient client = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null); Topic responseCallSettings = await client.CreateTopicAsync(request.TopicName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Topic responseCancellationToken = await client.CreateTopicAsync(request.TopicName, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void PublishResourceNames() { moq::Mock <Publisher.PublisherClient> mockGrpcClient = new moq::Mock <Publisher.PublisherClient>(moq::MockBehavior.Strict); PublishRequest request = new PublishRequest { TopicAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"), Messages = { new PubsubMessage(), }, }; PublishResponse expectedResponse = new PublishResponse { MessageIds = { "message_idsbfb136bc", }, }; mockGrpcClient.Setup(x => x.Publish(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); PublisherServiceApiClient client = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null); PublishResponse response = client.Publish(request.TopicAsTopicName, request.Messages); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task PublishResourceNamesAsync() { moq::Mock <Publisher.PublisherClient> mockGrpcClient = new moq::Mock <Publisher.PublisherClient>(moq::MockBehavior.Strict); PublishRequest request = new PublishRequest { TopicAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"), Messages = { new PubsubMessage(), }, }; PublishResponse expectedResponse = new PublishResponse { MessageIds = { "message_idsbfb136bc", }, }; mockGrpcClient.Setup(x => x.PublishAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <PublishResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); PublisherServiceApiClient client = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null); PublishResponse responseCallSettings = await client.PublishAsync(request.TopicAsTopicName, request.Messages, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); PublishResponse responseCancellationToken = await client.PublishAsync(request.TopicAsTopicName, request.Messages, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetTopic() { moq::Mock <Publisher.PublisherClient> mockGrpcClient = new moq::Mock <Publisher.PublisherClient>(moq::MockBehavior.Strict); GetTopicRequest request = new GetTopicRequest { TopicAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"), }; Topic expectedResponse = new Topic { TopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"), Labels = { { "key8a0b6e3c", "value60c16320" }, }, MessageStoragePolicy = new MessageStoragePolicy(), KmsKeyName = "kms_key_name06bd122b", }; mockGrpcClient.Setup(x => x.GetTopic(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); PublisherServiceApiClient client = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null); Topic response = client.GetTopic(request.Topic); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task CreateTopicAsync() { Mock <Publisher.PublisherClient> mockGrpcClient = new Mock <Publisher.PublisherClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateIAMPolicyClient()) .Returns(new Mock <IAMPolicy.IAMPolicyClient>().Object); Topic expectedRequest = new Topic { TopicName = new TopicName("[PROJECT]", "[TOPIC]"), }; Topic expectedResponse = new Topic { TopicName = new TopicName("[PROJECT]", "[TOPIC]"), KmsKeyName = "kmsKeyName2094986649", }; mockGrpcClient.Setup(x => x.CreateTopicAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <Topic>(Task.FromResult(expectedResponse), null, null, null, null)); PublisherServiceApiClient client = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null); TopicName name = new TopicName("[PROJECT]", "[TOPIC]"); Topic response = await client.CreateTopicAsync(name); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void GetTopic() { Mock <Publisher.PublisherClient> mockGrpcClient = new Mock <Publisher.PublisherClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateIAMPolicyClient()) .Returns(new Mock <IAMPolicy.IAMPolicyClient>().Object); GetTopicRequest expectedRequest = new GetTopicRequest { TopicAsTopicName = new TopicName("[PROJECT]", "[TOPIC]"), }; Topic expectedResponse = new Topic { TopicName = new TopicName("[PROJECT]", "[TOPIC]"), KmsKeyName = "kmsKeyName2094986649", }; mockGrpcClient.Setup(x => x.GetTopic(expectedRequest, It.IsAny <CallOptions>())) .Returns(expectedResponse); PublisherServiceApiClient client = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null); TopicName topic = new TopicName("[PROJECT]", "[TOPIC]"); Topic response = client.GetTopic(topic); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task PublishAsync2() { Mock <Publisher.PublisherClient> mockGrpcClient = new Mock <Publisher.PublisherClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateIAMPolicyClient()) .Returns(new Mock <IAMPolicy.IAMPolicyClient>().Object); PublishRequest request = new PublishRequest { TopicAsTopicName = new TopicName("[PROJECT]", "[TOPIC]"), Messages = { new PubsubMessage { Data = ByteString.CopyFromUtf8("-86"), }, }, }; PublishResponse expectedResponse = new PublishResponse { MessageIds = { "messageIdsElement-744837059", }, }; mockGrpcClient.Setup(x => x.PublishAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <PublishResponse>(Task.FromResult(expectedResponse), null, null, null, null)); PublisherServiceApiClient client = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null); PublishResponse response = await client.PublishAsync(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void DeleteTopicResourceNames() { moq::Mock <Publisher.PublisherClient> mockGrpcClient = new moq::Mock <Publisher.PublisherClient>(moq::MockBehavior.Strict); DeleteTopicRequest request = new DeleteTopicRequest { TopicAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeleteTopic(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); PublisherServiceApiClient client = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null); client.DeleteTopic(request.TopicAsTopicName); mockGrpcClient.VerifyAll(); }
public void DetachSubscriptionRequestObject() { moq::Mock <Publisher.PublisherClient> mockGrpcClient = new moq::Mock <Publisher.PublisherClient>(moq::MockBehavior.Strict); DetachSubscriptionRequest request = new DetachSubscriptionRequest { SubscriptionAsSubscriptionName = SubscriptionName.FromProjectSubscription("[PROJECT]", "[SUBSCRIPTION]"), }; DetachSubscriptionResponse expectedResponse = new DetachSubscriptionResponse { }; mockGrpcClient.Setup(x => x.DetachSubscription(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); PublisherServiceApiClient client = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null); DetachSubscriptionResponse response = client.DetachSubscription(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task DeleteTopicResourceNamesAsync() { moq::Mock <Publisher.PublisherClient> mockGrpcClient = new moq::Mock <Publisher.PublisherClient>(moq::MockBehavior.Strict); DeleteTopicRequest request = new DeleteTopicRequest { TopicAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeleteTopicAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null)); PublisherServiceApiClient client = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null); await client.DeleteTopicAsync(request.TopicAsTopicName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); await client.DeleteTopicAsync(request.TopicAsTopicName, st::CancellationToken.None); mockGrpcClient.VerifyAll(); }
public async Task DeleteTopicAsync2() { Mock <Publisher.PublisherClient> mockGrpcClient = new Mock <Publisher.PublisherClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateIAMPolicyClient()) .Returns(new Mock <IAMPolicy.IAMPolicyClient>().Object); DeleteTopicRequest request = new DeleteTopicRequest { TopicAsTopicName = new TopicName("[PROJECT]", "[TOPIC]"), }; Empty expectedResponse = new Empty(); mockGrpcClient.Setup(x => x.DeleteTopicAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <Empty>(Task.FromResult(expectedResponse), null, null, null, null)); PublisherServiceApiClient client = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null); await client.DeleteTopicAsync(request); mockGrpcClient.VerifyAll(); }
public void DeleteTopic2() { Mock <Publisher.PublisherClient> mockGrpcClient = new Mock <Publisher.PublisherClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateIAMPolicyClient()) .Returns(new Mock <IAMPolicy.IAMPolicyClient>().Object); DeleteTopicRequest request = new DeleteTopicRequest { TopicAsTopicName = new TopicName("[PROJECT]", "[TOPIC]"), }; Empty expectedResponse = new Empty(); mockGrpcClient.Setup(x => x.DeleteTopic(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); PublisherServiceApiClient client = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null); client.DeleteTopic(request); mockGrpcClient.VerifyAll(); }
public async stt::Task DetachSubscriptionRequestObjectAsync() { moq::Mock <Publisher.PublisherClient> mockGrpcClient = new moq::Mock <Publisher.PublisherClient>(moq::MockBehavior.Strict); DetachSubscriptionRequest request = new DetachSubscriptionRequest { SubscriptionAsSubscriptionName = SubscriptionName.FromProjectSubscription("[PROJECT]", "[SUBSCRIPTION]"), }; DetachSubscriptionResponse expectedResponse = new DetachSubscriptionResponse { }; mockGrpcClient.Setup(x => x.DetachSubscriptionAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <DetachSubscriptionResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); PublisherServiceApiClient client = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null); DetachSubscriptionResponse responseCallSettings = await client.DetachSubscriptionAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); DetachSubscriptionResponse responseCancellationToken = await client.DetachSubscriptionAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void Publish() { Mock <Publisher.PublisherClient> mockGrpcClient = new Mock <Publisher.PublisherClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateIAMPolicyClient()) .Returns(new Mock <IAMPolicy.IAMPolicyClient>().Object); PublishRequest expectedRequest = new PublishRequest { TopicAsTopicName = new TopicName("[PROJECT]", "[TOPIC]"), Messages = { new PubsubMessage { Data = ByteString.CopyFromUtf8("-86"), }, }, }; PublishResponse expectedResponse = new PublishResponse { MessageIds = { "messageIdsElement-744837059", }, }; mockGrpcClient.Setup(x => x.Publish(expectedRequest, It.IsAny <CallOptions>())) .Returns(expectedResponse); PublisherServiceApiClient client = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null); TopicName topic = new TopicName("[PROJECT]", "[TOPIC]"); IEnumerable <PubsubMessage> messages = new[] { new PubsubMessage { Data = ByteString.CopyFromUtf8("-86"), }, }; PublishResponse response = client.Publish(topic, messages); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void UpdateTopic() { Mock <Publisher.PublisherClient> mockGrpcClient = new Mock <Publisher.PublisherClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateIAMPolicyClient()) .Returns(new Mock <IAMPolicy.IAMPolicyClient>().Object); UpdateTopicRequest request = new UpdateTopicRequest { Topic = new Topic(), UpdateMask = new FieldMask(), }; Topic expectedResponse = new Topic { TopicName = new TopicName("[PROJECT]", "[TOPIC]"), }; mockGrpcClient.Setup(x => x.UpdateTopic(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); PublisherServiceApiClient client = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null); Topic response = client.UpdateTopic(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }