public void Receive_EmptyEnumerableIgnored()
        {
            var mockClient = new Mock <LoggingServiceV2Client>();
            var consumer   = new GrpcLogConsumer(mockClient.Object);

            consumer.Receive(new LogEntry[] { });
            mockClient.Verify(c => c.WriteLogEntries(null, null, LogLabels.AgentLabel,
                                                     It.IsAny <IEnumerable <LogEntry> >(), null), Times.Never());
        }
        public async Task ReceiveAsync_EmptyEnumerableIgnored()
        {
            var mockClient = new Mock <LoggingServiceV2Client>();
            var consumer   = new GrpcLogConsumer(mockClient.Object);

            await consumer.ReceiveAsync(new LogEntry[] { }, CancellationToken.None);

            mockClient.Verify(c => c.WriteLogEntriesAsync(null, null, LogLabels.AgentLabel,
                                                          It.IsAny <IEnumerable <LogEntry> >(), CancellationToken.None), Times.Never());
        }
        public void Receive()
        {
            var logs       = new[] { new LogEntry(), new LogEntry() };
            var mockClient = new Mock <LoggingServiceV2Client>();

            mockClient.Setup(c => c.WriteLogEntries(null, null, LogLabels.AgentLabel, logs, null));
            var consumer = new GrpcLogConsumer(mockClient.Object);

            consumer.Receive(logs);
            mockClient.VerifyAll();
        }
        public void Receive()
        {
            var logs       = new[] { new LogEntry(), new LogEntry() };
            var mockClient = new Mock <LoggingServiceV2Client>();

            mockClient.Setup(c => c.WriteLogEntries(
                                 null, null, It.IsAny <IDictionary <string, string> >(), logs, null));
            var consumer = new GrpcLogConsumer(mockClient.Object);

            consumer.Receive(logs);
            mockClient.VerifyAll();
        }
        public async Task ReceiveAsync()
        {
            var logs       = new[] { new LogEntry(), new LogEntry() };
            var mockClient = new Mock <LoggingServiceV2Client>();
            var task       = Task.FromResult(new WriteLogEntriesRequest());

            mockClient.Setup(c => c.WriteLogEntriesAsync(
                                 null, null, LogLabels.AgentLabel, logs, CancellationToken.None))
            .Returns(Task.FromResult(new WriteLogEntriesResponse()));
            var consumer = new GrpcLogConsumer(mockClient.Object);

            await consumer.ReceiveAsync(logs, CancellationToken.None);

            mockClient.VerifyAll();
        }