You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Test(Description="Assert that the translation helper returns the expected translations correctly.")]
@@ -70,8 +70,9 @@ public void Helper_GetTranslations_ReturnsExpectedText()
70
70
// assert
71
71
foreach(stringlocaleinexpected.Keys)
72
72
{
73
-
Assert.IsNotNull(actual[locale],$"The translations for {locale} is unexpectedly null.");
74
-
Assert.That(actual[locale],Is.EquivalentTo(expected[locale]).Using<Translation,Translation>(this.CompareEquality),$"The translations for {locale} don't match the expected values.");
73
+
actual[locale].Should()
74
+
.NotBeNull($"the translations for {locale} should be set")
75
+
.And.BeEquivalentTo(expected[locale],$"the translations for {locale} should match the input values");
75
76
}
76
77
}
77
78
@@ -98,8 +99,9 @@ public void Helper_Get_ReturnsExpectedText()
98
99
// assert
99
100
foreach(stringlocaleinexpected.Keys)
100
101
{
101
-
Assert.IsNotNull(actual[locale],$"The translations for {locale} is unexpectedly null.");
102
-
Assert.That(actual[locale],Is.EquivalentTo(expected[locale]).Using<Translation,Translation>(this.CompareEquality),$"The translations for {locale} don't match the expected values.");
102
+
actual[locale].Should()
103
+
.NotBeNull($"the translations for {locale} should be set")
104
+
.And.BeEquivalentTo(expected[locale],$"the translations for {locale} should match the input values");
103
105
}
104
106
}
105
107
@@ -125,9 +127,9 @@ public void Translation_ToString([ValueSource(nameof(TranslationTests.Samples))]
125
127
126
128
// assert
127
129
if(translation.HasValue())
128
-
Assert.AreEqual(text,translation.ToString(),"The translation returned an unexpected value given a valid input.");
130
+
translation.ToString().Should().Be(text,"the translation should match the valid input");
129
131
else
130
-
Assert.AreEqual(this.GetPlaceholderText("key"),translation.ToString(),"The translation returned an unexpected value given a null or empty input.");
132
+
translation.ToString().Should().Be(this.GetPlaceholderText("key"),"the translation should match the placeholder given a null or empty input");
131
133
}
132
134
133
135
[Test(Description="Assert that the translation's implicit string conversion returns the expected text for various inputs.")]
@@ -138,9 +140,9 @@ public void Translation_ImplicitStringConversion([ValueSource(nameof(Translation
138
140
139
141
// assert
140
142
if(translation.HasValue())
141
-
Assert.AreEqual(text,(string?)translation,"The translation returned an unexpected value given a valid input.");
143
+
((string?)translation).Should().Be(text,"the translation should match the valid input");
142
144
else
143
-
Assert.AreEqual(this.GetPlaceholderText("key"),(string?)translation,"The translation returned an unexpected value given a null or empty input.");
145
+
((string?)translation).Should().Be(this.GetPlaceholderText("key"),"the translation should match the placeholder given a null or empty input");
144
146
}
145
147
146
148
[Test(Description="Assert that the translation returns the expected text given a use-placeholder setting.")]
Assert.AreEqual(text,translation.ToString(),"The translation returned an unexpected value given a valid input.");
156
+
translation.ToString().Should().Be(text,"the translation should match the valid input");
155
157
elseif(!value)
156
-
Assert.AreEqual(text,translation.ToString(),"The translation returned an unexpected value given a null or empty input with the placeholder disabled.");
158
+
translation.ToString().Should().Be(text,"the translation should return the text as-is given a null or empty input with the placeholder disabled");
157
159
else
158
-
Assert.AreEqual(this.GetPlaceholderText("key"),translation.ToString(),"The translation returned an unexpected value given a null or empty input with the placeholder enabled.");
160
+
translation.ToString().Should().Be(this.GetPlaceholderText("key"),"the translation should match the placeholder given a null or empty input with the placeholder enabled");
159
161
}
160
162
161
163
[Test(Description="Assert that the translation returns the expected text after setting the default.")]
@@ -166,11 +168,11 @@ public void Translation_Default([ValueSource(nameof(TranslationTests.Samples))]
166
168
167
169
// assert
168
170
if(!string.IsNullOrEmpty(text))
169
-
Assert.AreEqual(text,translation.ToString(),"The translation returned an unexpected value given a valid base text.");
171
+
translation.ToString().Should().Be(text,"the translation should match the valid base text");
170
172
elseif(!string.IsNullOrEmpty(@default))
171
-
Assert.AreEqual(@default,translation.ToString(),"The translation returned an unexpected value given a null or empty base text, but valid default.");
173
+
translation.ToString().Should().Be(@default,"the translation should match the default text, given a null or empty base text and valid default.");
172
174
else
173
-
Assert.AreEqual(this.GetPlaceholderText("key"),translation.ToString(),"The translation returned an unexpected value given a null or empty base and default text.");
175
+
translation.ToString().Should().Be(this.GetPlaceholderText("key"),translation.ToString(),"the translation should match the placeholder, given a null or empty base text and no default text");
174
176
}
175
177
176
178
/****
@@ -211,7 +213,7 @@ public void Translation_Tokens([Values("anonymous object", "class", "IDictionary
211
213
}
212
214
213
215
// assert
214
-
Assert.AreEqual(expected,translation.ToString(),"The translation returned an unexpected text.");
216
+
translation.ToString().Should().Be(expected);
215
217
}
216
218
217
219
[Test(Description="Assert that the translation can replace tokens in all valid formats.")]
@@ -231,7 +233,7 @@ public void Translation_Tokens_ValidFormats(string text, string key)
Assert.Throws<ArgumentException>(()=>_=SDate.FromDaysSinceStart(daysSinceStart),"Passing the invalid number of days didn't throw the expected exception.");
Assert.Throws<ArithmeticException>(()=>_=this.GetDate(dateStr).AddDays(addDays),"Passing the invalid number of days didn't throw the expected exception.");
0 commit comments