-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from MRCollective/flags-enum-support
Flags enum support
- Loading branch information
Showing
43 changed files
with
992 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ _ReSharper.* | |
*.log | ||
packages | ||
*.received.* | ||
.vs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
ChameleonForms.AcceptanceTests/ModelBinding/ModelBindingTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
ChameleonForms.Tests/Attributes/RequiredFlagsEnumAttributeTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using ChameleonForms.Attributes; | ||
using ChameleonForms.Tests.FieldGenerator; | ||
using NUnit.Framework; | ||
|
||
namespace ChameleonForms.Tests.Attributes | ||
{ | ||
class RequiredFlagsEnumAttributeTests | ||
{ | ||
[Test] | ||
public void DefaultFlagsEnumValueShouldntBeValid() | ||
{ | ||
var attr = new RequiredFlagsEnumAttribute(); | ||
|
||
Assert.That(attr.IsValid(default(TestFlagsEnum)), Is.False); | ||
} | ||
|
||
[Test] | ||
public void NonDefaultFlagsEnumSingleValueShouldBeValid() | ||
{ | ||
var attr = new RequiredFlagsEnumAttribute(); | ||
|
||
Assert.That(attr.IsValid(TestFlagsEnum.Simplevalue), Is.True); | ||
} | ||
|
||
[Test] | ||
public void NonDefaultFlagsEnumMultipleValueShouldBeValid() | ||
{ | ||
var attr = new RequiredFlagsEnumAttribute(); | ||
|
||
Assert.That(attr.IsValid(TestFlagsEnum.Simplevalue | TestFlagsEnum.ValueWithDescriptionAttribute), Is.True); | ||
} | ||
|
||
[Test] | ||
public void NullShouldntBeValid() | ||
{ | ||
var attr = new RequiredFlagsEnumAttribute(); | ||
|
||
Assert.That(attr.IsValid(null), Is.False); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...nerator/FlagsEnumTests.Use_correct_html_for_child_viewmodel_enum_list_field.approved.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<ul> | ||
<li> | ||
<input class="input-validation-error" data-attr="value" data-val="true" data-val-required="The RequiredChildFlagsEnum field is required." id="Child_RequiredChildFlagsEnum_1" name="Child.RequiredChildFlagsEnum" type="checkbox" value="Simplevalue" /> | ||
<label for="Child_RequiredChildFlagsEnum_1">Simplevalue</label> | ||
</li> | ||
<li> | ||
<input class="input-validation-error" data-attr="value" id="Child_RequiredChildFlagsEnum_2" name="Child.RequiredChildFlagsEnum" type="checkbox" value="ValueWithDescriptionAttribute" /> | ||
<label for="Child_RequiredChildFlagsEnum_2">Description attr text</label> | ||
</li> | ||
<li> | ||
<input class="input-validation-error" data-attr="value" id="Child_RequiredChildFlagsEnum_3" name="Child.RequiredChildFlagsEnum" type="checkbox" value="ValueWithMultpipleWordsAndNoDescriptionAttribute" /> | ||
<label for="Child_RequiredChildFlagsEnum_3">Value with multpiple words and no description attribute</label> | ||
</li> | ||
</ul> |
4 changes: 4 additions & 0 deletions
4
...Generator/FlagsEnumTests.Use_correct_html_for_enum_list_with_excluded_value.approved.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<select class="input-validation-error" data-attr="value" data-val="true" data-val-required="The RequiredFlagsEnum field is required." id="RequiredFlagsEnum" multiple="multiple" name="RequiredFlagsEnum"> | ||
<option value="ValueWithDescriptionAttribute">Description attr text</option> | ||
<option value="ValueWithMultpipleWordsAndNoDescriptionAttribute">Value with multpiple words and no description attribute</option> | ||
</select> |
1 change: 1 addition & 0 deletions
1
...tFieldGenerator/FlagsEnumTests.Use_correct_html_for_label_for_enum_dropdown.approved.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<label for="RequiredFlagsEnum">RequiredFlagsEnum</label> |
1 change: 1 addition & 0 deletions
1
...faultFieldGenerator/FlagsEnumTests.Use_correct_html_for_label_for_enum_list.approved.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
RequiredFlagsEnum |
1 change: 1 addition & 0 deletions
1
...agsEnumTests.Use_correct_html_for_label_for_enum_list_with_overridden_label.approved.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<strong>lol</strong> |
5 changes: 5 additions & 0 deletions
5
...dGenerator/FlagsEnumTests.Use_correct_html_for_nullable_required_enum_field.approved.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<select class="input-validation-error" data-attr="value" data-val="true" data-val-required="The RequiredNullableFlagsEnum field is required." id="RequiredNullableFlagsEnum" multiple="multiple" name="RequiredNullableFlagsEnum"> | ||
<option value="Simplevalue">Simplevalue</option> | ||
<option value="ValueWithDescriptionAttribute">Description attr text</option> | ||
<option value="ValueWithMultpipleWordsAndNoDescriptionAttribute">Value with multpiple words and no description attribute</option> | ||
</select> |
6 changes: 6 additions & 0 deletions
6
...faultFieldGenerator/FlagsEnumTests.Use_correct_html_for_optional_enum_field.approved.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<select class="input-validation-error" data-attr="value" id="OptionalFlagsEnum" multiple="multiple" name="OptionalFlagsEnum"> | ||
<option selected="selected" value="">None</option> | ||
<option value="Simplevalue">Simplevalue</option> | ||
<option value="ValueWithDescriptionAttribute">Description attr text</option> | ||
<option value="ValueWithMultpipleWordsAndNoDescriptionAttribute">Value with multpiple words and no description attribute</option> | ||
</select> |
Oops, something went wrong.