public void AzureEventHubLogWriter_WriteBatch_WritesToEventHub()
        {
            var writer = new AzureEventHubLogWriter(ConnectionString, null);

            int itemsInBatch = 50;
            var batch        = new List <LogEvent>(itemsInBatch);

            for (int cnt = 0; cnt < itemsInBatch; cnt++)
            {
                batch.Add(new LogEvent()
                {
                    DateTime   = DateTime.Now,
                    EventName  = "Test event " + cnt.ToString(),
                    EventType  = LogEventType.SystemEvent,
                    Source     = "Test Source",
                    Properties = new Dictionary <string, object>()
                    {
                        { "Test Prop", "Test Value" }
                    }
                });
            }
            var sw = new System.Diagnostics.Stopwatch();

            sw.Start();
            writer.WriteBatch(batch);
            sw.Stop();
            System.Diagnostics.Trace.WriteLine($"Writing {itemsInBatch} log events to event hub took {sw.Elapsed.ToString()}");
        }
        public void AzureEventHubLogWriter_Write_WritesToEventHub()
        {
            var writer = new AzureEventHubLogWriter(ConnectionString, null);

            writer.Write(new LogEvent()
            {
                DateTime   = DateTime.Now,
                EventName  = "Test event",
                EventType  = LogEventType.SystemEvent,
                Source     = "Test Source",
                Properties = new Dictionary <string, object>()
                {
                    { "Test Prop", "Test Value" }
                }
            });
        }
        public void AzureEventHubLogWriter_WriteBatch_WritesOverSizedBatch()
        {
            var writer = new AzureEventHubLogWriter(ConnectionString, null, false);

            int itemsInBatch = 2;
            var batch        = new List <LogEvent>(itemsInBatch);

            for (int cnt = 0; cnt < itemsInBatch; cnt++)
            {
                batch.Add(new LogEvent()
                {
                    DateTime   = DateTime.Now,
                    EventName  = new string('A', 250 * 1024),
                    EventType  = LogEventType.SystemEvent,
                    Source     = "Test Source",
                    Properties = new Dictionary <string, object>()
                    {
                        { "Test Prop", "Test Value" }
                    }
                });
            }
            writer.WriteBatch(batch);
        }
 public void AzureEventHubLogWriter_Constructor_ConstructsOkWithNullFormatter()
 {
     var writer = new AzureEventHubLogWriter(ConnectionString, null);
 }
 public void AzureEventHubLogWriter_Constructor_ThrowsOnWhitespaceConnectionString()
 {
     var writer = new AzureEventHubLogWriter("  ", Formatters.JsonLogEventFormatter.DefaultInstance);
 }
 public void AzureEventHubLogWriter_Constructor_ThrowsOnEmptyConnectionString()
 {
     var writer = new AzureEventHubLogWriter(String.Empty);
 }