public void SendLogMessageTest() { LogAnalyticsWrapper logger = new LogAnalyticsWrapper( workspaceId: workspaceId, sharedKey: sharedKey); // after this is sent, wait a couple of minutes and then check your Log Analytics dashboard. // todo: if you want a true integration test, wait for it here, then query the logs from code and verify that the entries are there, then assert the test. logger.SendLogEntry(new TestEntity { Category = GetCategory(), TestString = $"String Test", TestBoolean = true, TestDateTime = DateTime.UtcNow, TestDouble = 2.1, TestGuid = Guid.NewGuid() }, "demolog"); }
public void SendBadEntity_Test() { LogAnalyticsWrapper logger = new LogAnalyticsWrapper( workspaceId: workspaceId, sharedKey: sharedKey); List <TestEntityBadProperties> entities = new List <TestEntityBadProperties>(); for (int ii = 0; ii < 1; ii++) { entities.Add(new TestEntityBadProperties { MyCustomProperty = new MyCustomClass { MyString = "hello world", }, TestInt = 123 }); } Assert.ThrowsException <ArgumentOutOfRangeException>(() => logger.SendLogEntries(entities, "testlog")); }
public void SendDemoEntities_Test() { LogAnalyticsWrapper logger = new LogAnalyticsWrapper( workspaceId: workspaceId, sharedKey: sharedKey); List <DemoEntity> entities = new List <DemoEntity>(); for (int ii = 0; ii < 5000; ii++) { entities.Add(new DemoEntity { Criticality = GetCriticality(), Message = "lorem ipsum dolor sit amet", SystemSource = GetSystemSource() }); } // after this is sent, wait a couple of minutes and then check your Log Analytics dashboard. // todo: if you want a true integration test, wait for it here, then query the logs from code and verify that the entries are there, then assert the test. logger.SendLogEntries(entities, "demolog"); }
public void SendDemoEvents_Test() { LogAnalyticsWrapper logger = new LogAnalyticsWrapper( workspaceId: workspaceId, sharedKey: sharedKey); // SECURITY EVENTS (Sample/Demo code only) List <TZSecurityEvent> securityEntities = new List <TZSecurityEvent>(); int securityRandom = new Random().Next(100, 12000); // amount of randomized log events to ship. for (int ii = 0; ii < securityRandom; ii++) { securityEntities.Add(new TZSecurityEvent { Severity = GetSeverity(DateTime.UtcNow.Millisecond), Source = Environment.MachineName, Message = GetRandomMessageForTest(DateTime.UtcNow.Millisecond) }); } logger.SendLogEntries(securityEntities, "tzsecurity").Wait(); // AUDIT EVENTS (Sample/Demo code only) List <TZAuditEvent> auditEntities = new List <TZAuditEvent>(); int auditRandom = new Random().Next(250, 5000); // amount of randomized log events to ship. for (int ii = 0; ii < auditRandom; ii++) { auditEntities.Add(new TZAuditEvent { Severity = GetSeverity(DateTime.UtcNow.Millisecond), Source = Environment.MachineName, Message = GetRandomMessageForTest(DateTime.UtcNow.Millisecond) }); } logger.SendLogEntries(auditEntities, "tzaudit").Wait(); }