| | 1 | | namespace Coverlet_Test; |
| | 2 | |
|
| | 3 | | using System.Diagnostics.CodeAnalysis; |
| | 4 | | using Microsoft.Extensions.Logging; |
| | 5 | |
|
| | 6 | | public partial class StuffMcStuffy |
| | 7 | | { |
| | 8 | | private readonly ILogger<StuffMcStuffy> _logger; |
| | 9 | |
|
| 6 | 10 | | public StuffMcStuffy(ILogger<StuffMcStuffy> logger) |
| | 11 | | { |
| 6 | 12 | | _logger = logger; |
| 6 | 13 | | } |
| | 14 | |
|
| | 15 | | [LoggerMessage( |
| | 16 | | EventId = 0, |
| | 17 | | Level = LogLevel.Information, |
| | 18 | | EventName = "testname", |
| | 19 | | Message = "tes:extraction {JobId} {ExtractionStatus} {ExtractionError}")] |
| | 20 | | private partial void RecordExtractionEvent(Guid jobId, string extractionStatus, string extractionError); |
| | 21 | |
|
| | 22 | | [ExcludeFromCodeCoverage] |
| | 23 | | public void DoThis() |
| | 24 | | { |
| | 25 | | Console.Write("do this"); |
| | 26 | | } |
| | 27 | |
|
| | 28 | | public void DoThat() |
| | 29 | | { |
| 2 | 30 | | Console.Write("do that"); |
| 2 | 31 | | } |
| | 32 | |
|
| | 33 | | public void BlahThis() |
| | 34 | | { |
| 2 | 35 | | var thislist = new List<KeyValuePair<string, object>>(); |
| 2 | 36 | | thislist.Add(new KeyValuePair<string, object>("hey", "ho")); |
| 2 | 37 | | thislist.Add(new KeyValuePair<string, object>("hey1", "ho1")); |
| 2 | 38 | | var blah = CreateLoggerDictionary(thislist); |
| 2 | 39 | | blah.ToString(); |
| 2 | 40 | | } |
| | 41 | |
|
| | 42 | | [ExcludeFromCodeCoverage] |
| | 43 | | private static Dictionary<string, string> CreateLoggerDictionary(List<KeyValuePair<string, object>> attributes) |
| | 44 | | { |
| 4 | 45 | | return attributes.ToDictionary(item => item.Key, |
| 4 | 46 | | item => item.Value.ToString() ?? string.Empty); |
| | 47 | | } |
| | 48 | | } |