Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit 38e5b71

Browse files
committed
Make Sln.Internal.Tests pass on localized setup
1 parent 981e3ae commit 38e5b71

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright (c) .NET Foundation and contributors. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System.Reflection;
5+
using System.Runtime.CompilerServices;
6+
7+
[assembly: InternalsVisibleTo("Microsoft.DotNet.Cli.Sln.Internal.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100039ac461fa5c82c7dd2557400c4fd4e9dcdf7ac47e3d572548c04cd4673e004916610f4ea5cbf86f2b1ca1cb824f2a7b3976afecfcf4eb72d9a899aa6786effa10c30399e6580ed848231fec48374e41b3acf8811931343fc2f73acf72dae745adbcb7063cc4b50550618383202875223fc75401351cd89c44bf9b50e7fa3796")]

test/Microsoft.DotNet.Cli.Sln.Internal.Tests/Microsoft.DotNet.Cli.Sln.Internal.Tests.cs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ public void WhenGivenASolutionWithMissingHeaderVersionItThrows(string fileConten
303303
};
304304

305305
action.ShouldThrow<InvalidSolutionFormatException>()
306-
.WithMessage($"Invalid format in line {lineNum}: File header is missing version");
306+
.WithMessage(FormatError(lineNum, LocalizableStrings.FileHeaderMissingVersionError));
307307
}
308308

309309
[Theory]
@@ -321,7 +321,7 @@ public void WhenGivenASolutionWithMissingHeaderItThrows(string fileContents)
321321
};
322322

323323
action.ShouldThrow<InvalidSolutionFormatException>()
324-
.WithMessage("Expected file header not found");
324+
.WithMessage(LocalizableStrings.FileHeaderMissingError);
325325
}
326326

327327
[Fact]
@@ -343,7 +343,7 @@ public void WhenGivenASolutionWithMultipleGlobalSectionsItThrows()
343343
};
344344

345345
action.ShouldThrow<InvalidSolutionFormatException>()
346-
.WithMessage("Invalid format in line 5: Global section specified more than once");
346+
.WithMessage(FormatError(5, LocalizableStrings.GlobalSectionMoreThanOnceError));
347347
}
348348

349349
[Fact]
@@ -362,7 +362,7 @@ public void WhenGivenASolutionWithGlobalSectionNotClosedItThrows()
362362
};
363363

364364
action.ShouldThrow<InvalidSolutionFormatException>()
365-
.WithMessage("Invalid format in line 3: Global section not closed");
365+
.WithMessage(FormatError(3, LocalizableStrings.GlobalSectionNotClosedError));
366366
}
367367

368368
[Fact]
@@ -381,7 +381,7 @@ public void WhenGivenASolutionWithProjectSectionNotClosedItThrows()
381381
};
382382

383383
action.ShouldThrow<InvalidSolutionFormatException>()
384-
.WithMessage("Invalid format in line 3: Project section not closed");
384+
.WithMessage(FormatError(3, LocalizableStrings.ProjectSectionNotClosedError));
385385
}
386386

387387
[Fact]
@@ -402,7 +402,7 @@ public void WhenGivenASolutionWithInvalidProjectSectionItThrows()
402402
};
403403

404404
action.ShouldThrow<InvalidSolutionFormatException>()
405-
.WithMessage("Invalid format in line 3: Project section is missing '(' when parsing the line starting at position 0");
405+
.WithMessage(FormatError(3, LocalizableStrings.ProjectParsingErrorFormatString, "(", 0));
406406
}
407407

408408
[Fact]
@@ -424,7 +424,7 @@ public void WhenGivenASolutionWithInvalidSectionTypeItThrows()
424424
};
425425

426426
action.ShouldThrow<InvalidSolutionFormatException>()
427-
.WithMessage("Invalid format in line 4: Invalid section type: thisIsUnknown");
427+
.WithMessage(FormatError(4, LocalizableStrings.InvalidSectionTypeError, "thisIsUnknown"));
428428
}
429429

430430
[Fact]
@@ -446,7 +446,7 @@ public void WhenGivenASolutionWithMissingSectionIdTypeItThrows()
446446
};
447447

448448
action.ShouldThrow<InvalidSolutionFormatException>()
449-
.WithMessage("Invalid format in line 4: Section id missing");
449+
.WithMessage(FormatError(4, LocalizableStrings.SectionIdMissingError));
450450
}
451451

452452
[Fact]
@@ -467,7 +467,7 @@ public void WhenGivenASolutionWithSectionNotClosedItThrows()
467467
};
468468

469469
action.ShouldThrow<InvalidSolutionFormatException>()
470-
.WithMessage("Invalid format in line 6: Closing section tag not found");
470+
.WithMessage(FormatError(6, LocalizableStrings.ClosingSectionTagNotFoundError));
471471
}
472472

473473
[Fact]
@@ -496,7 +496,15 @@ public void WhenGivenASolutionWithInvalidPropertySetItThrows()
496496
};
497497

498498
action.ShouldThrow<InvalidSolutionFormatException>()
499-
.WithMessage("Invalid format in line 7: Property set is missing '.'");
499+
.WithMessage(FormatError(7, LocalizableStrings.InvalidPropertySetFormatString, "."));
500+
}
501+
502+
private static string FormatError(int line, string format, params object[] args)
503+
{
504+
return string.Format(
505+
LocalizableStrings.ErrorMessageFormatString,
506+
line,
507+
string.Format(format, args));
500508
}
501509
}
502510
}

0 commit comments

Comments
 (0)