diff --git a/src/ExpressiveAnnotations.MvcWebSample.UITests/ExpressiveAnnotations.MvcWebSample.UITests.csproj b/src/ExpressiveAnnotations.MvcWebSample.UITests/ExpressiveAnnotations.MvcWebSample.UITests.csproj
index bd25f46..f42fb97 100644
--- a/src/ExpressiveAnnotations.MvcWebSample.UITests/ExpressiveAnnotations.MvcWebSample.UITests.csproj
+++ b/src/ExpressiveAnnotations.MvcWebSample.UITests/ExpressiveAnnotations.MvcWebSample.UITests.csproj
@@ -44,12 +44,12 @@
-
- ..\packages\Selenium.WebDriver.2.51.0\lib\net40\WebDriver.dll
+
+ ..\packages\Selenium.WebDriver.2.52.0\lib\net40\WebDriver.dll
True
-
- ..\packages\Selenium.Support.2.51.0\lib\net40\WebDriver.Support.dll
+
+ ..\packages\Selenium.Support.2.52.0\lib\net40\WebDriver.Support.dll
True
diff --git a/src/ExpressiveAnnotations.MvcWebSample.UITests/packages.config b/src/ExpressiveAnnotations.MvcWebSample.UITests/packages.config
index 5d9df7d..c872d7c 100644
--- a/src/ExpressiveAnnotations.MvcWebSample.UITests/packages.config
+++ b/src/ExpressiveAnnotations.MvcWebSample.UITests/packages.config
@@ -1,8 +1,8 @@
-
-
+
+
diff --git a/src/ExpressiveAnnotations.Tests/AttribsTest.cs b/src/ExpressiveAnnotations.Tests/AttribsTest.cs
index 2e3c1fd..b19082f 100644
--- a/src/ExpressiveAnnotations.Tests/AttribsTest.cs
+++ b/src/ExpressiveAnnotations.Tests/AttribsTest.cs
@@ -159,7 +159,6 @@ public void verify_custom_error_message_after_validation()
"field: #{Value1}#, expr: 1==1 | Value1: 0_{Value1}_, Internal.Internal.Value1: 2, _{Value2}_");
AssertErrorMessage( // all escaped
"field: {{0}}, expr: {{1}} | Value1: {{Value1}}{{Value1:n}}, Internal.Internal.Value1: {{Internal.Internal.Value1}}, {{Internal.Internal.Value2:N}}",
- "field: {0}, expr: {1} | Value1: {Value1}{Value1:n}, Internal.Internal.Value1: {Internal.Internal.Value1}, {Internal.Internal.Value2:N}",
"field: {0}, expr: {1} | Value1: {Value1}{Value1:n}, Internal.Internal.Value1: {Internal.Internal.Value1}, {Internal.Internal.Value2:N}");
AssertErrorMessage(
"field: {{{0}}}, expr: {{{1}}} | Value1: {{{Value1}}}{{{Value1:n}}}, Internal.Internal.Value1: {{{Internal.Internal.Value1}}}, {{{Internal.Internal.Value2:N}}}",
@@ -167,7 +166,6 @@ public void verify_custom_error_message_after_validation()
"field: {#{Value1}#}, expr: {1==1} | Value1: {0}{_{Value1}_}, Internal.Internal.Value1: {2}, {_{Value2}_}");
AssertErrorMessage( // all double-escaped
"field: {{{{0}}}}, expr: {{{{1}}}} | Value1: {{{{Value1}}}}{{{{Value1:n}}}}, Internal.Internal.Value1: {{{{Internal.Internal.Value1}}}}, {{{{Internal.Internal.Value2:N}}}}",
- "field: {{0}}, expr: {{1}} | Value1: {{Value1}}{{Value1:n}}, Internal.Internal.Value1: {{Internal.Internal.Value1}}, {{Internal.Internal.Value2:N}}",
"field: {{0}}, expr: {{1}} | Value1: {{Value1}}{{Value1:n}}, Internal.Internal.Value1: {{Internal.Internal.Value1}}, {{Internal.Internal.Value2:N}}");
//string.Format("{{0", 1); -> {0
@@ -175,10 +173,15 @@ public void verify_custom_error_message_after_validation()
AssertErrorMessage(
"field: {{0, expr: {{1 | Value1: {{Value1{{Value1:n, Internal.Internal.Value1: Internal.Internal.Value1}}, Internal.Internal.Value2:N}}",
- "field: {0, expr: {1 | Value1: {Value1{Value1:n, Internal.Internal.Value1: Internal.Internal.Value1}, Internal.Internal.Value2:N}",
"field: {0, expr: {1 | Value1: {Value1{Value1:n, Internal.Internal.Value1: Internal.Internal.Value1}, Internal.Internal.Value2:N}");
}
+ [Fact]
+ public void custom_error_message_tolerates_null_value()
+ {
+ AssertErrorMessage("lang: '{Lang}'", "lang: ''");
+ }
+
[Fact]
public void verify_format_exceptions_from_incorrect_custom_format_specifiers() // custom specifiers handling should throw the same formatting error as framework implementation, when incorrect nesting is detected
{
@@ -205,13 +208,13 @@ public void verify_custom_error_message_after_validation()
[Fact]
public void verify_that_culture_change_affects_validation_message()
{
- AssertErrorMessage("{Lang:n}", "default", "default");
+ AssertErrorMessage("{Lang:n}", "default");
// change culture
var culture = Thread.CurrentThread.CurrentUICulture;
Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("pl");
- AssertErrorMessage("{Lang:n}", "polski", "polski");
+ AssertErrorMessage("{Lang:n}", "polski");
// restore culture
Thread.CurrentThread.CurrentUICulture = culture;
@@ -295,6 +298,11 @@ public void display_attribute_takes_precedence_over_displayname_attribute()
Assert.Equal("assertthat only chosen", results.Single().ErrorMessage);
}
+ private static void AssertErrorMessage(string input, string output)
+ {
+ AssertErrorMessage(input, output, output);
+ }
+
private static void AssertErrorMessage(string input, string assertThatOutput, string requiredIfOutput)
{
var assertThat = new AssertThatAttribute("1!=1");
@@ -303,7 +311,7 @@ private static void AssertErrorMessage(string input, string assertThatOutput, st
var isValid = typeof (ExpressiveAttribute).GetMethod("IsValid", BindingFlags.NonPublic | BindingFlags.Instance);
var context = new ValidationContext(new MsgModel
{
- Value1 = 0,
+ Value1 = 0,
Internal = new MsgModel
{
Value1 = 1,
diff --git a/src/ExpressiveAnnotations.Tests/ParserTest.cs b/src/ExpressiveAnnotations.Tests/ParserTest.cs
index 56868a5..cf3a1d0 100644
--- a/src/ExpressiveAnnotations.Tests/ParserTest.cs
+++ b/src/ExpressiveAnnotations.Tests/ParserTest.cs
@@ -227,6 +227,9 @@ public void verify_logic_without_context()
Assert.True(parser.Parse