Skip to content

Commit

Permalink
Several type-mismatch errors fixed. Few tests parameterized. Coverage…
Browse files Browse the repository at this point in the history
… increased.
  • Loading branch information
jwaliszko committed Feb 18, 2016
1 parent 8636c77 commit 6fff1fd
Show file tree
Hide file tree
Showing 6 changed files with 399 additions and 372 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WebDriver, Version=2.51.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Selenium.WebDriver.2.51.0\lib\net40\WebDriver.dll</HintPath>
<Reference Include="WebDriver, Version=2.52.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Selenium.WebDriver.2.52.0\lib\net40\WebDriver.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="WebDriver.Support, Version=2.51.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Selenium.Support.2.51.0\lib\net40\WebDriver.Support.dll</HintPath>
<Reference Include="WebDriver.Support, Version=2.52.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Selenium.Support.2.52.0\lib\net40\WebDriver.Support.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="PhantomJS" version="2.0.0" targetFramework="net451" />
<package id="Selenium.Support" version="2.51.0" targetFramework="net451" />
<package id="Selenium.WebDriver" version="2.51.0" targetFramework="net451" />
<package id="Selenium.Support" version="2.52.0" targetFramework="net451" />
<package id="Selenium.WebDriver" version="2.52.0" targetFramework="net451" />
<package id="xunit" version="2.1.0" targetFramework="net451" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net451" />
<package id="xunit.assemblyfixture" version="2.0.2" targetFramework="net451" />
Expand Down
20 changes: 14 additions & 6 deletions src/ExpressiveAnnotations.Tests/AttribsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,26 +159,29 @@ 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}}}",
"field: {#{Value1}#}, expr: {1!=1} | Value1: {0}{_{Value1}_}, Internal.Internal.Value1: {2}, {_{Value2}_}",
"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
//string.Format("0}}", 1); -> 0}

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
{
Expand All @@ -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;
Expand Down Expand Up @@ -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");
Expand All @@ -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,
Expand Down
Loading

0 comments on commit 6fff1fd

Please sign in to comment.