Skip to content

Commit 950d2e9

Browse files
SIkeberynowak
authored andcommitted
Fix locale sensitive unit tests
1 parent dcfb63a commit 950d2e9

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

test/Microsoft.AspNetCore.Routing.Tests/Template/TemplateParserTests.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ public void Parse_RegularExpressions(string template, string constraint)
502502
[InlineData(@"{p1:regex(([}])\w+}")] // Not escaped }
503503
[InlineData(@"{p1:regex(^\d{{3}}-\d{{3}}-\d{{4}$)}")] // Not escaped }
504504
[InlineData(@"{p1:regex(abc)")]
505+
[ReplaceCulture]
505506
public void Parse_RegularExpressions_Invalid(string template)
506507
{
507508
// Act and Assert
@@ -514,6 +515,7 @@ public void Parse_RegularExpressions_Invalid(string template)
514515
[Theory]
515516
[InlineData(@"{p1:regex(^\d{{3}}-\d{{3}}-\d{{{4}}$)}")] // extra {
516517
[InlineData(@"{p1:regex(^\d{{3}}-\d{{3}}-\d{4}}$)}")] // Not escaped {
518+
[ReplaceCulture]
517519
public void Parse_RegularExpressions_Unescaped(string template)
518520
{
519521
// Act and Assert
@@ -529,6 +531,7 @@ public void Parse_RegularExpressions_Unescaped(string template)
529531
[InlineData("{p1?}{p2?}", "p1", "{p2?}")]
530532
[InlineData("{p1}.{p2?})", "p2", ")")]
531533
[InlineData("{foorb?}-bar-{z}", "foorb", "-bar-")]
534+
[ReplaceCulture]
532535
public void Parse_ComplexSegment_OptionalParameter_NotTheLastPart(
533536
string template,
534537
string parameter,
@@ -548,6 +551,7 @@ public void Parse_ComplexSegment_OptionalParameter_NotTheLastPart(
548551
[InlineData("..{p2?}", "..")]
549552
[InlineData("{p1}.abc.{p2?}", ".abc.")]
550553
[InlineData("{p1}{p2?}", "{p1}")]
554+
[ReplaceCulture]
551555
public void Parse_ComplexSegment_OptionalParametersSeperatedByPeriod_Invalid(string template, string parameter)
552556
{
553557
// Act and Assert
@@ -559,6 +563,7 @@ public void Parse_ComplexSegment_OptionalParametersSeperatedByPeriod_Invalid(str
559563
}
560564

561565
[Fact]
566+
[ReplaceCulture]
562567
public void InvalidTemplate_WithRepeatedParameter()
563568
{
564569
var ex = ExceptionAssert.Throws<ArgumentException>(
@@ -574,6 +579,7 @@ public void InvalidTemplate_WithRepeatedParameter()
574579
[InlineData("{{p1}")]
575580
[InlineData("{p1}}")]
576581
[InlineData("p1}}p2{")]
582+
[ReplaceCulture]
577583
public void InvalidTemplate_WithMismatchedBraces(string template)
578584
{
579585
ExceptionAssert.Throws<ArgumentException>(
@@ -584,6 +590,7 @@ public void InvalidTemplate_WithMismatchedBraces(string template)
584590
}
585591

586592
[Fact]
593+
[ReplaceCulture]
587594
public void InvalidTemplate_CannotHaveCatchAllInMultiSegment()
588595
{
589596
ExceptionAssert.Throws<ArgumentException>(
@@ -594,6 +601,7 @@ public void InvalidTemplate_CannotHaveCatchAllInMultiSegment()
594601
}
595602

596603
[Fact]
604+
[ReplaceCulture]
597605
public void InvalidTemplate_CannotHaveMoreThanOneCatchAll()
598606
{
599607
ExceptionAssert.Throws<ArgumentException>(
@@ -604,6 +612,7 @@ public void InvalidTemplate_CannotHaveMoreThanOneCatchAll()
604612
}
605613

606614
[Fact]
615+
[ReplaceCulture]
607616
public void InvalidTemplate_CannotHaveMoreThanOneCatchAllInMultiSegment()
608617
{
609618
ExceptionAssert.Throws<ArgumentException>(
@@ -614,6 +623,7 @@ public void InvalidTemplate_CannotHaveMoreThanOneCatchAllInMultiSegment()
614623
}
615624

616625
[Fact]
626+
[ReplaceCulture]
617627
public void InvalidTemplate_CannotHaveCatchAllWithNoName()
618628
{
619629
ExceptionAssert.Throws<ArgumentException>(
@@ -635,6 +645,7 @@ public void InvalidTemplate_CannotHaveCatchAllWithNoName()
635645
[InlineData("{p{{}", "p{")]
636646
[InlineData("{p}}}", "p}")]
637647
[InlineData("{p/}", "p/")]
648+
[ReplaceCulture]
638649
public void ParseRouteParameter_ThrowsIf_ParameterContainsSpecialCharacters(
639650
string template,
640651
string parameterName)
@@ -652,6 +663,7 @@ public void ParseRouteParameter_ThrowsIf_ParameterContainsSpecialCharacters(
652663
}
653664

654665
[Fact]
666+
[ReplaceCulture]
655667
public void InvalidTemplate_CannotHaveConsecutiveOpenBrace()
656668
{
657669
ExceptionAssert.Throws<ArgumentException>(
@@ -662,6 +674,7 @@ public void InvalidTemplate_CannotHaveConsecutiveOpenBrace()
662674
}
663675

664676
[Fact]
677+
[ReplaceCulture]
665678
public void InvalidTemplate_CannotHaveConsecutiveCloseBrace()
666679
{
667680
ExceptionAssert.Throws<ArgumentException>(
@@ -672,6 +685,7 @@ public void InvalidTemplate_CannotHaveConsecutiveCloseBrace()
672685
}
673686

674687
[Fact]
688+
[ReplaceCulture]
675689
public void InvalidTemplate_SameParameterTwiceThrows()
676690
{
677691
ExceptionAssert.Throws<ArgumentException>(
@@ -682,6 +696,7 @@ public void InvalidTemplate_SameParameterTwiceThrows()
682696
}
683697

684698
[Fact]
699+
[ReplaceCulture]
685700
public void InvalidTemplate_SameParameterTwiceAndOneCatchAllThrows()
686701
{
687702
ExceptionAssert.Throws<ArgumentException>(
@@ -692,6 +707,7 @@ public void InvalidTemplate_SameParameterTwiceAndOneCatchAllThrows()
692707
}
693708

694709
[Fact]
710+
[ReplaceCulture]
695711
public void InvalidTemplate_InvalidParameterNameWithCloseBracketThrows()
696712
{
697713
ExceptionAssert.Throws<ArgumentException>(
@@ -702,6 +718,7 @@ public void InvalidTemplate_InvalidParameterNameWithCloseBracketThrows()
702718
}
703719

704720
[Fact]
721+
[ReplaceCulture]
705722
public void InvalidTemplate_InvalidParameterNameWithOpenBracketThrows()
706723
{
707724
ExceptionAssert.Throws<ArgumentException>(
@@ -711,6 +728,7 @@ public void InvalidTemplate_InvalidParameterNameWithOpenBracketThrows()
711728
}
712729

713730
[Fact]
731+
[ReplaceCulture]
714732
public void InvalidTemplate_InvalidParameterNameWithEmptyNameThrows()
715733
{
716734
ExceptionAssert.Throws<ArgumentException>(
@@ -723,6 +741,7 @@ public void InvalidTemplate_InvalidParameterNameWithEmptyNameThrows()
723741
}
724742

725743
[Fact]
744+
[ReplaceCulture]
726745
public void InvalidTemplate_InvalidParameterNameWithQuestionThrows()
727746
{
728747
ExceptionAssert.Throws<ArgumentException>(
@@ -735,6 +754,7 @@ public void InvalidTemplate_InvalidParameterNameWithQuestionThrows()
735754
}
736755

737756
[Fact]
757+
[ReplaceCulture]
738758
public void InvalidTemplate_ConsecutiveSeparatorsSlashSlashThrows()
739759
{
740760
ExceptionAssert.Throws<ArgumentException>(
@@ -745,6 +765,7 @@ public void InvalidTemplate_ConsecutiveSeparatorsSlashSlashThrows()
745765
}
746766

747767
[Fact]
768+
[ReplaceCulture]
748769
public void InvalidTemplate_WithCatchAllNotAtTheEndThrows()
749770
{
750771
ExceptionAssert.Throws<ArgumentException>(
@@ -755,6 +776,7 @@ public void InvalidTemplate_WithCatchAllNotAtTheEndThrows()
755776
}
756777

757778
[Fact]
779+
[ReplaceCulture]
758780
public void InvalidTemplate_RepeatedParametersThrows()
759781
{
760782
ExceptionAssert.Throws<ArgumentException>(
@@ -777,6 +799,7 @@ public void ValidTemplate_CanStartWithSlashOrTildeSlash(string routeTemplate)
777799
}
778800

779801
[Fact]
802+
[ReplaceCulture]
780803
public void InvalidTemplate_CannotStartWithTilde()
781804
{
782805
ExceptionAssert.Throws<ArgumentException>(
@@ -786,6 +809,7 @@ public void InvalidTemplate_CannotStartWithTilde()
786809
}
787810

788811
[Fact]
812+
[ReplaceCulture]
789813
public void InvalidTemplate_CannotContainQuestionMark()
790814
{
791815
ExceptionAssert.Throws<ArgumentException>(
@@ -796,6 +820,7 @@ public void InvalidTemplate_CannotContainQuestionMark()
796820
}
797821

798822
[Fact]
823+
[ReplaceCulture]
799824
public void InvalidTemplate_ParameterCannotContainQuestionMark_UnlessAtEnd()
800825
{
801826
ExceptionAssert.Throws<ArgumentException>(
@@ -808,6 +833,7 @@ public void InvalidTemplate_ParameterCannotContainQuestionMark_UnlessAtEnd()
808833
}
809834

810835
[Fact]
836+
[ReplaceCulture]
811837
public void InvalidTemplate_CatchAllMarkedOptional()
812838
{
813839
ExceptionAssert.Throws<ArgumentException>(

test/Microsoft.AspNetCore.Routing.Tests/TemplateParserDefaultValuesTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using Microsoft.AspNetCore.Builder;
66
using Microsoft.AspNetCore.Routing.Internal;
7+
using Microsoft.AspNetCore.Testing;
78
using Microsoft.Extensions.DependencyInjection;
89
using Microsoft.Extensions.Options;
910
using Moq;
@@ -76,6 +77,7 @@ public void ExplicitDefaultValueSpecified_WithInlineDefaultValue_Throws()
7677
}
7778

7879
[Fact]
80+
[ReplaceCulture]
7981
public void EmptyDefaultValue_WithOptionalParameter_Throws()
8082
{
8183
// Arrange
@@ -99,6 +101,7 @@ public void EmptyDefaultValue_WithOptionalParameter_Throws()
99101
}
100102

101103
[Fact]
104+
[ReplaceCulture]
102105
public void NonEmptyDefaultValue_WithOptionalParameter_Throws()
103106
{
104107
// Arrange

0 commit comments

Comments
 (0)