Skip to content

Commit b7b4f12

Browse files
committed
* Renamed MsgLevel =< MessageLevel
- Avoids en-us acronym and clarifies intent better fitting with other names.
1 parent a526ce6 commit b7b4f12

21 files changed

Lines changed: 171 additions & 171 deletions

src/Ubiquity.NET.CommandLine.UT/ArgumentExceptionReporterTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void ArgumentExceptionReporterTest( )
2323
var reporter = new ArgumentExceptionReporter(ParamExpressionName);
2424
Assert.IsNotNull( reporter );
2525
Assert.AreEqual( ParamExpressionName, reporter.ArgumentExpression );
26-
Assert.AreEqual( MsgLevel.Error, reporter.Level );
26+
Assert.AreEqual( MessageLevel.Error, reporter.Level );
2727
Assert.AreEqual( Encoding.Unicode, reporter.Encoding );
2828
}
2929

@@ -35,7 +35,7 @@ public void ReportTest( )
3535
// should not throw for a Verbose level message
3636
var verboseMsg = new DiagnosticMessage()
3737
{
38-
Level = MsgLevel.Verbose,
38+
Level = MessageLevel.Verbose,
3939
Text = VerboseMessage,
4040
};
4141

@@ -44,7 +44,7 @@ public void ReportTest( )
4444
// should not throw for an Information level message
4545
var informationMsg = new DiagnosticMessage()
4646
{
47-
Level = MsgLevel.Information,
47+
Level = MessageLevel.Information,
4848
Text = InformationMessage,
4949
};
5050

@@ -53,7 +53,7 @@ public void ReportTest( )
5353
// should not throw for a warning
5454
var warningMsg = new DiagnosticMessage()
5555
{
56-
Level = MsgLevel.Warning,
56+
Level = MessageLevel.Warning,
5757
Text = WarningMessage,
5858
};
5959

@@ -62,7 +62,7 @@ public void ReportTest( )
6262
// should only throw for an error
6363
var errorMsg = new DiagnosticMessage()
6464
{
65-
Level = MsgLevel.Error,
65+
Level = MessageLevel.Error,
6666
Text = ErrorMessage,
6767
};
6868

src/Ubiquity.NET.CommandLine.UT/CommandLineTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public void Extensions_ParseAndInvokeResult_invokes_provided_action( )
183183
bool actionCalled = false;
184184
var settings = CreateTestSettings();
185185
using var stringWriter = new StringWriter();
186-
var reporter = new TextWriterReporter( MsgLevel.Error, error: stringWriter, warning: stringWriter, information: stringWriter, verbose: stringWriter );
186+
var reporter = new TextWriterReporter( MessageLevel.Error, error: stringWriter, warning: stringWriter, information: stringWriter, verbose: stringWriter );
187187

188188
string[] testArgs = ["--option1", "value1"];
189189

