public void TryParseTest_LineIsValid_ReturnTrue() { const string line = "2019-08-17 15:56:00,282 INFO - admin's role: Administrator"; bool result = LogModelParser.TryParse(line, out var logModel); Assert.True(result); }
public void TryParseTest_LineIsInvalid_ReturnFalse() { const string line = " admin's role: Administrator - INFO -"; bool result = LogModelParser.TryParse(line, out var logModel); Assert.False(result); }
public override async Task OnLoadedAsync() { string logText = await SafelyReadTextFromLogAsync(); if (string.IsNullOrWhiteSpace(logText)) { return; } LogModels.Clear(); foreach (string line in SplitByNewline(logText)) { if (LogModelParser.TryParse(line, out var logModel)) { LogModels.Add(logModel); } } }