@@ -288,7 +288,7 @@ public async Task Extensions_ParseAndInvokeResultAsync_invokes_provided_action(
288288
bool actionCalled = false;
289289
var settings = CreateTestSettings();
290290
using var stringWriter = new StringWriter();
291-
var reporter = new TextWriterReporter( MsgLevel.Error, error: stringWriter, warning: stringWriter, information: stringWriter, verbose: stringWriter );
291+
var reporter = new TextWriterReporter( MessageLevel.Error, error: stringWriter, warning: stringWriter, information: stringWriter, verbose: stringWriter );
292292

293293
string[] testArgs = ["--option1", "value1"];
294294

src/Ubiquity.NET.CommandLine.UT/DiagnosticMessageTests.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ public class DiagnosticMessageTests
1818
[TestMethod]
1919
public void Construction_throws_on_invalid_init( )
2020
{
21-
Assert.AreEqual( default, MsgLevel.None, "None should be the default (invalid) level" );
21+
Assert.AreEqual( default, MessageLevel.None, "None should be the default (invalid) level" );
2222

2323
Assert.ThrowsExactly<ArgumentException>(
2424
static ( ) =>
2525
{
2626
_ = new DiagnosticMessage()
2727
{
2828
Code = "Has Whitespace",
29-
Level = MsgLevel.Verbose,
29+
Level = MessageLevel.Verbose,
3030
Location = default,
3131
Origin = default,
3232
Subcategory = default,
@@ -42,7 +42,7 @@ public void Construction_throws_on_invalid_init( )
4242
_ = new DiagnosticMessage()
4343
{
4444
Code = default,
45-
Level = MsgLevel.Verbose,
45+
Level = MessageLevel.Verbose,
4646
Location = default,
4747
Origin = default,
4848
Subcategory = "Has Whitespace",
@@ -74,7 +74,7 @@ public void Construction_throws_on_invalid_init( )
7474
_ = new DiagnosticMessage()
7575
{
7676
Code = default,
77-
Level = (MsgLevel)int.MaxValue,
77+
Level = (MessageLevel)int.MaxValue,
7878
Location = default,
7979
Origin = default,
8080
Subcategory = default,
@@ -90,7 +90,7 @@ public void Construction_throws_on_invalid_init( )
9090
_ = new DiagnosticMessage()
9191
{
9292
Code = default,
93-
Level = MsgLevel.Verbose,
93+
Level = MessageLevel.Verbose,
9494
Location = default,
9595
Origin = default,
9696
Subcategory = default,
@@ -106,7 +106,7 @@ public void Construction_throws_on_invalid_init( )
106106
_ = new DiagnosticMessage()
107107
{
108108
Code = default,
109-
Level = MsgLevel.Verbose,
109+
Level = MessageLevel.Verbose,
110110
Location = default,
111111
Origin = default,
112112
Subcategory = default,
@@ -124,7 +124,7 @@ public void Construction_throws_on_invalid_init( )
124124
_ = new DiagnosticMessage()
125125
{
126126
Code = default,
127-
Level = MsgLevel.Verbose,
127+
Level = MessageLevel.Verbose,
128128
Location = default,
129129
Origin = default,
130130
Subcategory = default,
@@ -142,7 +142,7 @@ public void Initialization_sets_proerties_as_expected( )
142142
const string testCode = "CODE1";
143143
const string testSubCategory = "TestSubcategory";
144144
const string testMsg = "This is a test message";
145-
const MsgLevel testLevel = MsgLevel.Verbose;
145+
const MessageLevel testLevel = MessageLevel.Verbose;
146146

147147
var testLoc = new SourceRange(new SourcePosition(1,2,3), new SourcePosition(2,1,4));
148148
var testOrigin = new Uri("file://MyOrigin");
@@ -172,7 +172,7 @@ public void ToString_produces_Text_if_origin_is_null_or_whitespace( )
172172
var msg = new DiagnosticMessage( )
173173
{
174174
Code = default,
175-
Level = MsgLevel.Error,
175+
Level = MessageLevel.Error,
176176
Location = default,
177177
Origin = default,
178178
Subcategory = default,
@@ -190,7 +190,7 @@ public void ToString_produces_correctly_formatted_msg( )
190190
const string testCode = "CODE1";
191191
const string testSubCategory = "Subcategory";
192192
const string testMsg = "This is a test message";
193-
const MsgLevel testLevel = MsgLevel.Verbose;
193+
const MessageLevel testLevel = MessageLevel.Verbose;
194194

195195
var testLoc = new SourceRange(new SourcePosition(1,2,3), new SourcePosition(2,1,4));
196196
var testOrigin = new Uri("file://C:/MyOrigin.txt");

src/Ubiquity.NET.CommandLine.UT/DiagnosticReporterExtensionsTests.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void Report_overload_2_Tests( )
6363
// [InterpolatedStringHandlerArgument( "self", "level" )] DiagnosticReporterInterpolatedStringHandler handler
6464
//)
6565

66-
const MsgLevel testLevel = MsgLevel.Verbose;
66+
const MessageLevel testLevel = MessageLevel.Verbose;
6767
const string testValue = "[Boo]";
6868
const string expectedMsg = "This is a test value: [Boo]";
6969

@@ -84,7 +84,7 @@ public void Report_overload_2_Tests( )
8484

8585
// Validate interpolated string handler filters correctly
8686
// Messages captured must be Information+
87-
reporter = new TestReporter( MsgLevel.Information );
87+
reporter = new TestReporter( MessageLevel.Information );
8888
DiagnosticReporterExtensions.Report( reporter, testLevel, $"This is a test value: {SetValue( testValue )}" );
8989
Assert.HasCount( 0, reporter.VerboseMessages );
9090
Assert.HasCount( 0, reporter.AllMessages );
@@ -110,7 +110,7 @@ public void Report_overload_3_Tests( )
110110
// string msg
111111
//)
112112

113-
const MsgLevel testLevel = MsgLevel.Verbose;
113+
const MessageLevel testLevel = MessageLevel.Verbose;
114114
const string testMsg = "This is a test";
115115

116116
var reporter = new TestReporter(); // Default is capture all
@@ -127,7 +127,7 @@ public void Report_overload_3_Tests( )
127127
Assert.AreEqual( testMsg, msg.Text );
128128

129129
// Messages captured must be Information+
130-
reporter = new TestReporter( MsgLevel.Information );
130+
reporter = new TestReporter( MessageLevel.Information );
131131
DiagnosticReporterExtensions.Report( reporter, testLevel, testMsg );
132132
Assert.HasCount( 0, reporter.VerboseMessages );
133133
Assert.HasCount( 0, reporter.AllMessages );
@@ -143,7 +143,7 @@ public void Report_overload_4_Tests( )
143143
// [InterpolatedStringHandlerArgument( "self", "level" )] DiagnosticReporterInterpolatedStringHandler handler
144144
//)
145145

146-
const MsgLevel testLevel = MsgLevel.Verbose;
146+
const MessageLevel testLevel = MessageLevel.Verbose;
147147
var testLocation = new SourceRange(new SourcePosition(2,3,4), new SourcePosition(3,4,5));
148148
const string testValue = "[Boo]";
149149
const string expectedMsg = "This is a test value: [Boo]";
@@ -165,7 +165,7 @@ public void Report_overload_4_Tests( )
165165

166166
// Validate interpolated string handler filters correctly
167167
// Messages captured must be Information+
168-
reporter = new TestReporter( MsgLevel.Information );
168+
reporter = new TestReporter( MessageLevel.Information );
169169
DiagnosticReporterExtensions.Report( reporter, testLevel, testLocation, $"This is a test value: {SetValue( testValue )}" );
170170
Assert.HasCount( 0, reporter.VerboseMessages );
171171
Assert.HasCount( 0, reporter.AllMessages );
@@ -194,7 +194,7 @@ public void Report_overload_5_Tests( )
194194
// params object[] args
195195
// )
196196

197-
const MsgLevel testLevel = MsgLevel.Verbose;
197+
const MessageLevel testLevel = MessageLevel.Verbose;
198198
var testLocation = new SourceRange(new SourcePosition(2,3,4), new SourcePosition(3,4,5));
199199
var testOrigin = new Uri("file://foo");
200200
const string testFormat = "This is a test value: {0}";
@@ -215,7 +215,7 @@ public void Report_overload_5_Tests( )
215215
Assert.AreEqual( expectedMsg, msg.Text );
216216

217217
// Messages captured must be Information+
218-
reporter = new TestReporter( MsgLevel.Information );
218+
reporter = new TestReporter( MessageLevel.Information );
219219
DiagnosticReporterExtensions.Report( reporter, testLevel, testOrigin, testLocation, testFormat, testValue );
220220
Assert.HasCount( 0, reporter.VerboseMessages );
221221
Assert.HasCount( 0, reporter.AllMessages );
@@ -232,7 +232,7 @@ public void Report_overload6_Tests( )
232232
// [InterpolatedStringHandlerArgument( "self", "level" )] DiagnosticReporterInterpolatedStringHandler handler
233233
//)
234234

235-
const MsgLevel level = MsgLevel.Verbose;
235+
const MessageLevel level = MessageLevel.Verbose;
236236
var location = new SourceRange(new SourcePosition(2,3,4), new SourcePosition(3,4,5));
237237
var origin = new Uri("file://foo");
238238
string testValue = "[Boo]";
@@ -243,7 +243,7 @@ public void Report_overload6_Tests( )
243243
Assert.HasCount( 1, reporter.VerboseMessages );
244244
var msg = reporter.VerboseMessages[ 0 ];
245245
Assert.IsNull( msg.Code );
246-
Assert.AreEqual( MsgLevel.Verbose, msg.Level );
246+
Assert.AreEqual( MessageLevel.Verbose, msg.Level );
247247
Assert.AreEqual( location, msg.Location );
248248
Assert.AreEqual( origin, msg.Origin );
249249
Assert.IsNull( msg.Subcategory );
@@ -253,7 +253,7 @@ public void Report_overload6_Tests( )
253253

254254
// Validate interpolated string handler filters correctly
255255
// Messages captured must be Information+
256-
reporter = new TestReporter( MsgLevel.Information );
256+
reporter = new TestReporter( MessageLevel.Information );
257257
DiagnosticReporterExtensions.Report( reporter, level, $"This is a test value: {SetValue( testValue )}" );
258258
Assert.HasCount( 0, reporter.VerboseMessages );
259259
Assert.HasCount( 0, reporter.AllMessages );
@@ -287,11 +287,11 @@ public void Report_overload7_Tests( )
287287
var origin = new Uri("file://foo");
288288
string expecteMsg = $"Testing 1, 2, {1.23.ToString(CultureInfo.CurrentCulture)}";
289289

290-
DiagnosticReporterExtensions.Report( reporter, MsgLevel.Verbose, origin, location, "Testing 1, 2, {0}", 1.23 );
290+
DiagnosticReporterExtensions.Report( reporter, MessageLevel.Verbose, origin, location, "Testing 1, 2, {0}", 1.23 );
291291
Assert.HasCount( 1, reporter.VerboseMessages );
292292
var msg = reporter.VerboseMessages[ 0 ];
293293
Assert.IsNull( msg.Code );
294-
Assert.AreEqual( MsgLevel.Verbose, msg.Level );
294+
Assert.AreEqual( MessageLevel.Verbose, msg.Level );
295295
Assert.AreEqual( location, msg.Location );
296296
Assert.AreEqual( origin, msg.Origin );
297297
Assert.IsNull( msg.Subcategory );
@@ -312,7 +312,7 @@ public void Report_overload8_Tests( )
312312
// string? code = default
313313
// )
314314

315-
const MsgLevel testLevel = MsgLevel.Verbose;
315+
const MessageLevel testLevel = MessageLevel.Verbose;
316316
var testLocation = new SourceRange(new SourcePosition(2,3,4), new SourcePosition(3,4,5));
317317
var testOrigin = new Uri("file://foo");
318318
const string testMsg = "This is a test";
@@ -337,7 +337,7 @@ public void Report_overload8_Tests( )
337337
new DiagnosticMessage( )
338338
{
339339
Code = "Code0",
340-
Level = MsgLevel.Error,
340+
Level = MessageLevel.Error,
341341
Location = new Extensions.SourceRange( new SourcePosition( 2, 3, 10 ), new SourcePosition( 3, 3, 12 ) ),
342342
Origin = new System.Uri( @"file://foo" ),
343343
Subcategory = "subcategory",
@@ -346,7 +346,7 @@ public void Report_overload8_Tests( )
346346
new DiagnosticMessage( )
347347
{
348348
Code = "Code1",
349-
Level = MsgLevel.Warning,
349+
Level = MessageLevel.Warning,
350350
Location = new Extensions.SourceRange( new SourcePosition( 2, 3, 10 ), new SourcePosition( 3, 3, 12 ) ),
351351
Origin = new System.Uri( @"file://foo" ),
352352
Subcategory = "subcategory",
@@ -355,7 +355,7 @@ public void Report_overload8_Tests( )
355355
new DiagnosticMessage( )
356356
{
357357
Code = "Code2",
358-
Level = MsgLevel.Information,
358+
Level = MessageLevel.Information,
359359
Location = new Extensions.SourceRange( new SourcePosition( 2, 3, 10 ), new SourcePosition( 3, 3, 12 ) ),
360360
Origin = new System.Uri( @"file://foo" ),
361361
Subcategory = "subcategory",
@@ -364,7 +364,7 @@ public void Report_overload8_Tests( )
364364
new DiagnosticMessage( )
365365
{
366366
Code = "Code3",
367-
Level = MsgLevel.Verbose,
367+
Level = MessageLevel.Verbose,
368368
Location = new Extensions.SourceRange( new SourcePosition( 2, 3, 10 ), new SourcePosition( 3, 3, 12 ) ),
369369
Origin = new System.Uri( @"file://foo" ),
370370
Subcategory = "subcategory",

src/Ubiquity.NET.CommandLine.UT/TestReporter.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@ namespace Ubiquity.NET.CommandLine.UT
1313
internal class TestReporter
1414
: IDiagnosticReporter
1515
{
16-
public TestReporter(MsgLevel level)
16+
public TestReporter(MessageLevel level)
1717
{
1818
Level = level;
1919
}
2020

2121
public TestReporter()
22-
: this( MsgLevel.Verbose ) // Captures ALL messages (Max level)
22+
: this( MessageLevel.Verbose ) // Captures ALL messages (Max level)
2323
{
2424
}
2525

26-
public MsgLevel Level { get; }
26+
public MessageLevel Level { get; }
2727

2828
public Encoding Encoding => Encoding.Unicode;
2929

3030
/// <inheritdoc/>
3131
/// <remarks>
3232
/// This implementation will test if the <see cref="DiagnosticMessage.Level"/> of the
33-
/// message is enabled. If so, then a call is made to the virtual <see cref="ReportMessage(MsgLevel, string)"/>
33+
/// message is enabled. If so, then a call is made to the virtual <see cref="ReportMessage(MessageLevel, string)"/>
3434
/// with the results of <see cref="DiagnosticMessage.ToString()"/> as the message text.
3535
/// </remarks>
3636
public void Report( DiagnosticMessage diagnostic )
@@ -46,23 +46,23 @@ public void Report( DiagnosticMessage diagnostic )
4646
/// <summary>Gets ALL of the messages provided to this reporter</summary>
4747
public List<DiagnosticMessage> AllMessages { get; } = [];
4848

49-
/// <summary>Gets the messages with a level of <see cref="MsgLevel.None"/></summary>
49+
/// <summary>Gets the messages with a level of <see cref="MessageLevel.None"/></summary>
5050
/// <remarks>This is always an error and tests should validate this is an empty array</remarks>
51-
public ImmutableArray<DiagnosticMessage> NoneMessages => [ .. GetMessages( MsgLevel.None ) ];
51+
public ImmutableArray<DiagnosticMessage> NoneMessages => [ .. GetMessages( MessageLevel.None ) ];
5252

53-
/// <summary>Gets the messages with a level of <see cref="MsgLevel.Verbose"/></summary>
54-
public ImmutableArray<DiagnosticMessage> VerboseMessages => [ .. GetMessages(MsgLevel.Verbose) ];
53+
/// <summary>Gets the messages with a level of <see cref="MessageLevel.Verbose"/></summary>
54+
public ImmutableArray<DiagnosticMessage> VerboseMessages => [ .. GetMessages(MessageLevel.Verbose) ];
5555

56-
/// <summary>Gets the messages with a level of <see cref="MsgLevel.Information"/></summary>
57-
public ImmutableArray<DiagnosticMessage> InformationMessages => [ .. GetMessages( MsgLevel.Information ) ];
56+
/// <summary>Gets the messages with a level of <see cref="MessageLevel.Information"/></summary>
57+
public ImmutableArray<DiagnosticMessage> InformationMessages => [ .. GetMessages( MessageLevel.Information ) ];
5858

59-
/// <summary>Gets the messages with a level of <see cref="MsgLevel.Warning"/></summary>
60-
public ImmutableArray<DiagnosticMessage> WarningMessages => [ .. GetMessages( MsgLevel.Warning ) ];
59+
/// <summary>Gets the messages with a level of <see cref="MessageLevel.Warning"/></summary>
60+
public ImmutableArray<DiagnosticMessage> WarningMessages => [ .. GetMessages( MessageLevel.Warning ) ];
6161

62-
/// <summary>Gets the messages with a level of <see cref="MsgLevel.Error"/></summary>
63-
public ImmutableArray<DiagnosticMessage> ErrorMessages => [ .. GetMessages( MsgLevel.Error ) ];
62+
/// <summary>Gets the messages with a level of <see cref="MessageLevel.Error"/></summary>
63+
public ImmutableArray<DiagnosticMessage> ErrorMessages => [ .. GetMessages( MessageLevel.Error ) ];
6464

65-
private IEnumerable<DiagnosticMessage> GetMessages(MsgLevel level)
65+
private IEnumerable<DiagnosticMessage> GetMessages(MessageLevel level)
6666
{
6767
return from dm in AllMessages
6868
where dm.Level == level

0 commit comments

Comments
 (0)