diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8c3ff4c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,39 @@ +root = true + +[*] +charset = utf-8 +end_of_line = crlf +indent_style = space + +[*.cs] +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true +dotnet_sort_system_directives_first = true +csharp_new_line_before_open_brace = all +csharp_new_line_before_else = true +csharp_new_line_before_catch= true +csharp_new_line_before_finally= true +csharp_new_line_before_members_in_object_initializers= true +csharp_new_line_before_members_in_anonymous_types= true +csharp_new_line_between_query_expression_clauses= true +csharp_indent_case_contents= true +csharp_indent_switch_labels= true +csharp_indent_labels = no_change +csharp_space_after_cast = false +csharp_space_after_keywords_in_control_flow_statements= true +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_preserve_single_line_statements= true +csharp_preserve_single_line_blocks= true + +[*.sln] +indent_style = tab + +[*.{csproj, yml, config, cake}] +indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..57d9cd3 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +* text=auto + +*.cs text diff=csharp eol=crlf +*.sln text merge=union eol=crlf +*.csproj text merge=union eol=crlf \ No newline at end of file diff --git a/.gitignore b/.gitignore index 43fa8ce..ec7b0cc 100644 --- a/.gitignore +++ b/.gitignore @@ -297,8 +297,8 @@ __pycache__/ *.pyc # Cake - Uncomment if you are using it - tools/** - !tools/packages.config +tools/** +!tools/packages.config # Tabs Studio *.tss @@ -312,5 +312,5 @@ __pycache__/ *.odx.cs *.xsd.cs -# diff -*.orig \ No newline at end of file +# diff +*.orig \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 1816edc..db2d549 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,52 +1,52 @@ { - "version": "0.2.0", - "configurations": [ - { - "name": ".NET Core Launch (console)", - "type": "coreclr", - "request": "launch", - "preLaunchTask": "build", - "program": "${workspaceRoot}/tests/Valit.Tests/bin/Debug/netcoreapp2.0/Valit.Tests.dll", - "args": [], - "cwd": "${workspaceRoot}", - "stopAtEntry": false, - "console": "internalConsole" - }, - { - "name": ".NET Core Launch (web)", - "type": "coreclr", - "request": "launch", - "preLaunchTask": "build", - "program": "${workspaceRoot}/tests/Valit.Tests/bin/Debug/netcoreapp2.0/Valit.Tests.dll", - "args": [], - "cwd": "${workspaceRoot}", - "stopAtEntry": false, - "launchBrowser": { - "enabled": true, - "args": "${auto-detect-url}", - "windows": { - "command": "cmd.exe", - "args": "/C start ${auto-detect-url}" - }, - "osx": { - "command": "open" - }, - "linux": { - "command": "xdg-open" - } - }, - "env": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "sourceFileMap": { - "/Views": "${workspaceRoot}/Views" - } - }, - { - "name": ".NET Core Attach", - "type": "coreclr", - "request": "attach", - "processId": "${command:pickProcess}" - } - ] + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceRoot}/tests/Valit.Tests/bin/Debug/netcoreapp2.0/Valit.Tests.dll", + "args": [], + "cwd": "${workspaceRoot}", + "stopAtEntry": false, + "console": "internalConsole" + }, + { + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceRoot}/tests/Valit.Tests/bin/Debug/netcoreapp2.0/Valit.Tests.dll", + "args": [], + "cwd": "${workspaceRoot}", + "stopAtEntry": false, + "launchBrowser": { + "enabled": true, + "args": "${auto-detect-url}", + "windows": { + "command": "cmd.exe", + "args": "/C start ${auto-detect-url}" + }, + "osx": { + "command": "open" + }, + "linux": { + "command": "xdg-open" + } + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceRoot}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index fc0bf39..83b37fd 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,17 +1,17 @@ { - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "2.0.0", - "tasks": [ - { - "taskName": "build", - "command": "dotnet build", - "type": "shell", - "group": "build", - "presentation": { - "reveal": "silent" - }, - "problemMatcher": "$msCompile" - } - ] + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "taskName": "build", + "command": "dotnet build", + "type": "shell", + "group": "build", + "presentation": { + "reveal": "silent" + }, + "problemMatcher": "$msCompile" + } + ] } \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ab21c52..c2403ce 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -49,6 +49,11 @@ When you're done make sure all tests passess. Navigate to the ```Valit.Tests``` dotnet test ``` +You can also run the following command for continuous testing: +``` +dotnet watch test // this will compile the project and rerun the tests on every file change +``` + Alternatively, you can use our **Cake script** which is placed in the root folder. Navigate there and run: ``` ./build.sh //on Unix @@ -63,7 +68,7 @@ When the code is stable, you can submit your changes by creating a pull request. git push origin ``` -Then go to the **GitHub -> Pull Request -> New Pull Request**. +Then go to the **GitHub -> Pull Request -> New Pull Request**. Select **develop** as base and your branch as compare. We provide default template for PR description: ![PR_Template](http://foreverframe.net/wp-content/uploads/2017/09/Screen-Shot-2017-09-27-at-21.16.02.png) @@ -86,7 +91,7 @@ Each PR must fulfill certain conditions before it can be merged: If some of the above won't be fulfilled (due to change request or some mistake) simply fix it locally on your machine, create new commit and push it to origin. This will update the exisitng PR and will kick off all checks again. -If everything will be fine, your changes will be merged into develop, branch will be deleted and related issue will be closed. +If everything will be fine, your changes will be merged into develop, branch will be deleted and related issue will be closed. # WELL DONE AND THANK YOU VERY MUCH! diff --git a/Valit.sln b/Valit.sln index ac628ed..17a5d46 100644 --- a/Valit.sln +++ b/Valit.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26730.16 diff --git a/build.cake b/build.cake index 36f3d17..39cddb8 100644 --- a/build.cake +++ b/build.cake @@ -4,38 +4,38 @@ var target = Argument("target", "Default"); var configuration = Argument("configuration", "Release"); Task("dotnet-restore") - .Does(() => - { - DotNetCoreRestore("./Valit.sln"); - }); + .Does(() => + { + DotNetCoreRestore("./Valit.sln"); + }); Task("dotnet-build") - .IsDependentOn("dotnet-restore") - .Does(() => - { - DotNetCoreBuild("./Valit.sln", new DotNetCoreBuildSettings - { - Configuration = configuration, - MSBuildSettings = new DotNetCoreMSBuildSettings - { - TreatAllWarningsAs = MSBuildTreatAllWarningsAs.Error - } - }); - }); + .IsDependentOn("dotnet-restore") + .Does(() => + { + DotNetCoreBuild("./Valit.sln", new DotNetCoreBuildSettings + { + Configuration = configuration, + MSBuildSettings = new DotNetCoreMSBuildSettings + { + TreatAllWarningsAs = MSBuildTreatAllWarningsAs.Error + } + }); + }); Task("run-xunit-tests") - .IsDependentOn("dotnet-build") - .Does(() => - { - var settings = new DotNetCoreTestSettings + .IsDependentOn("dotnet-build") + .Does(() => + { + var settings = new DotNetCoreTestSettings { - Configuration = configuration + Configuration = configuration }; - DotNetCoreTest("./tests/Valit.Tests/Valit.Tests.csproj", settings); - }); + DotNetCoreTest("./tests/Valit.Tests/Valit.Tests.csproj", settings); + }); Task("Default") - .IsDependentOn("run-xunit-tests"); + .IsDependentOn("run-xunit-tests"); RunTarget(target); \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index 265bd12..67b2cb4 100644 --- a/build.ps1 +++ b/build.ps1 @@ -156,7 +156,7 @@ if(-Not $SkipToolPackageRestore.IsPresent) { # Check for changes in packages.config and remove installed tools if true. [string] $md5Hash = MD5HashFile($PACKAGES_CONFIG) if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or - ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) { + ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) { Write-Verbose -Message "Missing or changed package.config hash..." Remove-Item * -Recurse -Exclude packages.config,nuget.exe } diff --git a/src/Valit/CompleteValitStrategy.cs b/src/Valit/CompleteValitStrategy.cs index 13b4fca..c6c0126 100644 --- a/src/Valit/CompleteValitStrategy.cs +++ b/src/Valit/CompleteValitStrategy.cs @@ -1,8 +1,8 @@ -namespace Valit +namespace Valit { public class CompleteValitStrategy : IValitStrategy { - public void Fail(IValitRule rule, IValitResult result, out bool cancel) + public void Fail(IValitRule rule, IValitResult result, out bool cancel) where TObject : class { cancel = false; diff --git a/src/Valit/Errors/ValitRuleError.cs b/src/Valit/Errors/ValitRuleError.cs index b532640..a059858 100644 --- a/src/Valit/Errors/ValitRuleError.cs +++ b/src/Valit/Errors/ValitRuleError.cs @@ -1,24 +1,28 @@ +using System; + namespace Valit.Errors { internal class ValitRuleError { - public string Message { get; } + private readonly Func _messageFunc; + public string Message => _messageFunc(); public int? ErrorCode { get; } - private ValitRuleError(string message) + private ValitRuleError(Func messageFunc) { - Message = message; + _messageFunc = messageFunc; } private ValitRuleError(int errorCode) { ErrorCode = errorCode; + _messageFunc = () => string.Empty; } - public static ValitRuleError CreateForMessage(string message) - => new ValitRuleError(message); + public static ValitRuleError CreateForMessage(Func messageFunc) + => new ValitRuleError(messageFunc); public static ValitRuleError CreateForErrorCode(int errorCode) - => new ValitRuleError(errorCode); + => new ValitRuleError(errorCode); } -} \ No newline at end of file +} diff --git a/src/Valit/Exceptions/SemanticExceptions.cs b/src/Valit/Exceptions/SemanticExceptions.cs index 87c5240..0dca17c 100644 --- a/src/Valit/Exceptions/SemanticExceptions.cs +++ b/src/Valit/Exceptions/SemanticExceptions.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace Valit.Exceptions { @@ -8,6 +8,6 @@ public static ValitException NullDereferenced(string message) => throw new ValitException(message, new ArgumentNullException()); public static ValitException NullDereferenced() - => throw new ValitException("Null dereferenced", new ArgumentNullException()); + => throw new ValitException("Null dereferenced", new ArgumentNullException()); } } diff --git a/src/Valit/Exceptions/ValitExceptionExtensions.cs b/src/Valit/Exceptions/ValitExceptionExtensions.cs index 01547e7..5d4ca78 100644 --- a/src/Valit/Exceptions/ValitExceptionExtensions.cs +++ b/src/Valit/Exceptions/ValitExceptionExtensions.cs @@ -22,4 +22,4 @@ internal static void ThrowIfNull(this T @object, string message) } } } -} \ No newline at end of file +} diff --git a/src/Valit/Exceptions/ValitExceptionMessages.cs b/src/Valit/Exceptions/ValitExceptionMessages.cs index d9a2aa7..2535aaf 100644 --- a/src/Valit/Exceptions/ValitExceptionMessages.cs +++ b/src/Valit/Exceptions/ValitExceptionMessages.cs @@ -3,6 +3,6 @@ namespace Valit.Exceptions internal static class ValitExceptionMessages { public static string NullRule => "Valit rule is null"; - public static string NullPredicate => "Given predicate is null"; + public static string NullPredicate => "Given predicate is null"; } -} \ No newline at end of file +} diff --git a/src/Valit/FailFastValitStrategy.cs b/src/Valit/FailFastValitStrategy.cs index 0b1a293..bb743f5 100644 --- a/src/Valit/FailFastValitStrategy.cs +++ b/src/Valit/FailFastValitStrategy.cs @@ -1,9 +1,9 @@ -namespace Valit +namespace Valit { public class FailFastValitStrategy : IValitStrategy { public void Fail(IValitRule rule, IValitResult result, out bool cancel) - where TObject : class + where TObject : class { cancel = true; } diff --git a/src/Valit/IValitMessageProvider.cs b/src/Valit/IValitMessageProvider.cs index 98c1e86..570e62d 100644 --- a/src/Valit/IValitMessageProvider.cs +++ b/src/Valit/IValitMessageProvider.cs @@ -1,4 +1,4 @@ -namespace Valit +namespace Valit { public interface IValitMessageProvider { diff --git a/src/Valit/IValitResult.cs b/src/Valit/IValitResult.cs index 2046323..caeec6c 100644 --- a/src/Valit/IValitResult.cs +++ b/src/Valit/IValitResult.cs @@ -4,10 +4,10 @@ namespace Valit { public interface IValitResult { - bool Succeeded { get; } + bool Succeeded { get; } - ImmutableArray ErrorMessages { get; } + ImmutableArray ErrorMessages { get; } - ImmutableArray ErrorCodes { get; } + ImmutableArray ErrorCodes { get; } } -} \ No newline at end of file +} diff --git a/src/Valit/IValitRule.cs b/src/Valit/IValitRule.cs index 159a641..10350c8 100644 --- a/src/Valit/IValitRule.cs +++ b/src/Valit/IValitRule.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace Valit { @@ -10,6 +10,8 @@ public interface IValitRule public interface IValitRule : IValitRule where TObject : class { IValitResult Validate(TObject @object); + + IEnumerable> GetEnsureRules(TObject @object); } public interface IValitRule : IValitRule where TObject : class { diff --git a/src/Valit/IValitRules.cs b/src/Valit/IValitRules.cs index e23d380..8023379 100644 --- a/src/Valit/IValitRules.cs +++ b/src/Valit/IValitRules.cs @@ -5,13 +5,17 @@ namespace Valit { public interface IValitRules where TObject : class { - IValitRules Ensure(Func selector, Func,IValitRule> rule); - IValitRules For(TObject @object); - IEnumerable> GetAllRules(); - IEnumerable> GetTaggedRules(); - IEnumerable> GetUntaggedRules(); - IValitResult Validate(); - IValitResult Validate(params string[] tags); - IValitResult Validate(Func, bool> predicate); + IValitRules Ensure(Func selector, Func, IValitRule> ruleFunc); + IValitRules Ensure(Func selector, IValitRulesProvider valitRulesProvider) where TProperty : class; + IValitRules Ensure(Func selector, Func, TObject, IValitRule> rule); + IValitRules EnsureFor(Func> selector, Func, IValitRule> ruleFunc); + IValitRules EnsureFor(Func> selector, IValitRulesProvider valitRulesProvider) where TProperty : class; + IValitRules For(TObject @object); + IEnumerable> GetAllRules(); + IEnumerable> GetTaggedRules(); + IEnumerable> GetUntaggedRules(); + IValitResult Validate(); + IValitResult Validate(params string[] tags); + IValitResult Validate(Func, bool> predicate); } -} \ No newline at end of file +} diff --git a/src/Valit/IValitRulesMessageProvider.cs b/src/Valit/IValitRulesMessageProvider.cs index 8f5d33a..01891d4 100644 --- a/src/Valit/IValitRulesMessageProvider.cs +++ b/src/Valit/IValitRulesMessageProvider.cs @@ -1,8 +1,8 @@ -namespace Valit +namespace Valit { public interface IValitRulesMessageProvider : IValitRulesStrategyPicker where TObject : class { IValitRulesStrategyPicker WithMessageProvider(IValitMessageProvider messageProvider); } -} \ No newline at end of file +} diff --git a/src/Valit/IValitRulesProvider.cs b/src/Valit/IValitRulesProvider.cs new file mode 100644 index 0000000..1b4510a --- /dev/null +++ b/src/Valit/IValitRulesProvider.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace Valit +{ + public interface IValitRulesProvider where TObject : class + { + IEnumerable> GetRules(); + } +} diff --git a/src/Valit/IValitRulesStrategyPicker.cs b/src/Valit/IValitRulesStrategyPicker.cs index 43202bf..b0b60c4 100644 --- a/src/Valit/IValitRulesStrategyPicker.cs +++ b/src/Valit/IValitRulesStrategyPicker.cs @@ -3,6 +3,6 @@ namespace Valit public interface IValitRulesStrategyPicker : IValitRules where TObject : class { - IValitRules WithStrategy(IValitStrategy strategy); + IValitRules WithStrategy(IValitStrategy strategy); } -} \ No newline at end of file +} diff --git a/src/Valit/IValitStrategy.cs b/src/Valit/IValitStrategy.cs index a68214a..edf480b 100644 --- a/src/Valit/IValitStrategy.cs +++ b/src/Valit/IValitStrategy.cs @@ -1,4 +1,4 @@ -namespace Valit +namespace Valit { public interface IValitStrategy { diff --git a/src/Valit/IValitator.cs b/src/Valit/IValitator.cs new file mode 100644 index 0000000..520a4e1 --- /dev/null +++ b/src/Valit/IValitator.cs @@ -0,0 +1,7 @@ +namespace Valit +{ + public interface IValitator where TObject : class + { + IValitResult Validate(TObject @object, IValitStrategy strategy = null); + } +} diff --git a/src/Valit/MessageProvider/EmptyMessageProvider.cs b/src/Valit/MessageProvider/EmptyMessageProvider.cs index 37a3771..536c39e 100644 --- a/src/Valit/MessageProvider/EmptyMessageProvider.cs +++ b/src/Valit/MessageProvider/EmptyMessageProvider.cs @@ -1,4 +1,4 @@ -namespace Valit.MessageProvider +namespace Valit.MessageProvider { internal sealed class EmptyMessageProvider : IValitMessageProvider { diff --git a/src/Valit/Result/ValitResult.cs b/src/Valit/Result/ValitResult.cs index c36c135..940bd8b 100644 --- a/src/Valit/Result/ValitResult.cs +++ b/src/Valit/Result/ValitResult.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using Valit.Errors; @@ -7,7 +7,7 @@ namespace Valit.Result { internal class ValitResult : IValitResult { - public static readonly ValitResult Success = new ValitResult(); + public static readonly ValitResult Success = new ValitResult(); public bool Succeeded { get; } @@ -23,7 +23,7 @@ private ValitResult() private ValitResult(IEnumerable errors) { - Succeeded = false; + Succeeded = false; ErrorMessages = errors .Where(e => !string.IsNullOrEmpty(e.Message)) diff --git a/src/Valit/Rules/CollectionValitRule.cs b/src/Valit/Rules/CollectionValitRule.cs new file mode 100644 index 0000000..46a7d93 --- /dev/null +++ b/src/Valit/Rules/CollectionValitRule.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Valit.Exceptions; +using Valit.Result; + +namespace Valit.Rules +{ + internal class CollectionValitRule : IValitRule where TObject : class + { + public IEnumerable Tags { get; private set; } + + private readonly Func> _collectionSelector; + private readonly Func,IValitRule> _ruleFunc; + private readonly IValitStrategy _strategy; + private readonly IValitMessageProvider _messageProvider; + + public CollectionValitRule( + Func> collectionSelector, + Func,IValitRule> ruleFunc, + IValitStrategy strategy, + IValitMessageProvider messageProvider) + { + Tags = Enumerable.Empty(); + _collectionSelector = collectionSelector; + _ruleFunc = ruleFunc; + _strategy = strategy; + _messageProvider = messageProvider; + } + + IValitResult IValitRule.Validate(TObject @object) + { + @object.ThrowIfNull(); + + var collection = _collectionSelector(@object); + + var result = ValitResult.Success; + + foreach(var property in collection) + { + Func selector = _ => property; + var lastEnsureRule = _ruleFunc(new ValitRule(selector, _messageProvider)); + var propertyRules = lastEnsureRule.GetAllEnsureRules(); + + result &= ValidatePropertyRules(propertyRules, @object); + + if(!result.Succeeded) + { + _strategy.Fail(default(IValitRule), result, out bool cancel); + if(cancel) + { + break; + } + } + } + + return result; + } + + private IValitResult ValidatePropertyRules(IEnumerable> propertyRules, TObject @object) + => ValitRules + .Create(propertyRules) + .WithStrategy(_strategy) + .For(@object) + .Validate(); + + public IEnumerable> GetEnsureRules(TObject @object) => new []{ this }; + } +} diff --git a/src/Valit/Rules/IValitRuleAccessor.cs b/src/Valit/Rules/IValitRuleAccessor.cs index f130c41..811d565 100644 --- a/src/Valit/Rules/IValitRuleAccessor.cs +++ b/src/Valit/Rules/IValitRuleAccessor.cs @@ -1,23 +1,22 @@ -using System; +using System; using Valit.Errors; namespace Valit.Rules { internal interface IValitRuleAccessor { - IValitStrategy Strategy { get; } IValitMessageProvider GetMessageProvider(); IValitMessageProvider GetMessageProvider(); void AddError(ValitRuleError error); void AddTags(params string[] tags); - bool HasPredicate(); + bool HasPredicate(); } - + internal interface IValitRuleAccessor : IValitRuleAccessor where TObject : class { Func PropertySelector { get; } IValitRule PreviousRule { get; } - void SetPredicate(Predicate predicate); - void AddCondition(Predicate condition); + void SetPredicate(Predicate predicate); + void AddCondition(Predicate condition); } } diff --git a/src/Valit/Rules/NestedObjectCollectionValitRule.cs b/src/Valit/Rules/NestedObjectCollectionValitRule.cs new file mode 100644 index 0000000..c0f9bb5 --- /dev/null +++ b/src/Valit/Rules/NestedObjectCollectionValitRule.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Valit.Exceptions; +using Valit.Result; + +namespace Valit.Rules +{ + internal class NestedObjectCollectionValitRule : IValitRule where TObject : class where TProperty : class + { + public IEnumerable Tags { get; private set; } + private readonly Func> _collectionSelector; + private readonly IValitRulesProvider _valitRulesProvider; + private readonly IValitStrategy _strategy; + + public NestedObjectCollectionValitRule( + Func> collectionSelector, + IValitRulesProvider valitRulesProvider, + IValitStrategy strategy) + { + Tags = Enumerable.Empty(); + _collectionSelector = collectionSelector; + _valitRulesProvider = valitRulesProvider; + _strategy = strategy; + } + + IValitResult IValitRule.Validate(TObject @object) + { + @object.ThrowIfNull(); + + var collection = _collectionSelector(@object); + + var result = ValitResult.Success; + + foreach(var property in collection) + { + Func selector = _ => property; + var nestedObjectValitRule = new NestedObjectValitRule(selector, _valitRulesProvider, _strategy); + + result &= nestedObjectValitRule.Validate(@object); + + if(!result.Succeeded) + { + _strategy.Fail(default(IValitRule), result, out bool cancel); + if(cancel) + { + break; + } + } + } + + return result; + } + + public IEnumerable> GetEnsureRules(TObject @object) => new [] { this }; + } +} diff --git a/src/Valit/Rules/NestedObjectValitRule.cs b/src/Valit/Rules/NestedObjectValitRule.cs new file mode 100644 index 0000000..f708adb --- /dev/null +++ b/src/Valit/Rules/NestedObjectValitRule.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Valit.Exceptions; + +namespace Valit.Rules +{ + internal class NestedObjectValitRule : IValitRule where TObject : class where TProperty : class + { + public IEnumerable Tags { get; set; } + private readonly Func _propertySelector; + private readonly IValitator _valitator; + private readonly IValitStrategy _strategy; + + public NestedObjectValitRule( + Func selector, + IValitRulesProvider valitRulesProvider, + IValitStrategy strategy) + { + Tags = Enumerable.Empty(); + _propertySelector = selector; + _valitator = valitRulesProvider.CreateValitator(); + _strategy = strategy; + } + + public IValitResult Validate(TObject @object) + { + @object.ThrowIfNull(); + + var property = _propertySelector(@object); + return _valitator.Validate(property, _strategy); + } + + public IEnumerable> GetEnsureRules(TObject @object) => new [] { this }; + } +} diff --git a/src/Valit/Rules/ValitRule.cs b/src/Valit/Rules/ValitRule.cs index 91d63ea..9d425e4 100644 --- a/src/Valit/Rules/ValitRule.cs +++ b/src/Valit/Rules/ValitRule.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using Valit.Errors; using Valit.Exceptions; @@ -8,17 +8,17 @@ namespace Valit.Rules { internal class ValitRule : IValitRule, IValitRuleAccessor where TObject : class { - public IValitStrategy Strategy { get; } public IEnumerable Tags => _tags; Func IValitRuleAccessor.PropertySelector => _propertySelector; IValitRule IValitRuleAccessor.PreviousRule => _previousRule; - private readonly Func _propertySelector; + private readonly Func _propertySelector; private Predicate _predicate; + private readonly Func, TObject, IValitRule> _ruleFunc; private readonly List> _conditions; private readonly IValitRule _previousRule; - private readonly List _errors; + private readonly List _errors; private readonly List _tags; private readonly IValitMessageProvider _messageProvider; @@ -28,36 +28,41 @@ internal ValitRule(IValitRule previousRule) : this() _propertySelector = previousRuleAccessor.PropertySelector; _previousRule = previousRule; _messageProvider = previousRuleAccessor.GetMessageProvider(); - Strategy = previousRuleAccessor.Strategy; } - internal ValitRule(Func propertySelector, IValitStrategy strategy, IValitMessageProvider messageProvider) : this() + internal ValitRule(Func propertySelector, IValitMessageProvider messageProvider) : this() { _propertySelector = propertySelector; _messageProvider = messageProvider; - Strategy = strategy; + } + + internal ValitRule(Func propertySelector, IValitMessageProvider messageProvider, Func, TObject, IValitRule> ruleFunc) : this() + { + _propertySelector = propertySelector; + _messageProvider = messageProvider; + _ruleFunc = ruleFunc; } private ValitRule() - { + { _errors = new List(); _conditions = new List>(); _tags = new List(); - } + } - void IValitRuleAccessor.SetPredicate(Predicate predicate) + void IValitRuleAccessor.SetPredicate(Predicate predicate) => _predicate = predicate; bool IValitRuleAccessor.HasPredicate() - => _predicate != null; + => _predicate != null; - void IValitRuleAccessor.AddError(ValitRuleError error) + void IValitRuleAccessor.AddError(ValitRuleError error) => _errors.Add(error); - void IValitRuleAccessor.AddCondition(Predicate condition) - => _conditions.Add(condition); + void IValitRuleAccessor.AddCondition(Predicate condition) + => _conditions.Add(condition); - void IValitRuleAccessor.AddTags(params string[] tags) + void IValitRuleAccessor.AddTags(params string[] tags) => _tags.AddRange(tags); IValitMessageProvider IValitRuleAccessor.GetMessageProvider() @@ -67,18 +72,29 @@ IValitMessageProvider IValitRuleAccessor.GetMessageProvider() => _messageProvider as IValitMessageProvider; public IValitResult Validate(TObject @object) - { + { @object.ThrowIfNull(); var property = _propertySelector(@object); - var hasAllConditionsFulfilled = true; + var hasAllConditionsFulfilled = true; foreach(var condition in _conditions) hasAllConditionsFulfilled &= condition(@object); var isSatisfied = _predicate?.Invoke(property) != false; - return !hasAllConditionsFulfilled || isSatisfied ? ValitResult.Success : ValitResult.Fail(_errors.ToArray()); + return !hasAllConditionsFulfilled || isSatisfied ? ValitResult.Success : ValitResult.Fail(_errors.ToArray()); + } + + IEnumerable> IValitRule.GetEnsureRules(TObject @object) + { + @object.ThrowIfNull(); + + if(_ruleFunc == null) + { + return new [] { this }; + } + return _ruleFunc(this, @object).GetAllEnsureRules(); } - } + } } diff --git a/src/Valit/Rules/ValitRuleAccessorExtensions.cs b/src/Valit/Rules/ValitRuleAccessorExtensions.cs index b440f59..4bef588 100644 --- a/src/Valit/Rules/ValitRuleAccessorExtensions.cs +++ b/src/Valit/Rules/ValitRuleAccessorExtensions.cs @@ -1,4 +1,4 @@ -using Valit.Exceptions; +using Valit.Exceptions; namespace Valit.Rules { @@ -10,6 +10,6 @@ internal static IValitRuleAccessor GetAccessor : IValitator where TObject : class + { + private readonly IValitRulesStrategyPicker _strategyPicker; + + internal Valitator(IValitRulesProvider valitRulesProvider) + { + _strategyPicker = CreateStrategyPicker(valitRulesProvider); + } + + IValitResult IValitator.Validate(TObject @object, IValitStrategy strategy) + { + var selectedStrategy = strategy ?? new CompleteValitStrategy(); + + return _strategyPicker + .WithStrategy(selectedStrategy) + .For(@object) + .Validate(); + } + + private IValitRulesStrategyPicker CreateStrategyPicker(IValitRulesProvider valitRulesProvider) + { + var rules = valitRulesProvider.GetRules(); + return ValitRules.Create(rules); + } + } +} diff --git a/src/Valit/Valit.csproj b/src/Valit/Valit.csproj index 94366d4..9ca129f 100644 --- a/src/Valit/Valit.csproj +++ b/src/Valit/Valit.csproj @@ -1,4 +1,4 @@ - + Valit diff --git a/src/Valit/ValitException.cs b/src/Valit/ValitException.cs index eb5c111..8e3a2b2 100644 --- a/src/Valit/ValitException.cs +++ b/src/Valit/ValitException.cs @@ -4,9 +4,9 @@ namespace Valit { public class ValitException : Exception { - public ValitException(string message, Exception innerException) + public ValitException(string message, Exception innerException) :base(message, innerException) { } } -} \ No newline at end of file +} diff --git a/src/Valit/ValitRuleBooleanExtensions.cs b/src/Valit/ValitRuleBooleanExtensions.cs new file mode 100644 index 0000000..b6b29e3 --- /dev/null +++ b/src/Valit/ValitRuleBooleanExtensions.cs @@ -0,0 +1,32 @@ +namespace Valit +{ + public static class ValitRuleBooleanExtensions + { + public static IValitRule IsTrue(this IValitRule rule) where TObject : class + => rule.Satisfies(p => p); + + public static IValitRule IsTrue(this IValitRule rule) where TObject : class + => rule.Satisfies(p => p.HasValue && p == true); + + public static IValitRule IsFalse(this IValitRule rule) where TObject : class + => rule.Satisfies(p => !p); + + public static IValitRule IsFalse(this IValitRule rule) where TObject : class + => rule.Satisfies(p => p.HasValue && p == false); + + public static IValitRule IsEqualTo(this IValitRule rule, bool value) where TObject : class + => rule.Satisfies(p => p == value); + + public static IValitRule IsEqualTo(this IValitRule rule, bool? value) where TObject : class + => rule.Satisfies(p => value.HasValue && p == value.Value); + + public static IValitRule IsEqualTo(this IValitRule rule, bool value) where TObject : class + => rule.Satisfies(p => p.HasValue && p.Value == value); + + public static IValitRule IsEqualTo(this IValitRule rule, bool? value) where TObject : class + => rule.Satisfies(p => p.HasValue && value.HasValue && p.Value == value.Value); + + public static IValitRule Required(this IValitRule rule) where TObject : class + => rule.Satisfies(p => p.HasValue); + } +} diff --git a/src/Valit/ValitRuleDateTimeExtensions.cs b/src/Valit/ValitRuleDateTimeExtensions.cs index 7d0290c..efcd924 100644 --- a/src/Valit/ValitRuleDateTimeExtensions.cs +++ b/src/Valit/ValitRuleDateTimeExtensions.cs @@ -5,90 +5,90 @@ namespace Valit public static class ValitRuleDateTimeExtensions { public static IValitRule IsAfter(this IValitRule rule, DateTime datetime) where TObject : class - => rule.Satisfies(p => p > datetime); + => rule.Satisfies(p => p > datetime); public static IValitRule IsAfter(this IValitRule rule, DateTime? datetime) where TObject : class - => rule.Satisfies(p => datetime.HasValue && p > datetime.Value); + => rule.Satisfies(p => datetime.HasValue && p > datetime.Value); public static IValitRule IsAfter(this IValitRule rule, DateTime datetime) where TObject : class - => rule.Satisfies(p => p.HasValue && p.Value > datetime); + => rule.Satisfies(p => p.HasValue && p.Value > datetime); public static IValitRule IsAfter(this IValitRule rule, DateTime? datetime) where TObject : class - => rule.Satisfies(p => p.HasValue && datetime.HasValue && p.Value > datetime.Value); + => rule.Satisfies(p => p.HasValue && datetime.HasValue && p.Value > datetime.Value); public static IValitRule IsBefore(this IValitRule rule, DateTime datetime) where TObject : class - => rule.Satisfies(p => p < datetime); + => rule.Satisfies(p => p < datetime); public static IValitRule IsBefore(this IValitRule rule, DateTime? datetime) where TObject : class - => rule.Satisfies(p => datetime.HasValue && p < datetime.Value); + => rule.Satisfies(p => datetime.HasValue && p < datetime.Value); public static IValitRule IsBefore(this IValitRule rule, DateTime datetime) where TObject : class - => rule.Satisfies(p => p.HasValue && p.Value < datetime); + => rule.Satisfies(p => p.HasValue && p.Value < datetime); public static IValitRule IsBefore(this IValitRule rule, DateTime? datetime) where TObject : class - => rule.Satisfies(p => p.HasValue && datetime.HasValue && p.Value < datetime.Value); + => rule.Satisfies(p => p.HasValue && datetime.HasValue && p.Value < datetime.Value); public static IValitRule IsAfterOrSameAs(this IValitRule rule, DateTime datetime) where TObject : class - => rule.Satisfies(p => p >= datetime); + => rule.Satisfies(p => p >= datetime); public static IValitRule IsAfterOrSameAs(this IValitRule rule, DateTime? datetime) where TObject : class - => rule.Satisfies(p => datetime.HasValue && p >= datetime.Value); + => rule.Satisfies(p => datetime.HasValue && p >= datetime.Value); public static IValitRule IsAfterOrSameAs(this IValitRule rule, DateTime datetime) where TObject : class - => rule.Satisfies(p => p.HasValue && p.Value >= datetime); + => rule.Satisfies(p => p.HasValue && p.Value >= datetime); public static IValitRule IsAfterOrSameAs(this IValitRule rule, DateTime? datetime) where TObject : class - => rule.Satisfies(p => p.HasValue && datetime.HasValue && p.Value >= datetime.Value); + => rule.Satisfies(p => p.HasValue && datetime.HasValue && p.Value >= datetime.Value); public static IValitRule IsBeforeOrSameAs(this IValitRule rule, DateTime datetime) where TObject : class - => rule.Satisfies(p => p <= datetime); + => rule.Satisfies(p => p <= datetime); public static IValitRule IsBeforeOrSameAs(this IValitRule rule, DateTime? datetime) where TObject : class - => rule.Satisfies(p => datetime.HasValue && p <= datetime.Value); + => rule.Satisfies(p => datetime.HasValue && p <= datetime.Value); public static IValitRule IsBeforeOrSameAs(this IValitRule rule, DateTime datetime) where TObject : class - => rule.Satisfies(p => p.HasValue && p.Value <= datetime); + => rule.Satisfies(p => p.HasValue && p.Value <= datetime); public static IValitRule IsBeforeOrSameAs(this IValitRule rule, DateTime? datetime) where TObject : class - => rule.Satisfies(p => p.HasValue && datetime.HasValue && p.Value <= datetime.Value); + => rule.Satisfies(p => p.HasValue && datetime.HasValue && p.Value <= datetime.Value); public static IValitRule IsAfterNow(this IValitRule rule) where TObject : class - => rule.Satisfies(p => p > DateTime.Now); + => rule.Satisfies(p => p > DateTime.Now); public static IValitRule IsAfterNow(this IValitRule rule) where TObject : class - => rule.Satisfies(p => p.HasValue && p.Value > DateTime.Now); + => rule.Satisfies(p => p.HasValue && p.Value > DateTime.Now); public static IValitRule IsBeforeNow(this IValitRule rule) where TObject : class - => rule.Satisfies(p => p < DateTime.Now); + => rule.Satisfies(p => p < DateTime.Now); public static IValitRule IsBeforeNow(this IValitRule rule) where TObject : class - => rule.Satisfies(p => p.HasValue && p.Value < DateTime.Now); + => rule.Satisfies(p => p.HasValue && p.Value < DateTime.Now); public static IValitRule IsAfterUtcNow(this IValitRule rule) where TObject : class - => rule.Satisfies(p => p > DateTime.UtcNow); + => rule.Satisfies(p => p > DateTime.UtcNow); public static IValitRule IsAfterUtcNow(this IValitRule rule) where TObject : class - => rule.Satisfies(p => p.HasValue && p.Value > DateTime.UtcNow); + => rule.Satisfies(p => p.HasValue && p.Value > DateTime.UtcNow); public static IValitRule IsBeforeUtcNow(this IValitRule rule) where TObject : class - => rule.Satisfies(p => p < DateTime.UtcNow); + => rule.Satisfies(p => p < DateTime.UtcNow); public static IValitRule IsBeforeUtcNow(this IValitRule rule) where TObject : class - => rule.Satisfies(p => p.HasValue && p.Value < DateTime.UtcNow); + => rule.Satisfies(p => p.HasValue && p.Value < DateTime.UtcNow); public static IValitRule IsSameAs(this IValitRule rule, DateTime datetime) where TObject : class - => rule.Satisfies(p => p == datetime); + => rule.Satisfies(p => p == datetime); public static IValitRule IsSameAs(this IValitRule rule, DateTime? datetime) where TObject : class - => rule.Satisfies(p => datetime.HasValue && p == datetime.Value); + => rule.Satisfies(p => datetime.HasValue && p == datetime.Value); public static IValitRule IsSameAs(this IValitRule rule, DateTime datetime) where TObject : class - => rule.Satisfies(p => p.HasValue && p.Value == datetime); + => rule.Satisfies(p => p.HasValue && p.Value == datetime); public static IValitRule IsSameAs(this IValitRule rule, DateTime? datetime) where TObject : class - => rule.Satisfies(p => p.HasValue && datetime.HasValue && p.Value == datetime.Value); + => rule.Satisfies(p => p.HasValue && datetime.HasValue && p.Value == datetime.Value); public static IValitRule Required(this IValitRule rule) where TObject : class - => rule.Satisfies(p => p.HasValue); + => rule.Satisfies(p => p.HasValue); } -} \ No newline at end of file +} diff --git a/src/Valit/ValitRuleDateTimeOffsetExtensions.cs b/src/Valit/ValitRuleDateTimeOffsetExtensions.cs index 720b662..7c81054 100644 --- a/src/Valit/ValitRuleDateTimeOffsetExtensions.cs +++ b/src/Valit/ValitRuleDateTimeOffsetExtensions.cs @@ -91,4 +91,4 @@ public static IValitRule IsSameAs(this IValitR public static IValitRule Required(this IValitRule rule) where TObject : class => rule.Satisfies(p => p.HasValue); } -} \ No newline at end of file +} diff --git a/src/Valit/ValitRuleDecimalExtensions.cs b/src/Valit/ValitRuleDecimalExtensions.cs index 1bdcc9c..e9d2a97 100644 --- a/src/Valit/ValitRuleDecimalExtensions.cs +++ b/src/Valit/ValitRuleDecimalExtensions.cs @@ -3,85 +3,85 @@ namespace Valit public static class ValitRuleDecimalExtensions { public static IValitRule IsGreaterThan(this IValitRule rule, decimal value) where TObject : class - => rule.Satisfies(p => p > value); + => rule.Satisfies(p => p > value); public static IValitRule IsGreaterThan(this IValitRule rule, decimal? value) where TObject : class - => rule.Satisfies(p => value.HasValue && p > value.Value); + => rule.Satisfies(p => value.HasValue && p > value.Value); public static IValitRule IsGreaterThan(this IValitRule rule, decimal value) where TObject : class - => rule.Satisfies(p => p.HasValue && p.Value > value); + => rule.Satisfies(p => p.HasValue && p.Value > value); public static IValitRule IsGreaterThan(this IValitRule rule, decimal? value) where TObject : class - => rule.Satisfies(p => p.HasValue && value.HasValue && p.Value > value.Value); + => rule.Satisfies(p => p.HasValue && value.HasValue && p.Value > value.Value); public static IValitRule IsLessThan(this IValitRule rule, decimal value) where TObject : class - => rule.Satisfies(p => p < value); + => rule.Satisfies(p => p < value); public static IValitRule IsLessThan(this IValitRule rule, decimal? value) where TObject : class - => rule.Satisfies(p => value.HasValue && p < value.Value); + => rule.Satisfies(p => value.HasValue && p < value.Value); public static IValitRule IsLessThan(this IValitRule rule, decimal value) where TObject : class - => rule.Satisfies(p => p.HasValue && p.Value < value); + => rule.Satisfies(p => p.HasValue && p.Value < value); public static IValitRule IsLessThan(this IValitRule rule, decimal? value) where TObject : class - => rule.Satisfies(p => p.HasValue && value.HasValue && p.Value < value.Value); + => rule.Satisfies(p => p.HasValue && value.HasValue && p.Value < value.Value); public static IValitRule IsGreaterThanOrEqualTo(this IValitRule rule, decimal value) where TObject : class - => rule.Satisfies(p => p >= value); + => rule.Satisfies(p => p >= value); public static IValitRule IsGreaterThanOrEqualTo(this IValitRule rule, decimal? value) where TObject : class - => rule.Satisfies(p => value.HasValue && p >= value.Value); + => rule.Satisfies(p => value.HasValue && p >= value.Value); public static IValitRule IsGreaterThanOrEqualTo(this IValitRule rule, decimal value) where TObject : class - => rule.Satisfies(p => p.HasValue && p.Value >= value); + => rule.Satisfies(p => p.HasValue && p.Value >= value); public static IValitRule IsGreaterThanOrEqualTo(this IValitRule rule, decimal? value) where TObject : class - => rule.Satisfies(p => p.HasValue && value.HasValue && p.Value >= value.Value); + => rule.Satisfies(p => p.HasValue && value.HasValue && p.Value >= value.Value); public static IValitRule IsLessThanOrEqualTo(this IValitRule rule, decimal value) where TObject : class - => rule.Satisfies(p => p <= value); + => rule.Satisfies(p => p <= value); public static IValitRule IsLessThanOrEqualTo(this IValitRule rule, decimal? value) where TObject : class - => rule.Satisfies(p => value.HasValue && p <= value.Value); + => rule.Satisfies(p => value.HasValue && p <= value.Value); public static IValitRule IsLessThanOrEqualTo(this IValitRule rule, decimal value) where TObject : class - => rule.Satisfies(p => p.HasValue && p.Value <= value); + => rule.Satisfies(p => p.HasValue && p.Value <= value); public static IValitRule IsLessThanOrEqualTo(this IValitRule rule, decimal? value) where TObject : class - => rule.Satisfies(p => p.HasValue && value.HasValue && p.Value <= value.Value); + => rule.Satisfies(p => p.HasValue && value.HasValue && p.Value <= value.Value); public static IValitRule IsEqualTo(this IValitRule rule, decimal value) where TObject : class - => rule.Satisfies(p => p == value); + => rule.Satisfies(p => p == value); public static IValitRule IsEqualTo(this IValitRule rule, decimal? value) where TObject : class - => rule.Satisfies(p => value.HasValue && p == value.Value); + => rule.Satisfies(p => value.HasValue && p == value.Value); public static IValitRule IsEqualTo(this IValitRule rule, decimal value) where TObject : class - => rule.Satisfies(p => p.HasValue && p.Value == value); + => rule.Satisfies(p => p.HasValue && p.Value == value); public static IValitRule IsEqualTo(this IValitRule rule, decimal? value) where TObject : class - => rule.Satisfies(p => p.HasValue && value.HasValue && p.Value == value.Value); + => rule.Satisfies(p => p.HasValue && value.HasValue && p.Value == value.Value); public static IValitRule IsPositive(this IValitRule rule) where TObject : class => rule.Satisfies(p => p > 0m); public static IValitRule IsPositive(this IValitRule rule) where TObject : class - => rule.Satisfies(p => p.HasValue && p.Value > 0m); + => rule.Satisfies(p => p.HasValue && p.Value > 0m); public static IValitRule IsNegative(this IValitRule rule) where TObject : class => rule.Satisfies(p => p < 0m); public static IValitRule IsNegative(this IValitRule rule) where TObject : class - => rule.Satisfies(p => p.HasValue && p.Value < 0m); + => rule.Satisfies(p => p.HasValue && p.Value < 0m); public static IValitRule IsNonZero(this IValitRule rule) where TObject : class => rule.Satisfies(p => p != 0m); public static IValitRule IsNonZero(this IValitRule rule) where TObject : class - => rule.Satisfies(p => p.HasValue && p.Value != 0m); + => rule.Satisfies(p => p.HasValue && p.Value != 0m); public static IValitRule Required(this IValitRule rule) where TObject : class - => rule.Satisfies(p => p.HasValue); + => rule.Satisfies(p => p.HasValue); } -} \ No newline at end of file +} diff --git a/src/Valit/ValitRuleDoubleExtensions.cs b/src/Valit/ValitRuleDoubleExtensions.cs index f691d85..aa17a0a 100644 --- a/src/Valit/ValitRuleDoubleExtensions.cs +++ b/src/Valit/ValitRuleDoubleExtensions.cs @@ -97,4 +97,4 @@ public static IValitRule IsNaN(this IValitRule Required(this IValitRule rule) where TObject : class => rule.Satisfies(p => p.HasValue); } -} \ No newline at end of file +} diff --git a/src/Valit/ValitRuleEnumerableExtensions.cs b/src/Valit/ValitRuleEnumerableExtensions.cs index 7b6dd4a..a49a16a 100644 --- a/src/Valit/ValitRuleEnumerableExtensions.cs +++ b/src/Valit/ValitRuleEnumerableExtensions.cs @@ -4,7 +4,7 @@ namespace Valit { public static class ValitRuleEnumerableExtensions - { + { public static IValitRule> MinItems(this IValitRule> rule, int expectedItemsNumber) where TObject : class => rule.Satisfies(p => p != null && p.Count() >= expectedItemsNumber); @@ -12,4 +12,4 @@ public static IValitRule> MinItems> MaxItems(this IValitRule> rule, int expectedItemsNumber) where TObject : class => rule.Satisfies(p => p != null && p.Count() <= expectedItemsNumber); } -} \ No newline at end of file +} diff --git a/src/Valit/ValitRuleFloatExtensions.cs b/src/Valit/ValitRuleFloatExtensions.cs index 96cf947..bc065a8 100644 --- a/src/Valit/ValitRuleFloatExtensions.cs +++ b/src/Valit/ValitRuleFloatExtensions.cs @@ -97,4 +97,4 @@ public static IValitRule IsNaN(this IValitRule Required(this IValitRule rule) where TObject : class => rule.Satisfies(p => p.HasValue); } -} \ No newline at end of file +} diff --git a/src/Valit/ValitRuleGuidExtensions.cs b/src/Valit/ValitRuleGuidExtensions.cs index 973ed4c..ebb2ec2 100644 --- a/src/Valit/ValitRuleGuidExtensions.cs +++ b/src/Valit/ValitRuleGuidExtensions.cs @@ -6,10 +6,10 @@ public static class ValitRuleGuidExtensions { public static IValitRule IsEqualTo(this IValitRule rule, Guid guid) where TObject : class => rule.Satisfies(p => p == guid); - + public static IValitRule IsEqualTo(this IValitRule rule, Guid? guid) where TObject : class => rule.Satisfies(p => guid.HasValue && p == guid.Value); - + public static IValitRule IsEqualTo(this IValitRule rule, Guid? guid) where TObject : class => rule.Satisfies(p => p.HasValue && guid.HasValue && p.Value == guid.Value); @@ -25,4 +25,4 @@ public static IValitRule IsNotEmpty(this IValitRule IsNotEmpty(this IValitRule rule) where TObject : class => rule.Satisfies(p => p.HasValue && p.Value != Guid.Empty); } -} \ No newline at end of file +} diff --git a/src/Valit/ValitRuleInt16Extensions.cs b/src/Valit/ValitRuleInt16Extensions.cs index 62e6f09..272e2d2 100644 --- a/src/Valit/ValitRuleInt16Extensions.cs +++ b/src/Valit/ValitRuleInt16Extensions.cs @@ -83,4 +83,4 @@ public static IValitRule IsNonZero(this IValitRule Required(this IValitRule rule) where TObject : class => rule.Satisfies(p => p.HasValue); } -} \ No newline at end of file +} diff --git a/src/Valit/ValitRuleInt32Extensions.cs b/src/Valit/ValitRuleInt32Extensions.cs index e383c84..ce1f2aa 100644 --- a/src/Valit/ValitRuleInt32Extensions.cs +++ b/src/Valit/ValitRuleInt32Extensions.cs @@ -83,4 +83,4 @@ public static IValitRule IsNonZero(this IValitRule Required(this IValitRule rule) where TObject : class => rule.Satisfies(p => p.HasValue); } -} \ No newline at end of file +} diff --git a/src/Valit/ValitRuleInt64Extensions.cs b/src/Valit/ValitRuleInt64Extensions.cs index 83ffb62..baf933b 100644 --- a/src/Valit/ValitRuleInt64Extensions.cs +++ b/src/Valit/ValitRuleInt64Extensions.cs @@ -93,4 +93,4 @@ public static IValitRule IsNonZero(this IValitRule Required(this IValitRule rule) where TObject : class => rule.Satisfies(p => p.HasValue); } -} \ No newline at end of file +} diff --git a/src/Valit/ValitRulePropertyExtensions.cs b/src/Valit/ValitRulePropertyExtensions.cs index 60a987e..aa6e5e3 100644 --- a/src/Valit/ValitRulePropertyExtensions.cs +++ b/src/Valit/ValitRulePropertyExtensions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using Valit.Errors; using Valit.Exceptions; @@ -23,7 +23,7 @@ public static IValitRule Satisfies(this } var newRule = new ValitRule(rule); - accessor = newRule.GetAccessor(); + accessor = newRule.GetAccessor(); accessor.SetPredicate(predicate); return newRule; } @@ -35,23 +35,36 @@ public static IValitRule Required(this I public static IValitRule When(this IValitRule rule, Predicate condition) where TObject : class { - rule.ThrowIfNull(ValitExceptionMessages.NullRule); + rule.ThrowIfNull(ValitExceptionMessages.NullRule); condition.ThrowIfNull(ValitExceptionMessages.NullPredicate); var accessor = rule.GetAccessor(); - accessor.AddCondition(condition); + accessor.AddCondition(condition); + return rule; + } + + public static IValitRule WithMessage( + this IValitRule rule, Func messageFunc) where TObject : class + { + rule.ThrowIfNull(ValitExceptionMessages.NullRule); + messageFunc.ThrowIfNull(); + + var accessor = rule.GetAccessor(); + + var error = ValitRuleError.CreateForMessage(messageFunc); + accessor.AddError(error); return rule; } public static IValitRule WithMessage(this IValitRule rule, string message) where TObject : class { rule.ThrowIfNull(ValitExceptionMessages.NullRule); - message.ThrowIfNull(); - + message.ThrowIfNull(); + var accessor = rule.GetAccessor(); - - var error = ValitRuleError.CreateForMessage(message); + + var error = ValitRuleError.CreateForMessage(() => message); accessor.AddError(error); return rule; } @@ -62,32 +75,31 @@ public static IValitRule WithMessageKey(); - var message = messageProvider.GetByKey(messageKey); - var error = ValitRuleError.CreateForMessage(message); + var error = ValitRuleError.CreateForMessage(() => messageProvider.GetByKey(messageKey)); accessor.AddError(error); return rule; } public static IValitRule WithErrorCode(this IValitRule rule, int errorCode) where TObject : class { - rule.ThrowIfNull(ValitExceptionMessages.NullRule); - + rule.ThrowIfNull(ValitExceptionMessages.NullRule); + var accessor = rule.GetAccessor(); var error = ValitRuleError.CreateForErrorCode(errorCode); accessor.AddError(error); return rule; - } + } public static IValitRule Tag(this IValitRule rule, params string[] tags) where TObject : class { - rule.ThrowIfNull(ValitExceptionMessages.NullRule); + rule.ThrowIfNull(ValitExceptionMessages.NullRule); tags.ThrowIfNull(); var accessor = rule.GetAccessor(); - accessor.AddTags(tags); + accessor.AddTags(tags); return rule; } @@ -104,7 +116,7 @@ internal static IEnumerable> GetAllEnsureRules(this IValitRule rule) where TObject : class => rule.GetAccessor().PreviousRule == null && ! rule.GetAccessor().HasPredicate(); diff --git a/src/Valit/ValitRuleSByteExtensions.cs b/src/Valit/ValitRuleSByteExtensions.cs index 949cb9f..b61abad 100644 --- a/src/Valit/ValitRuleSByteExtensions.cs +++ b/src/Valit/ValitRuleSByteExtensions.cs @@ -93,4 +93,4 @@ public static IValitRule IsNonZero(this IValitRule Required(this IValitRule rule) where TObject : class => rule.Satisfies(p => p.HasValue); } -} \ No newline at end of file +} diff --git a/src/Valit/ValitRuleStringExtensions.cs b/src/Valit/ValitRuleStringExtensions.cs index 58e57bf..e9df61c 100644 --- a/src/Valit/ValitRuleStringExtensions.cs +++ b/src/Valit/ValitRuleStringExtensions.cs @@ -19,5 +19,8 @@ public static IValitRule Matches(this IValitRule Email(this IValitRule rule) where TObject : class => rule.Matches(@"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z"); + + public static IValitRule Required(this IValitRule rule) where TObject : class + => rule.Satisfies(p => !string.IsNullOrEmpty(p)); } -} \ No newline at end of file +} diff --git a/src/Valit/ValitRuleTimeSpanExtensions.cs b/src/Valit/ValitRuleTimeSpanExtensions.cs index f4eceff..6d14ba9 100644 --- a/src/Valit/ValitRuleTimeSpanExtensions.cs +++ b/src/Valit/ValitRuleTimeSpanExtensions.cs @@ -73,4 +73,4 @@ public static IValitRule IsNonZero(this IValitRule Required(this IValitRule rule) where TObject : class => rule.Satisfies(p => p.HasValue); } -} \ No newline at end of file +} diff --git a/src/Valit/ValitRuleUInt16Extensions.cs b/src/Valit/ValitRuleUInt16Extensions.cs index d23afef..f640c03 100644 --- a/src/Valit/ValitRuleUInt16Extensions.cs +++ b/src/Valit/ValitRuleUInt16Extensions.cs @@ -80,4 +80,4 @@ public static IValitRule IsNonZero(this IValitRule Required(this IValitRule rule) where TObject : class => rule.Satisfies(p => p.HasValue); } -} \ No newline at end of file +} diff --git a/src/Valit/ValitRuleUInt32Extensions.cs b/src/Valit/ValitRuleUInt32Extensions.cs index e8d7360..e2e741a 100644 --- a/src/Valit/ValitRuleUInt32Extensions.cs +++ b/src/Valit/ValitRuleUInt32Extensions.cs @@ -81,4 +81,4 @@ public static IValitRule IsNonZero(this IValitRule Required(this IValitRule rule) where TObject : class => rule.Satisfies(p => p.HasValue); } -} \ No newline at end of file +} diff --git a/src/Valit/ValitRuleUInt64Extensions.cs b/src/Valit/ValitRuleUInt64Extensions.cs index 9043427..0f60975 100644 --- a/src/Valit/ValitRuleUInt64Extensions.cs +++ b/src/Valit/ValitRuleUInt64Extensions.cs @@ -80,4 +80,4 @@ public static IValitRule IsNonZero(this IValitRule Required(this IValitRule rule) where TObject : class => rule.Satisfies(p => p.HasValue); } -} \ No newline at end of file +} diff --git a/src/Valit/ValitRules.cs b/src/Valit/ValitRules.cs index 0f79653..12b186e 100644 --- a/src/Valit/ValitRules.cs +++ b/src/Valit/ValitRules.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using Valit.Exceptions; @@ -8,19 +8,19 @@ namespace Valit { - public class ValitRules : + public class ValitRules : IValitRules, - IValitRulesMessageProvider, - IValitRulesStrategyPicker + IValitRulesMessageProvider, + IValitRulesStrategyPicker where TObject : class { - private TObject _object; + private TObject _object; private readonly List> _rules; private IValitStrategy _strategy; private IValitMessageProvider _messageProvider; private ValitRules(IEnumerable> rules) - { + { _rules = rules?.ToList() ?? new List>(); _strategy = default(DefaultValitStrategies).Complete; _messageProvider = new EmptyMessageProvider(); @@ -41,19 +41,62 @@ IValitRules IValitRulesStrategyPicker.WithStrategy(IValitStrat return this; } - IValitRules IValitRules.Ensure(Func selector, Func,IValitRule> ruleFunc) - { + IValitRules IValitRules.Ensure(Func selector, Func, IValitRule> ruleFunc) + { + selector.ThrowIfNull(); + ruleFunc.ThrowIfNull(); + AddEnsureRulesAccessors(selector, ruleFunc); return this; } + IValitRules IValitRules.Ensure(Func selector, IValitRulesProvider valitRulesProvider) + { + selector.ThrowIfNull(); + valitRulesProvider.ThrowIfNull(); + + var nestedValitRule = new NestedObjectValitRule(selector, valitRulesProvider, _strategy); + _rules.Add(nestedValitRule); + return this; + } + + IValitRules IValitRules.Ensure(Func selector, Func, TObject, IValitRule> ruleFunc) + { + selector.ThrowIfNull(); + ruleFunc.ThrowIfNull(); + + var lastEnsureRule = new ValitRule(selector, _messageProvider, ruleFunc); + _rules.AddRange(lastEnsureRule.GetAllEnsureRules()); + return this; + } + + IValitRules IValitRules.EnsureFor(Func> selector, Func, IValitRule> ruleFunc) + { + selector.ThrowIfNull(); + ruleFunc.ThrowIfNull(); + + var collectionValitRule = new CollectionValitRule(selector, ruleFunc, _strategy, _messageProvider); + _rules.Add(collectionValitRule); + return this; + } + + IValitRules IValitRules.EnsureFor(Func> selector, IValitRulesProvider valitRulesProvider) + { + selector.ThrowIfNull(); + valitRulesProvider.ThrowIfNull(); + + var collectionValitRule = new NestedObjectCollectionValitRule(selector, valitRulesProvider, _strategy); + _rules.Add(collectionValitRule); + return this; + } + IValitRules IValitRules.For(TObject @object) { @object.ThrowIfNull(); _object = @object; return this; - } + } IEnumerable> IValitRules.GetAllRules() => _rules; @@ -61,14 +104,14 @@ IEnumerable> IValitRules.GetAllRules() IEnumerable> IValitRules.GetTaggedRules() => _rules.Where(r => r.Tags.Any()); - IEnumerable> IValitRules.GetUntaggedRules() + IEnumerable> IValitRules.GetUntaggedRules() => _rules.Where(r => !r.Tags.Any()); IValitResult IValitRules.Validate() => Validate(_rules); - IValitResult IValitRules.Validate(params string[] tags) - { + IValitResult IValitRules.Validate(params string[] tags) + { tags.ThrowIfNull(); var taggedRules = _rules.Where(r => r.Tags.Intersect(tags).Any()); @@ -76,7 +119,7 @@ IValitResult IValitRules.Validate(params string[] tags) } IValitResult IValitRules.Validate(Func, bool> predicate) - { + { predicate.ThrowIfNull(ValitExceptionMessages.NullPredicate); var taggedRules = _rules.Where(predicate); @@ -86,31 +129,47 @@ IValitResult IValitRules.Validate(Func, bool> predi private IValitResult Validate(IEnumerable> rules) { var result = ValitResult.Success; - foreach(var rule in rules.ToList()) { - result &= rule.Validate(_object); + result &= ValidateRule(rule, out bool cancel); + if (cancel) + { + break; + } + } - if(!result.Succeeded) + _strategy.Done(result); + + return result; + } + + private IValitResult ValidateRule(IValitRule rule, out bool cancelValidation) + { + var result = ValitResult.Success; + cancelValidation = false; + var ensureRules = rule.GetEnsureRules(_object); + foreach(var ensureRule in ensureRules) + { + result &= ensureRule.Validate(_object); + if (!result.Succeeded) { - _strategy.Fail(rule, result, out bool cancel); - if(cancel) + _strategy.Fail(ensureRule, result, out bool cancel); + if (cancel) { + cancelValidation = true; break; } } } - _strategy.Done(result); - return result; } private void AddEnsureRulesAccessors(Func propertySelector, Func,IValitRule> ruleFunc) { - var lastEnsureRule = ruleFunc(new ValitRule(propertySelector, _strategy, _messageProvider)); + var lastEnsureRule = ruleFunc(new ValitRule(propertySelector, _messageProvider)); var ensureRules = lastEnsureRule.GetAllEnsureRules(); _rules.AddRange(ensureRules); } - } + } } diff --git a/src/Valit/ValitRulesProviderExtensions.cs b/src/Valit/ValitRulesProviderExtensions.cs new file mode 100644 index 0000000..93b14eb --- /dev/null +++ b/src/Valit/ValitRulesProviderExtensions.cs @@ -0,0 +1,14 @@ +using Valit.Exceptions; +using Valit.Validators; + +namespace Valit +{ + public static class ValitRulesProviderExtensions + { + public static IValitator CreateValitator(this IValitRulesProvider valitRulesProvider) where TObject : class + { + valitRulesProvider.ThrowIfNull(); + return new Valitator(valitRulesProvider); + } + } +} diff --git a/src/Valit/ValitStrategies.cs b/src/Valit/ValitStrategies.cs index 2de3184..60a59d0 100644 --- a/src/Valit/ValitStrategies.cs +++ b/src/Valit/ValitStrategies.cs @@ -1,10 +1,10 @@ -namespace Valit +namespace Valit { public struct DefaultValitStrategies { static readonly CompleteValitStrategy _complete = new CompleteValitStrategy(); static readonly FailFastValitStrategy _failFast = new FailFastValitStrategy(); - + public CompleteValitStrategy Complete => _complete; public FailFastValitStrategy FailFast => _failFast; diff --git a/src/Valit/ValitStrategiesExtensions.cs b/src/Valit/ValitStrategiesExtensions.cs index 6b94e4a..d327381 100644 --- a/src/Valit/ValitStrategiesExtensions.cs +++ b/src/Valit/ValitStrategiesExtensions.cs @@ -12,4 +12,4 @@ public static IValitRules WithStrategy(this IValitRulesStrateg return that.WithStrategy(strat); } } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Boolean/Boolean_IsEqual_To_Tests.cs b/tests/Valit.Tests/Boolean/Boolean_IsEqual_To_Tests.cs new file mode 100644 index 0000000..30d74cf --- /dev/null +++ b/tests/Valit.Tests/Boolean/Boolean_IsEqual_To_Tests.cs @@ -0,0 +1,105 @@ +using System; +using Shouldly; +using Xunit; + +namespace Valit.Tests.Boolean +{ + public class Boolean_IsEqualTo_Tests + { + [Fact] + public void Boolean_IsEqualTo_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Given() + { + var exception = Record.Exception(() => + { + ((IValitRule)null) + .IsEqualTo(true); + }); + + exception.ShouldBeOfType(typeof(ValitException)); + } + + [Fact] + public void Boolean_IsEqualTo_For_Not_Nullable_Value_And_Nullable_Value_Throws_When_Null_Rule_Is_Given() + { + var exception = Record.Exception(() => + { + ((IValitRule)null) + .IsEqualTo((bool?)true); + }); + + exception.ShouldBeOfType(typeof(ValitException)); + } + + [Fact] + public void Boolean_IsEqualTo_For_Nullable_Value_And_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() + { + var exception = Record.Exception(() => + { + ((IValitRule)null) + .IsEqualTo(true); + }); + + exception.ShouldBeOfType(typeof(ValitException)); + } + + [Fact] + public void Boolean_IsEqualTo_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() + { + var exception = Record.Exception(() => + { + ((IValitRule)null) + .IsEqualTo((bool?)true); + }); + + exception.ShouldBeOfType(typeof(ValitException)); + } + + [Theory] + [InlineData(true, true)] + [InlineData(false, false)] + public void Boolean_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(bool value, bool expected) + { + IValitResult result = ValitRules + .Create() + .Ensure(m => m.Value, _ => _ + .IsEqualTo(value)) + .For(_model) + .Validate(); + + Assert.Equal(result.Succeeded, expected); + } + + [Theory] + [InlineData(false, true, true)] + [InlineData(false, false, false)] + [InlineData(true, true, false)] + [InlineData(true, false, false)] + public void Boolean_IsEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, bool value, bool expected) + { + IValitResult result = ValitRules + .Create() + .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ + .IsEqualTo(value)) + .For(_model) + .Validate(); + + Assert.Equal(result.Succeeded, expected); + } + + #region ARRANGE + public Boolean_IsEqualTo_Tests() + { + _model = new Model(); + } + + private readonly Model _model; + + class Model + { + public bool Value => true; + public bool? NullableValue => true; + public bool? NullValue => null; + } + #endregion + } +} diff --git a/tests/Valit.Tests/Boolean/Boolean_IsFalse_Tests.cs b/tests/Valit.Tests/Boolean/Boolean_IsFalse_Tests.cs new file mode 100644 index 0000000..691716f --- /dev/null +++ b/tests/Valit.Tests/Boolean/Boolean_IsFalse_Tests.cs @@ -0,0 +1,95 @@ +using System; +using Shouldly; +using Xunit; + +namespace Valit.Tests.Boolean +{ + public class Boolean_IsFalse_Tests + { + [Fact] + public void Boolean_IsFalse_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() + { + var exception = Record.Exception(() => + { + ((IValitRule)null) + .IsFalse(); + }); + + exception.ShouldBeOfType(typeof(ValitException)); + } + + [Fact] + public void Boolean_IsFalse_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() + { + var exception = Record.Exception(() => + { + ((IValitRule)null) + .IsFalse(); + }); + + exception.ShouldBeOfType(typeof(ValitException)); + } + + [Theory] + [InlineData(true, false)] + [InlineData(false, true)] + public void Boolean_IsFalse_Returns_Proper_Results_For_Not_Nullable_Values(bool useTrueValue, bool expected) + { + IValitResult result = ValitRules + .Create() + .Ensure(m => useTrueValue ? m.TrueValue : m.FalseValue, _ => _ + .IsFalse()) + .For(_model) + .Validate(); + + Assert.Equal(result.Succeeded, expected); + } + + [Theory] + [InlineData(true, false)] + [InlineData(false, true)] + public void Boolean_IsFalse_Returns_Proper_Results_For_Nullable_Values(bool useTrueValue, bool expected) + { + IValitResult result = ValitRules + .Create() + .Ensure(m => useTrueValue ? m.NullableTrueValue : m.NullableFalseValue, _ => _ + .IsFalse()) + .For(_model) + .Validate(); + + Assert.Equal(result.Succeeded, expected); + } + + [Fact] + public void Boolean_IsFalse_Fails_For_Null_Value() + { + IValitResult result = ValitRules + .Create() + .Ensure(m => m.NullValue, _ => _ + .IsFalse()) + .For(_model) + .Validate(); + + Assert.Equal(result.Succeeded, false); + } + + + #region ARRANGE + public Boolean_IsFalse_Tests() + { + _model = new Model(); + } + + private readonly Model _model; + + class Model + { + public bool TrueValue => true; + public bool FalseValue => false; + public bool? NullableTrueValue => true; + public bool? NullableFalseValue => false; + public bool? NullValue => null; + } + #endregion + } +} diff --git a/tests/Valit.Tests/Boolean/Boolean_IsTrue_Tests.cs b/tests/Valit.Tests/Boolean/Boolean_IsTrue_Tests.cs new file mode 100644 index 0000000..ca0304b --- /dev/null +++ b/tests/Valit.Tests/Boolean/Boolean_IsTrue_Tests.cs @@ -0,0 +1,95 @@ +using System; +using Shouldly; +using Xunit; + +namespace Valit.Tests.Boolean +{ + public class Boolean_IsTrue_Tests + { + [Fact] + public void Boolean_IsTrue_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() + { + var exception = Record.Exception(() => + { + ((IValitRule)null) + .IsTrue(); + }); + + exception.ShouldBeOfType(typeof(ValitException)); + } + + [Fact] + public void Boolean_IsTrue_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() + { + var exception = Record.Exception(() => + { + ((IValitRule)null) + .IsTrue(); + }); + + exception.ShouldBeOfType(typeof(ValitException)); + } + + [Theory] + [InlineData(true, true)] + [InlineData(false, false)] + public void Boolean_IsTrue_Returns_Proper_Results_For_Not_Nullable_Values(bool useTrueValue, bool expected) + { + IValitResult result = ValitRules + .Create() + .Ensure(m => useTrueValue ? m.TrueValue : m.FalseValue, _ => _ + .IsTrue()) + .For(_model) + .Validate(); + + Assert.Equal(result.Succeeded, expected); + } + + [Theory] + [InlineData(true, true)] + [InlineData(false, false)] + public void Boolean_IsTrue_Returns_Proper_Results_For_Nullable_Values(bool useTrueValue, bool expected) + { + IValitResult result = ValitRules + .Create() + .Ensure(m => useTrueValue ? m.NullableTrueValue : m.NullableFalseValue, _ => _ + .IsTrue()) + .For(_model) + .Validate(); + + Assert.Equal(result.Succeeded, expected); + } + + [Fact] + public void Boolean_IsTrue_Fails_For_Null_Value() + { + IValitResult result = ValitRules + .Create() + .Ensure(m => m.NullValue, _ => _ + .IsTrue()) + .For(_model) + .Validate(); + + Assert.Equal(result.Succeeded, false); + } + + + #region ARRANGE + public Boolean_IsTrue_Tests() + { + _model = new Model(); + } + + private readonly Model _model; + + class Model + { + public bool TrueValue => true; + public bool FalseValue => false; + public bool? NullableTrueValue => true; + public bool? NullableFalseValue => false; + public bool? NullValue => null; + } + #endregion + } +} diff --git a/tests/Valit.Tests/Boolean/Boolean_Required_Tests.cs b/tests/Valit.Tests/Boolean/Boolean_Required_Tests.cs new file mode 100644 index 0000000..2e1f58e --- /dev/null +++ b/tests/Valit.Tests/Boolean/Boolean_Required_Tests.cs @@ -0,0 +1,51 @@ +using Shouldly; +using Xunit; + +namespace Valit.Tests.Boolean +{ + public class Boolean_Required_Tests + { + [Fact] + public void Boolean_Required_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() + { + var exception = Record.Exception(() => + { + ((IValitRule)null) + .Required(); + }); + + exception.ShouldBeOfType(typeof(ValitException)); + } + + + [Theory] + [InlineData(false, true)] + [InlineData(true, false)] + public void Boolean_Required_Returns_Proper_Results_For_Nullable_Value(bool useNullValue, bool expected) + { + IValitResult result = ValitRules + .Create() + .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ + .Required()) + .For(_model) + .Validate(); + + Assert.Equal(result.Succeeded, expected); + } + + #region ARRANGE + public Boolean_Required_Tests() + { + _model = new Model(); + } + + private readonly Model _model; + + class Model + { + public bool? NullableValue => true; + public bool? NullValue => null; + } + #endregion + } +} diff --git a/tests/Valit.Tests/Byte/Byte_IsEqual_To_Tests.cs b/tests/Valit.Tests/Byte/Byte_IsEqual_To_Tests.cs index df11316..368ff19 100644 --- a/tests/Valit.Tests/Byte/Byte_IsEqual_To_Tests.cs +++ b/tests/Valit.Tests/Byte/Byte_IsEqual_To_Tests.cs @@ -12,7 +12,7 @@ public void Byte_IsEqualTo_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Give ((IValitRule)null) .IsEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void Byte_IsEqualTo_For_Not_Nullable_Value_And_Nullable_Value_Throws_When ((IValitRule)null) .IsEqualTo((byte?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void Byte_IsEqualTo_For_Nullable_Value_And_Not_Nullable_Value_Throws_When ((IValitRule)null) .IsEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void Byte_IsEqualTo_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsEqualTo((byte?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void Byte_IsEqualTo_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() [Theory] [InlineData(10, true)] [InlineData(9, false)] - [InlineData(11, false)] + [InlineData(11, false)] public void Byte_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(byte value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void Byte_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(byte v [Theory] [InlineData((byte) 10, true)] [InlineData((byte) 9, false)] - [InlineData((byte) 11, false)] - [InlineData(null, false)] + [InlineData((byte) 11, false)] + [InlineData(null, false)] public void Byte_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(byte? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void Byte_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nul [Theory] [InlineData(false, 10, true)] - [InlineData(false, 9, false)] - [InlineData(false, 11, false)] - [InlineData(true, 10, false)] + [InlineData(false, 9, false)] + [InlineData(false, 11, false)] + [InlineData(true, 10, false)] public void Byte_IsEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, byte value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void Byte_IsEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nul } [Theory] - [InlineData(false, (byte) 10, true)] - [InlineData(false, (byte) 9, false)] + [InlineData(false, (byte) 10, true)] + [InlineData(false, (byte) 9, false)] [InlineData(false, (byte) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (byte) 10, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (byte) 10, false)] + [InlineData(true, null, false)] public void Byte_IsEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, byte? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -133,6 +133,6 @@ class Model public byte? NullableValue => 10; public byte? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Byte/Byte_IsGreaterThanOrEqualTo_Tests.cs b/tests/Valit.Tests/Byte/Byte_IsGreaterThanOrEqualTo_Tests.cs index bc5dcb2..150d193 100644 --- a/tests/Valit.Tests/Byte/Byte_IsGreaterThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/Byte/Byte_IsGreaterThanOrEqualTo_Tests.cs @@ -12,7 +12,7 @@ public void Byte_IsGreaterThanOrEqualTo_For_Not_Nullable_Values_Throws_When_Null ((IValitRule)null) .IsGreaterThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void Byte_IsGreaterThanOrEqualTo_For_Not_Nullable_Value_And_Nullable_Valu ((IValitRule)null) .IsGreaterThanOrEqualTo((byte?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void Byte_IsGreaterThanOrEqualTo_For_Nullable_Value_And_Not_Nullable_Valu ((IValitRule)null) .IsGreaterThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void Byte_IsGreaterThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Rul ((IValitRule)null) .IsGreaterThanOrEqualTo((byte?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void Byte_IsGreaterThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Rul [Theory] [InlineData(9, true)] [InlineData(10, true)] - [InlineData(11, false)] + [InlineData(11, false)] public void Byte_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(byte value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void Byte_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_ [Theory] [InlineData((byte) 9, true)] [InlineData((byte) 10, true)] - [InlineData((byte) 11, false)] - [InlineData(null, false)] + [InlineData((byte) 11, false)] + [InlineData(null, false)] public void Byte_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(byte? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void Byte_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_ [Theory] [InlineData(false, 9, true)] - [InlineData(false, 10, true)] - [InlineData(false, 11, false)] - [InlineData(true, 9, false)] + [InlineData(false, 10, true)] + [InlineData(false, 11, false)] + [InlineData(true, 9, false)] public void Byte_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, byte value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void Byte_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Valu } [Theory] - [InlineData(false, (byte) 9, true)] - [InlineData(false, (byte) 10, true)] + [InlineData(false, (byte) 9, true)] + [InlineData(false, (byte) 10, true)] [InlineData(false, (byte) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (byte) 9, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (byte) 9, false)] + [InlineData(true, null, false)] public void Byte_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, byte? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -135,4 +135,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Byte/Byte_IsGreaterThan_Tests.cs b/tests/Valit.Tests/Byte/Byte_IsGreaterThan_Tests.cs index 22f83ec..5226cf3 100644 --- a/tests/Valit.Tests/Byte/Byte_IsGreaterThan_Tests.cs +++ b/tests/Valit.Tests/Byte/Byte_IsGreaterThan_Tests.cs @@ -13,7 +13,7 @@ public void Byte_IsGreaterThan_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_ ((IValitRule)null) .IsGreaterThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -24,7 +24,7 @@ public void Byte_IsGreaterThan_For_Not_Nullable_Value_And_Nullable_Value_Throws_ ((IValitRule)null) .IsGreaterThan((byte?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -35,7 +35,7 @@ public void Byte_IsGreaterThan_For_Nullable_Value_And_Not_Nullable_Value_Throws_ ((IValitRule)null) .IsGreaterThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -46,7 +46,7 @@ public void Byte_IsGreaterThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Give ((IValitRule)null) .IsGreaterThan((byte?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -54,9 +54,9 @@ public void Byte_IsGreaterThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Give [Theory] [InlineData(9, true)] [InlineData(10, false)] - [InlineData(11, false)] + [InlineData(11, false)] public void Byte_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Values(byte value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -70,10 +70,10 @@ public void Byte_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Values(by [Theory] [InlineData((byte) 9, true)] [InlineData((byte) 10, false)] - [InlineData((byte) 11, false)] - [InlineData(null, false)] + [InlineData((byte) 11, false)] + [InlineData(null, false)] public void Byte_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(byte? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -86,11 +86,11 @@ public void Byte_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Value_And [Theory] [InlineData(false, 9, true)] - [InlineData(false, 10, false)] - [InlineData(false, 11, false)] - [InlineData(true, 9, false)] + [InlineData(false, 10, false)] + [InlineData(false, 11, false)] + [InlineData(true, 9, false)] public void Byte_IsGreaterThan_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, byte value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -102,14 +102,14 @@ public void Byte_IsGreaterThan_Returns_Proper_Results_For_Nullable_Value_And_Not } [Theory] - [InlineData(false, (byte) 9, true)] - [InlineData(false, (byte) 10, false)] + [InlineData(false, (byte) 9, true)] + [InlineData(false, (byte) 10, false)] [InlineData(false, (byte) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (byte) 9, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (byte) 9, false)] + [InlineData(true, null, false)] public void Byte_IsGreaterThan_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, byte? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -136,4 +136,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Byte/Byte_IsLessThanOrEqualTo_Tests.cs b/tests/Valit.Tests/Byte/Byte_IsLessThanOrEqualTo_Tests.cs index 6cf47d8..ce38fa2 100644 --- a/tests/Valit.Tests/Byte/Byte_IsLessThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/Byte/Byte_IsLessThanOrEqualTo_Tests.cs @@ -12,7 +12,7 @@ public void Byte_IsLessThanOrEqualTo_For_Not_Nullable_Values_Throws_When_Null_Ru ((IValitRule)null) .IsLessThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void Byte_IsLessThanOrEqualTo_For_Not_Nullable_Value_And_Nullable_Value_T ((IValitRule)null) .IsLessThanOrEqualTo((byte?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void Byte_IsLessThanOrEqualTo_For_Nullable_Value_And_Not_Nullable_Value_T ((IValitRule)null) .IsLessThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void Byte_IsLessThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Rule_I ((IValitRule)null) .IsLessThanOrEqualTo((byte?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void Byte_IsLessThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Rule_I [Theory] [InlineData(11, true)] [InlineData(10, true)] - [InlineData(9, false)] + [InlineData(9, false)] public void Byte_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(byte value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void Byte_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Val [Theory] [InlineData((byte) 11, true)] [InlineData((byte) 10, true)] - [InlineData((byte) 9, false)] - [InlineData(null, false)] + [InlineData((byte) 9, false)] + [InlineData(null, false)] public void Byte_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(byte? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void Byte_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Val [Theory] [InlineData(false, 11, true)] - [InlineData(false, 10, true)] - [InlineData(false, 9, false)] - [InlineData(true, 11, false)] + [InlineData(false, 10, true)] + [InlineData(false, 9, false)] + [InlineData(true, 11, false)] public void Byte_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, byte value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void Byte_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_A } [Theory] - [InlineData(false, (byte) 11, true)] - [InlineData(false, (byte) 10, true)] + [InlineData(false, (byte) 11, true)] + [InlineData(false, (byte) 10, true)] [InlineData(false, (byte) 9, false)] - [InlineData(false, null, false)] - [InlineData(true, (byte) 11, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (byte) 11, false)] + [InlineData(true, null, false)] public void Byte_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, byte? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -133,6 +133,6 @@ class Model public byte? NullableValue => 10; public byte? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Byte/Byte_IsLessThan_Tests.cs b/tests/Valit.Tests/Byte/Byte_IsLessThan_Tests.cs index a90194a..0408f51 100644 --- a/tests/Valit.Tests/Byte/Byte_IsLessThan_Tests.cs +++ b/tests/Valit.Tests/Byte/Byte_IsLessThan_Tests.cs @@ -5,47 +5,51 @@ namespace Valit.Tests.Byte { public class Byte_IsLessThan_Tests { - [Fact] + [Fact] public void Byte_IsLessThan_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Given() { - var exception = Record.Exception(() => { + var exception = Record.Exception(() => + { ((IValitRule)null) .IsLessThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Fact] public void Byte_IsLessThan_For_Not_Nullable_Value_And_Nullable_Value_Throws_When_Null_Rule_Is_Given() { - var exception = Record.Exception(() => { + var exception = Record.Exception(() => + { ((IValitRule)null) .IsLessThan((byte?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Fact] public void Byte_IsLessThan_For_Nullable_Value_And_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { - var exception = Record.Exception(() => { + var exception = Record.Exception(() => + { ((IValitRule)null) .IsLessThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Fact] public void Byte_IsLessThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() { - var exception = Record.Exception(() => { + var exception = Record.Exception(() => + { ((IValitRule)null) .IsLessThan((byte?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,12 +57,12 @@ public void Byte_IsLessThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() [Theory] [InlineData(11, true)] [InlineData(10, false)] - [InlineData(9, false)] - public void Byte_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Values(byte value, bool expected) - { + [InlineData(9, false)] + public void Byte_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Values(byte value, bool expected) + { IValitResult result = ValitRules .Create() - .Ensure(m => m.Value, _=>_ + .Ensure(m => m.Value, _ => _ .IsLessThan(value)) .For(_model) .Validate(); @@ -67,15 +71,15 @@ public void Byte_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Values(byte } [Theory] - [InlineData((byte) 11, true)] - [InlineData((byte) 10, false)] - [InlineData((byte) 9, false)] - [InlineData(null, false)] - public void Byte_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(byte? value, bool expected) - { + [InlineData((byte)11, true)] + [InlineData((byte)10, false)] + [InlineData((byte)9, false)] + [InlineData(null, false)] + public void Byte_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(byte? value, bool expected) + { IValitResult result = ValitRules .Create() - .Ensure(m => m.Value, _=>_ + .Ensure(m => m.Value, _ => _ .IsLessThan(value)) .For(_model) .Validate(); @@ -85,14 +89,14 @@ public void Byte_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Value_And_Nu [Theory] [InlineData(false, 11, true)] - [InlineData(false, 10, false)] - [InlineData(false, 9, false)] - [InlineData(true, 11, false)] - public void Byte_IsLessThan_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, byte value, bool expected) - { + [InlineData(false, 10, false)] + [InlineData(false, 9, false)] + [InlineData(true, 11, false)] + public void Byte_IsLessThan_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, byte value, bool expected) + { IValitResult result = ValitRules .Create() - .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ + .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ .IsLessThan(value)) .For(_model) .Validate(); @@ -101,17 +105,17 @@ public void Byte_IsLessThan_Returns_Proper_Results_For_Nullable_Value_And_Not_Nu } [Theory] - [InlineData(false, (byte) 11, true)] - [InlineData(false, (byte) 10, false)] - [InlineData(false, (byte) 9, false)] - [InlineData(false, null, false)] - [InlineData(true, (byte) 11, false)] - [InlineData(true, null, false)] - public void Byte_IsLessThan_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, byte? value, bool expected) - { + [InlineData(false, (byte)11, true)] + [InlineData(false, (byte)10, false)] + [InlineData(false, (byte)9, false)] + [InlineData(false, null, false)] + [InlineData(true, (byte)11, false)] + [InlineData(true, null, false)] + public void Byte_IsLessThan_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, byte? value, bool expected) + { IValitResult result = ValitRules .Create() - .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ + .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ .IsLessThan(value)) .For(_model) .Validate(); @@ -119,7 +123,7 @@ public void Byte_IsLessThan_Returns_Proper_Results_For_Nullable_Values(bool useN Assert.Equal(result.Succeeded, expected); } -#region ARRANGE + #region ARRANGE public Byte_IsLessThan_Tests() { _model = new Model(); @@ -133,7 +137,7 @@ class Model public byte? NullableValue => 10; public byte? NullValue => null; } -#endregion + #endregion } - -} \ No newline at end of file + +} diff --git a/tests/Valit.Tests/Byte/Byte_IsNonZero_Tests.cs b/tests/Valit.Tests/Byte/Byte_IsNonZero_Tests.cs index 6d0f74a..0d80baa 100644 --- a/tests/Valit.Tests/Byte/Byte_IsNonZero_Tests.cs +++ b/tests/Valit.Tests/Byte/Byte_IsNonZero_Tests.cs @@ -5,14 +5,14 @@ namespace Valit.Tests.Byte { public class Byte_IsNonZero_Tests { - [Fact] + [Fact] public void Byte_IsNonZero_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsNonZero(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,16 +23,16 @@ public void Byte_IsNonZero_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsNonZero(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void Byte_IsNonZero_Returns_Proper_Results_For_Not_Nullable_Value(bool useZeroValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useZeroValue? m.ZeroValue : m.Value, _=>_ @@ -45,9 +45,9 @@ public void Byte_IsNonZero_Returns_Proper_Results_For_Not_Nullable_Value(bool us [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void Byte_IsNonZero_Returns_Proper_Results_For_Nullable_Value(bool useZeroValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useZeroValue? m.NullableZeroValue : m.NullableValue, _=>_ @@ -60,7 +60,7 @@ public void Byte_IsNonZero_Returns_Proper_Results_For_Nullable_Value(bool useZer [Fact] public void Byte_IsNonZero_Fails_For_Null_Value() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullValue, _=>_ @@ -89,4 +89,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Byte/Byte_Required_Tests.cs b/tests/Valit.Tests/Byte/Byte_Required_Tests.cs index 0af383f..fda07f6 100644 --- a/tests/Valit.Tests/Byte/Byte_Required_Tests.cs +++ b/tests/Valit.Tests/Byte/Byte_Required_Tests.cs @@ -13,16 +13,16 @@ public void Byte_Required_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .Required(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void Byte_Required_Returns_Proper_Results_For_Nullable_Value(bool useNullValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -51,4 +51,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Collection/Primitive_Property_Collection_Validation_Tests.cs b/tests/Valit.Tests/Collection/Primitive_Property_Collection_Validation_Tests.cs new file mode 100644 index 0000000..fcc0414 --- /dev/null +++ b/tests/Valit.Tests/Collection/Primitive_Property_Collection_Validation_Tests.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Shouldly; +using Xunit; + +namespace Valit.Tests.Collection +{ + public class Primitive_Property_Collection_Validation_Tests + { + + [Fact] + public void EnsureFor_Throws_When_Null_RuleFunc_Is_Given() + { + var exception = Record.Exception(() => { + ValitRules + .Create() + .EnsureFor(m => m.InvalidValuesCollection, (Func,IValitRule>)null); + }); + + exception.ShouldBeOfType(typeof(ValitException)); + } + + [Fact] + public void Validation_With_Complete_Strategy_Fails_When_Invalid_Collection_Is_Given() + { + var result = ValitRules + .Create() + .EnsureFor(m => m.InvalidValuesCollection, _=>_ + .Required() + .WithMessage("One") + .Email() + .WithMessage("Two")) + .For(_model) + .Validate(); + + Assert.False(result.Succeeded); + result.ErrorMessages.Count(m => m == "One").ShouldBe(1); + result.ErrorMessages.Count(m => m == "Two").ShouldBe(3); + } + + [Fact] + public void Validation_With_FailFast_Strategy_Fails_When_Invalid_Collection_Is_Given() + { + var result = ValitRules + .Create() + .WithStrategy(picker => picker.FailFast) + .EnsureFor(m => m.InvalidValuesCollection, _=>_ + .Required() + .WithMessage("One") + .Email() + .WithMessage("Two")) + .For(_model) + .Validate(); + + Assert.False(result.Succeeded); + result.ErrorMessages.Count().ShouldBe(1); + result.ErrorMessages.First().ShouldBe("Two"); + } + + [Fact] + public void Validation_With_Complete_Strategy_Succeeds_When_Valid_Collection_Is_Given() + { + var result = ValitRules + .Create() + .EnsureFor(m => m.ValidValuesCollection, _=>_ + .Required() + .WithMessage("One") + .Email() + .WithMessage("Two")) + .For(_model) + .Validate(); + + Assert.True(result.Succeeded); + } + + [Fact] + public void Validation_With_FailFast_Strategy_Succeeds_When_Valid_Collection_Is_Given() + { + var result = ValitRules + .Create() + .WithStrategy(picker => picker.FailFast) + .EnsureFor(m => m.ValidValuesCollection, _=>_ + .Required() + .WithMessage("One") + .Email() + .WithMessage("Two")) + .For(_model) + .Validate(); + + Assert.True(result.Succeeded); + } + + +#region ARRANGE + private readonly Model _model; + + public Primitive_Property_Collection_Validation_Tests() + { + _model = new Model(); + } + + class Model + { + public IEnumerable InvalidValuesCollection => new List + { + "correct.email@test.com", + "incorrect.email.com", + null, + "another@incorrect@email.com" + }; + + public IEnumerable ValidValuesCollection => new List + { + "correct.email@test.com", + "another.correct.email@test.com" + }; + } +#endregion + } +} diff --git a/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsAfterNow_Tests.cs b/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsAfterNow_Tests.cs index 5d3d950..ff8b0e7 100644 --- a/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsAfterNow_Tests.cs +++ b/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsAfterNow_Tests.cs @@ -7,14 +7,14 @@ namespace Valit.Tests.DateTimeOffset_ { public class DateTimeOffset_IsAfterNow_Tests { - [Fact] + [Fact] public void DateTimeOffset_IsAfterNow_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsAfterNow(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void DateTimeOffset_IsAfterNow_For_Nullable_Value_Throws_When_Null_Rule_I ((IValitRule)null) .IsAfterNow(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -38,7 +38,7 @@ public void DateTimeOffset_IsAfterNow_For_Not_Nullable_Value_Succeeds_When_Value .IsAfterNow()) .For(_model) .Validate(); - + Assert.True(result.Succeeded); } @@ -51,7 +51,7 @@ public void DateTimeOffset_IsAfterNow_For_Not_Nullable_Value_Fails_When_Value_Is .IsAfterNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -64,7 +64,7 @@ public void DateTimeOffset_IsAfterNow_For_Nullable_Value_Succeeds_When_Value_Is_ .IsAfterNow()) .For(_model) .Validate(); - + Assert.True(result.Succeeded); } @@ -77,7 +77,7 @@ public void DateTimeOffset_IsAfterNow_For_Nullable_Value_Fails_When_Value_Is_Bef .IsAfterNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -90,7 +90,7 @@ public void DateTimeOffset_IsAfterNow_For_Nullable_Value_Fails_When_Value_Is_Nul .IsAfterNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -104,12 +104,12 @@ public DateTimeOffset_IsAfterNow_Tests() class Model { - public DateTimeOffset BeforeNowValue => DateTimeOffset.Now.AddDays(-1); + public DateTimeOffset BeforeNowValue => DateTimeOffset.Now.AddDays(-1); public DateTimeOffset AfterNowValue => DateTimeOffset.Now.AddDays(1); public DateTimeOffset? NullableBeforeNowValue => DateTimeOffset.Now.AddDays(-1); public DateTimeOffset? NullableAfterNowValue => DateTimeOffset.Now.AddDays(1); public DateTimeOffset? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsAfterOrSameAs_Tests.cs b/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsAfterOrSameAs_Tests.cs index 8756e54..986e84b 100644 --- a/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsAfterOrSameAs_Tests.cs +++ b/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsAfterOrSameAs_Tests.cs @@ -14,7 +14,7 @@ public void DateTimeOffset_IsAfterOrSameAs_For_Not_Nullable_Values_Throws_When_N ((IValitRule)null) .IsAfterOrSameAs(DateTimeOffset.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void DateTimeOffset_IsAfterOrSameAs_For_Not_Nullable_Value_And_Nullable_V ((IValitRule)null) .IsAfterOrSameAs((DateTimeOffset?)DateTimeOffset.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -36,9 +36,9 @@ public void DateTimeOffset_IsAfterOrSameAs_For_Nullable_Value_And_Not_Nullable_V ((IValitRule)null) .IsAfterOrSameAs(DateTimeOffset.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); - } + } [Fact] public void DateTimeOffset_IsAfterOrSameAs_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() @@ -47,16 +47,16 @@ public void DateTimeOffset_IsAfterOrSameAs_For_Nullable_Values_Throws_When_Null_ ((IValitRule)null) .IsAfterOrSameAs((DateTimeOffset?) DateTimeOffset.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData("2017-06-09", true)] [InlineData("2017-06-10", true)] - [InlineData("2017-06-11", false)] + [InlineData("2017-06-11", false)] public void DateTimeOffset_IsAfterOrSameAs_Returns_Proper_Results_For_Not_Nullable_Values(string stringValue, bool expected) - { + { var value = stringValue.AsDateTimeOffset(); IValitResult result = ValitRules @@ -67,15 +67,15 @@ public void DateTimeOffset_IsAfterOrSameAs_Returns_Proper_Results_For_Not_Nullab .Validate(); Assert.Equal(result.Succeeded, expected); - } + } [Theory] [InlineData("2017-06-09", true)] [InlineData("2017-06-10", true)] - [InlineData("2017-06-11", false)] - [InlineData(null, false)] + [InlineData("2017-06-11", false)] + [InlineData(null, false)] public void DateTimeOffset_IsAfterOrSameAs_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(string stringValue, bool expected) - { + { DateTimeOffset? value = stringValue.AsNullableDateTimeOffset(); IValitResult result = ValitRules @@ -90,11 +90,11 @@ public void DateTimeOffset_IsAfterOrSameAs_Returns_Proper_Results_For_Not_Nullab [Theory] [InlineData(false, "2017-06-09", true)] - [InlineData(false, "2017-06-10", true)] - [InlineData(false, "2017-06-11", false)] - [InlineData(true, "2017-06-09", false)] + [InlineData(false, "2017-06-10", true)] + [InlineData(false, "2017-06-11", false)] + [InlineData(true, "2017-06-09", false)] public void DateTimeOffset_IsAfterOrSameAs_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, string stringValue, bool expected) - { + { var value = stringValue.AsDateTimeOffset(); IValitResult result = ValitRules @@ -108,14 +108,14 @@ public void DateTimeOffset_IsAfterOrSameAs_Returns_Proper_Results_For_Nullable_V } [Theory] - [InlineData(false, "2017-06-09", true)] - [InlineData(false, "2017-06-10", true)] + [InlineData(false, "2017-06-09", true)] + [InlineData(false, "2017-06-10", true)] [InlineData(false, "2017-06-11", false)] - [InlineData(false, null, false)] - [InlineData(true, "2017-06-09", false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, "2017-06-09", false)] + [InlineData(true, null, false)] public void DateTimeOffset_IsAfterOrSameAs_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, string stringValue, bool expected) - { + { DateTimeOffset? value = stringValue.AsNullableDateTimeOffset(); IValitResult result = ValitRules @@ -142,6 +142,6 @@ class Model public DateTimeOffset? NullableValue => new DateTimeOffset(new DateTime(2017, 6, 10)); public DateTimeOffset? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsAfterUtcNow_Tests.cs b/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsAfterUtcNow_Tests.cs index 2f2a55d..c828e4a 100644 --- a/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsAfterUtcNow_Tests.cs +++ b/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsAfterUtcNow_Tests.cs @@ -7,14 +7,14 @@ namespace Valit.Tests.DateTimeOffset_ { public class DateTimeOffset_IsAfterUtcNow_Tests { - [Fact] + [Fact] public void DateTimeOffset_IsAfterUtcNow_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsAfterUtcNow(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void DateTimeOffset_IsAfterUtcNow_For_Nullable_Value_Throws_When_Null_Rul ((IValitRule)null) .IsAfterUtcNow(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -38,7 +38,7 @@ public void DateTimeOffset_IsAfterUtcNow_For_Not_Nullable_Value_Succeeds_When_Va .IsAfterUtcNow()) .For(_model) .Validate(); - + Assert.True(result.Succeeded); } @@ -51,7 +51,7 @@ public void DateTimeOffset_IsAfterUtcNow_For_Not_Nullable_Value_Fails_When_Value .IsAfterUtcNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -64,7 +64,7 @@ public void DateTimeOffset_IsAfterUtcNow_For_Nullable_Value_Succeeds_When_Value_ .IsAfterUtcNow()) .For(_model) .Validate(); - + Assert.True(result.Succeeded); } @@ -77,7 +77,7 @@ public void DateTimeOffset_IsAfterUtcNow_For_Nullable_Value_Fails_When_Value_Is_ .IsAfterUtcNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -90,7 +90,7 @@ public void DateTimeOffset_IsAfterUtcNow_For_Nullable_Value_Fails_When_Value_Is_ .IsAfterUtcNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -104,12 +104,12 @@ public DateTimeOffset_IsAfterUtcNow_Tests() class Model { - public DateTimeOffset BeforeNowValue => DateTimeOffset.UtcNow.AddDays(-1); + public DateTimeOffset BeforeNowValue => DateTimeOffset.UtcNow.AddDays(-1); public DateTimeOffset AfterNowValue => DateTimeOffset.UtcNow.AddDays(1); public DateTimeOffset? NullableBeforeNowValue => DateTimeOffset.UtcNow.AddDays(-1); public DateTimeOffset? NullableAfterNowValue => DateTimeOffset.UtcNow.AddDays(1); public DateTimeOffset? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsAfter_Tests.cs b/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsAfter_Tests.cs index 1182a45..b871d09 100644 --- a/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsAfter_Tests.cs +++ b/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsAfter_Tests.cs @@ -14,7 +14,7 @@ public void DateTimeOffset_IsAfter_For_Not_Nullable_Values_Throws_When_Null_Rule ((IValitRule)null) .IsAfter(DateTimeOffset.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void DateTimeOffset_IsAfter_For_Not_Nullable_Value_And_Nullable_Value_Thr ((IValitRule)null) .IsAfter((DateTimeOffset?)DateTimeOffset.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -36,9 +36,9 @@ public void DateTimeOffset_IsAfter_For_Nullable_Value_And_Not_Nullable_Value_Thr ((IValitRule)null) .IsAfter(DateTimeOffset.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); - } + } [Fact] public void DateTimeOffset_IsAfter_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() @@ -47,16 +47,16 @@ public void DateTimeOffset_IsAfter_For_Nullable_Values_Throws_When_Null_Rule_Is_ ((IValitRule)null) .IsAfter((DateTimeOffset?) DateTimeOffset.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData("2017-06-09", true)] [InlineData("2017-06-10", false)] - [InlineData("2017-06-11", false)] + [InlineData("2017-06-11", false)] public void DateTimeOffset_IsAfter_Returns_Proper_Results_For_Not_Nullable_Values(string stringValue, bool expected) - { + { var value = stringValue.AsDateTimeOffset(); IValitResult result = ValitRules @@ -67,15 +67,15 @@ public void DateTimeOffset_IsAfter_Returns_Proper_Results_For_Not_Nullable_Value .Validate(); Assert.Equal(result.Succeeded, expected); - } + } [Theory] [InlineData("2017-06-09", true)] [InlineData("2017-06-10", false)] - [InlineData("2017-06-11", false)] - [InlineData(null, false)] + [InlineData("2017-06-11", false)] + [InlineData(null, false)] public void DateTimeOffset_IsAfter_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(string stringValue, bool expected) - { + { DateTimeOffset? value = stringValue.AsNullableDateTimeOffset(); IValitResult result = ValitRules @@ -90,11 +90,11 @@ public void DateTimeOffset_IsAfter_Returns_Proper_Results_For_Not_Nullable_Value [Theory] [InlineData(false, "2017-06-09", true)] - [InlineData(false, "2017-06-10", false)] - [InlineData(false, "2017-06-11", false)] - [InlineData(true, "2017-06-09", false)] + [InlineData(false, "2017-06-10", false)] + [InlineData(false, "2017-06-11", false)] + [InlineData(true, "2017-06-09", false)] public void DateTimeOffset_IsAfter_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, string stringValue, bool expected) - { + { var value = stringValue.AsDateTimeOffset(); IValitResult result = ValitRules @@ -108,14 +108,14 @@ public void DateTimeOffset_IsAfter_Returns_Proper_Results_For_Nullable_Value_And } [Theory] - [InlineData(false, "2017-06-09", true)] - [InlineData(false, "2017-06-10", false)] + [InlineData(false, "2017-06-09", true)] + [InlineData(false, "2017-06-10", false)] [InlineData(false, "2017-06-11", false)] - [InlineData(false, null, false)] - [InlineData(true, "2017-06-09", false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, "2017-06-09", false)] + [InlineData(true, null, false)] public void DateTimeOffset_IsAfter_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, string stringValue, bool expected) - { + { DateTimeOffset? value = stringValue.AsNullableDateTimeOffset(); IValitResult result = ValitRules @@ -142,6 +142,6 @@ class Model public DateTimeOffset? NullableValue => new DateTimeOffset(new DateTime(2017, 6, 10)); public DateTimeOffset? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsBeforeNow_Tests.cs b/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsBeforeNow_Tests.cs index 1cc1002..aea97eb 100644 --- a/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsBeforeNow_Tests.cs +++ b/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsBeforeNow_Tests.cs @@ -7,14 +7,14 @@ namespace Valit.Tests.DateTimeOffset_ { public class DateTimeOffset_IsBeforeNow_Tests { - [Fact] + [Fact] public void DateTimeOffset_IsBeforeNow_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsBeforeNow(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void DateTimeOffset_IsBeforeNow_For_Nullable_Value_Throws_When_Null_Rule_ ((IValitRule)null) .IsBeforeNow(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -38,7 +38,7 @@ public void DateTimeOffset_IsBeforeNow_For_Not_Nullable_Value_Succeeds_When_Valu .IsBeforeNow()) .For(_model) .Validate(); - + Assert.True(result.Succeeded); } @@ -51,7 +51,7 @@ public void DateTimeOffset_IsBeforeNow_For_Not_Nullable_Value_Fails_When_Value_I .IsBeforeNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -64,7 +64,7 @@ public void DateTimeOffset_IsBeforeNow_For_Nullable_Value_Succeeds_When_Value_Is .IsBeforeNow()) .For(_model) .Validate(); - + Assert.True(result.Succeeded); } @@ -77,7 +77,7 @@ public void DateTimeOffset_IsBeforeNow_For_Nullable_Value_Fails_When_Value_Is_Af .IsBeforeNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -90,7 +90,7 @@ public void DateTimeOffset_IsBeforeNow_For_Nullable_Value_Fails_When_Value_Is_Nu .IsBeforeNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -104,12 +104,12 @@ public DateTimeOffset_IsBeforeNow_Tests() class Model { - public DateTimeOffset BeforeNowValue => DateTimeOffset.Now.AddDays(-1); + public DateTimeOffset BeforeNowValue => DateTimeOffset.Now.AddDays(-1); public DateTimeOffset AfterNowValue => DateTimeOffset.Now.AddDays(1); public DateTimeOffset? NullableBeforeNowValue => DateTimeOffset.Now.AddDays(-1); public DateTimeOffset? NullableAfterNowValue => DateTimeOffset.Now.AddDays(1); public DateTimeOffset? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsBeforeOrSameAs_Tests.cs b/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsBeforeOrSameAs_Tests.cs index cc6ead4..7395886 100644 --- a/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsBeforeOrSameAs_Tests.cs +++ b/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsBeforeOrSameAs_Tests.cs @@ -14,7 +14,7 @@ public void DateTimeOffset_IsBeforeOrSameAs_For_Not_Nullable_Values_Throws_When_ ((IValitRule)null) .IsBeforeOrSameAs(DateTimeOffset.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void DateTimeOffset_IsBeforeOrSameAs_For_Not_Nullable_Value_And_Nullable_ ((IValitRule)null) .IsBeforeOrSameAs((DateTimeOffset?)DateTimeOffset.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -36,9 +36,9 @@ public void DateTimeOffset_IsBeforeOrSameAs_For_Nullable_Value_And_Not_Nullable_ ((IValitRule)null) .IsBeforeOrSameAs(DateTimeOffset.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); - } + } [Fact] public void DateTimeOffset_IsBeforeOrSameAs_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() @@ -47,16 +47,16 @@ public void DateTimeOffset_IsBeforeOrSameAs_For_Nullable_Values_Throws_When_Null ((IValitRule)null) .IsBeforeOrSameAs((DateTimeOffset?) DateTimeOffset.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData("2017-06-11", true)] [InlineData("2017-06-10", true)] - [InlineData("2017-06-09", false)] + [InlineData("2017-06-09", false)] public void DateTimeOffset_IsBeforeOrSameAs_Returns_Proper_Results_For_Not_Nullable_Values(string stringValue, bool expected) - { + { var value = stringValue.AsDateTimeOffset(); IValitResult result = ValitRules @@ -67,15 +67,15 @@ public void DateTimeOffset_IsBeforeOrSameAs_Returns_Proper_Results_For_Not_Nulla .Validate(); Assert.Equal(result.Succeeded, expected); - } + } [Theory] [InlineData("2017-06-11", true)] [InlineData("2017-06-10", true)] - [InlineData("2017-06-09", false)] - [InlineData(null, false)] + [InlineData("2017-06-09", false)] + [InlineData(null, false)] public void DateTimeOffset_IsBeforeOrSameAs_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(string stringValue, bool expected) - { + { DateTimeOffset? value = stringValue.AsNullableDateTimeOffset(); IValitResult result = ValitRules @@ -90,11 +90,11 @@ public void DateTimeOffset_IsBeforeOrSameAs_Returns_Proper_Results_For_Not_Nulla [Theory] [InlineData(false, "2017-06-11", true)] - [InlineData(false, "2017-06-10", true)] - [InlineData(false, "2017-06-09", false)] - [InlineData(true, "2017-06-11", false)] + [InlineData(false, "2017-06-10", true)] + [InlineData(false, "2017-06-09", false)] + [InlineData(true, "2017-06-11", false)] public void DateTimeOffset_IsBeforeOrSameAs_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, string stringValue, bool expected) - { + { var value = stringValue.AsDateTimeOffset(); IValitResult result = ValitRules @@ -108,14 +108,14 @@ public void DateTimeOffset_IsBeforeOrSameAs_Returns_Proper_Results_For_Nullable_ } [Theory] - [InlineData(false, "2017-06-11", true)] - [InlineData(false, "2017-06-10", true)] + [InlineData(false, "2017-06-11", true)] + [InlineData(false, "2017-06-10", true)] [InlineData(false, "2017-06-09", false)] - [InlineData(false, null, false)] - [InlineData(true, "2017-06-11", false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, "2017-06-11", false)] + [InlineData(true, null, false)] public void DateTimeOffset_IsBeforeOrSameAs_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, string stringValue, bool expected) - { + { DateTimeOffset? value = stringValue.AsNullableDateTimeOffset(); IValitResult result = ValitRules @@ -142,6 +142,6 @@ class Model public DateTimeOffset? NullableValue => new DateTimeOffset(new DateTime(2017, 6, 10)); public DateTimeOffset? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsBeforeUtcNow_Tests.cs b/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsBeforeUtcNow_Tests.cs index dd192c0..f3e9bdd 100644 --- a/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsBeforeUtcNow_Tests.cs +++ b/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsBeforeUtcNow_Tests.cs @@ -7,14 +7,14 @@ namespace Valit.Tests.DateTimeOffset_ { public class DateTimeOffset_IsBeforeUtcNow_Tests { - [Fact] + [Fact] public void DateTimeOffset_IsBeforeUtcNow_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsBeforeUtcNow(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void DateTimeOffset_IsBeforeUtcNow_For_Nullable_Value_Throws_When_Null_Ru ((IValitRule)null) .IsBeforeUtcNow(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -38,7 +38,7 @@ public void DateTimeOffset_IsBeforeUtcNow_For_Not_Nullable_Value_Succeeds_When_V .IsBeforeUtcNow()) .For(_model) .Validate(); - + Assert.True(result.Succeeded); } @@ -51,7 +51,7 @@ public void DateTimeOffset_IsBeforeUtcNow_For_Not_Nullable_Value_Fails_When_Valu .IsBeforeUtcNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -64,7 +64,7 @@ public void DateTimeOffset_IsBeforeUtcNow_For_Nullable_Value_Succeeds_When_Value .IsBeforeUtcNow()) .For(_model) .Validate(); - + Assert.True(result.Succeeded); } @@ -77,7 +77,7 @@ public void DateTimeOffset_IsBeforeUtcNow_For_Nullable_Value_Fails_When_Value_Is .IsBeforeUtcNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -90,7 +90,7 @@ public void DateTimeOffset_IsBeforeUtcNow_For_Nullable_Value_Fails_When_Value_Is .IsBeforeUtcNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -104,12 +104,12 @@ public DateTimeOffset_IsBeforeUtcNow_Tests() class Model { - public DateTimeOffset BeforeNowValue => DateTimeOffset.UtcNow.AddDays(-1); + public DateTimeOffset BeforeNowValue => DateTimeOffset.UtcNow.AddDays(-1); public DateTimeOffset AfterNowValue => DateTimeOffset.UtcNow.AddDays(1); public DateTimeOffset? NullableBeforeNowValue => DateTimeOffset.UtcNow.AddDays(-1); public DateTimeOffset? NullableAfterNowValue => DateTimeOffset.UtcNow.AddDays(1); public DateTimeOffset? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsBefore_Tests.cs b/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsBefore_Tests.cs index 9b6d685..7280a54 100644 --- a/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsBefore_Tests.cs +++ b/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsBefore_Tests.cs @@ -14,7 +14,7 @@ public void DateTimeOffset_IsBefore_For_Not_Nullable_Values_Throws_When_Null_Rul ((IValitRule)null) .IsBefore(DateTimeOffset.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void DateTimeOffset_IsBefore_For_Not_Nullable_Value_And_Nullable_Value_Th ((IValitRule)null) .IsBefore((DateTimeOffset?)DateTimeOffset.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -36,9 +36,9 @@ public void DateTimeOffset_IsBefore_For_Nullable_Value_And_Not_Nullable_Value_Th ((IValitRule)null) .IsBefore(DateTimeOffset.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); - } + } [Fact] public void DateTimeOffset_IsBefore_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() @@ -47,16 +47,16 @@ public void DateTimeOffset_IsBefore_For_Nullable_Values_Throws_When_Null_Rule_Is ((IValitRule)null) .IsBefore((DateTimeOffset?) DateTimeOffset.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData("2017-06-11", true)] [InlineData("2017-06-10", false)] - [InlineData("2017-06-09", false)] + [InlineData("2017-06-09", false)] public void DateTimeOffset_IsBefore_Returns_Proper_Results_For_Not_Nullable_Values(string stringValue, bool expected) - { + { var value = stringValue.AsDateTimeOffset(); IValitResult result = ValitRules @@ -67,15 +67,15 @@ public void DateTimeOffset_IsBefore_Returns_Proper_Results_For_Not_Nullable_Valu .Validate(); Assert.Equal(result.Succeeded, expected); - } + } [Theory] [InlineData("2017-06-11", true)] [InlineData("2017-06-10", false)] - [InlineData("2017-06-09", false)] - [InlineData(null, false)] + [InlineData("2017-06-09", false)] + [InlineData(null, false)] public void DateTimeOffset_IsBefore_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(string stringValue, bool expected) - { + { DateTimeOffset? value = stringValue.AsNullableDateTimeOffset(); IValitResult result = ValitRules @@ -90,11 +90,11 @@ public void DateTimeOffset_IsBefore_Returns_Proper_Results_For_Not_Nullable_Valu [Theory] [InlineData(false, "2017-06-11", true)] - [InlineData(false, "2017-06-10", false)] - [InlineData(false, "2017-06-09", false)] - [InlineData(true, "2017-06-11", false)] + [InlineData(false, "2017-06-10", false)] + [InlineData(false, "2017-06-09", false)] + [InlineData(true, "2017-06-11", false)] public void DateTimeOffset_IsBefore_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, string stringValue, bool expected) - { + { var value = stringValue.AsDateTimeOffset(); IValitResult result = ValitRules @@ -108,14 +108,14 @@ public void DateTimeOffset_IsBefore_Returns_Proper_Results_For_Nullable_Value_An } [Theory] - [InlineData(false, "2017-06-11", true)] - [InlineData(false, "2017-06-10", false)] + [InlineData(false, "2017-06-11", true)] + [InlineData(false, "2017-06-10", false)] [InlineData(false, "2017-06-09", false)] - [InlineData(false, null, false)] - [InlineData(true, "2017-06-11", false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, "2017-06-11", false)] + [InlineData(true, null, false)] public void DateTimeOffset_IsBefore_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, string stringValue, bool expected) - { + { DateTimeOffset? value = stringValue.AsNullableDateTimeOffset(); IValitResult result = ValitRules @@ -142,6 +142,6 @@ class Model public DateTimeOffset? NullableValue => new DateTimeOffset(new DateTime(2017, 6, 10)); public DateTimeOffset? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsSameAs_Tests.cs b/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsSameAs_Tests.cs index cd81571..92c3f55 100644 --- a/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsSameAs_Tests.cs +++ b/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_IsSameAs_Tests.cs @@ -14,7 +14,7 @@ public void DateTimeOffset_IsSameAs_For_Not_Nullable_Values_Throws_When_Null_Rul ((IValitRule)null) .IsSameAs(DateTimeOffset.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void DateTimeOffset_IsSameAs_For_Not_Nullable_Value_And_Nullable_Value_Th ((IValitRule)null) .IsSameAs((DateTimeOffset?)DateTimeOffset.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -36,9 +36,9 @@ public void DateTimeOffset_IsSameAs_For_Nullable_Value_And_Not_Nullable_Value_Th ((IValitRule)null) .IsSameAs(DateTimeOffset.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); - } + } [Fact] public void DateTimeOffset_IsSameAs_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() @@ -47,16 +47,16 @@ public void DateTimeOffset_IsSameAs_For_Nullable_Values_Throws_When_Null_Rule_Is ((IValitRule)null) .IsSameAs((DateTimeOffset?) DateTimeOffset.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData("2017-06-10", true)] [InlineData("2017-06-09", false)] - [InlineData("2017-06-11", false)] + [InlineData("2017-06-11", false)] public void DateTimeOffset_IsSameAs_Returns_Proper_Results_For_Not_Nullable_Values(string stringValue, bool expected) - { + { var value = stringValue.AsDateTimeOffset(); IValitResult result = ValitRules @@ -67,15 +67,15 @@ public void DateTimeOffset_IsSameAs_Returns_Proper_Results_For_Not_Nullable_Valu .Validate(); Assert.Equal(result.Succeeded, expected); - } + } [Theory] [InlineData("2017-06-10", true)] [InlineData("2017-06-09", false)] - [InlineData("2017-06-11", false)] - [InlineData(null, false)] + [InlineData("2017-06-11", false)] + [InlineData(null, false)] public void DateTimeOffset_IsSameAs_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(string stringValue, bool expected) - { + { DateTimeOffset? value = stringValue.AsNullableDateTimeOffset(); IValitResult result = ValitRules @@ -90,11 +90,11 @@ public void DateTimeOffset_IsSameAs_Returns_Proper_Results_For_Not_Nullable_Valu [Theory] [InlineData(false, "2017-06-10", true)] - [InlineData(false, "2017-06-09", false)] - [InlineData(false, "2017-06-11", false)] - [InlineData(true, "2017-06-10", false)] + [InlineData(false, "2017-06-09", false)] + [InlineData(false, "2017-06-11", false)] + [InlineData(true, "2017-06-10", false)] public void DateTimeOffset_IsSameAs_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, string stringValue, bool expected) - { + { var value = stringValue.AsDateTimeOffset(); IValitResult result = ValitRules @@ -108,14 +108,14 @@ public void DateTimeOffset_IsSameAs_Returns_Proper_Results_For_Nullable_Value_An } [Theory] - [InlineData(false, "2017-06-10", true)] - [InlineData(false, "2017-06-09", false)] + [InlineData(false, "2017-06-10", true)] + [InlineData(false, "2017-06-09", false)] [InlineData(false, "2017-06-11", false)] - [InlineData(false, null, false)] - [InlineData(true, "2017-06-10", false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, "2017-06-10", false)] + [InlineData(true, null, false)] public void DateTimeOffset_IsSameAs_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, string stringValue, bool expected) - { + { DateTimeOffset? value = stringValue.AsNullableDateTimeOffset(); IValitResult result = ValitRules @@ -142,6 +142,6 @@ class Model public DateTimeOffset? NullableValue => new DateTimeOffset(new DateTime(2017, 6, 10)); public DateTimeOffset? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_Required_Tests.cs b/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_Required_Tests.cs index 424d59b..b284ba5 100644 --- a/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_Required_Tests.cs +++ b/tests/Valit.Tests/DateTimeOffset_/DateTimeOffset_Required_Tests.cs @@ -14,16 +14,16 @@ public void DateTimeOffset_Required_For_Nullable_Value_Throws_When_Null_Rule_Is_ ((IValitRule)null) .Required(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void DateTimeOffset_Required_Returns_Proper_Results_For_Nullable_Value(bool useNullValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -49,4 +49,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/DateTime_/DateTime_IsAfterNow_Tests.cs b/tests/Valit.Tests/DateTime_/DateTime_IsAfterNow_Tests.cs index 3152c37..0b59497 100644 --- a/tests/Valit.Tests/DateTime_/DateTime_IsAfterNow_Tests.cs +++ b/tests/Valit.Tests/DateTime_/DateTime_IsAfterNow_Tests.cs @@ -7,14 +7,14 @@ namespace Valit.Tests.DateTime_ { public class DateTime_IsAfterNow_Tests { - [Fact] + [Fact] public void DateTime_IsAfterNow_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsAfterNow(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void DateTime_IsAfterNow_For_Nullable_Value_Throws_When_Null_Rule_Is_Give ((IValitRule)null) .IsAfterNow(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -38,7 +38,7 @@ public void DateTime_IsAfterNow_For_Not_Nullable_Value_Succeeds_When_Value_Is_Af .IsAfterNow()) .For(_model) .Validate(); - + Assert.True(result.Succeeded); } @@ -51,7 +51,7 @@ public void DateTime_IsAfterNow_For_Not_Nullable_Value_Fails_When_Value_Is_Befor .IsAfterNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -64,7 +64,7 @@ public void DateTime_IsAfterNow_For_Nullable_Value_Succeeds_When_Value_Is_After_ .IsAfterNow()) .For(_model) .Validate(); - + Assert.True(result.Succeeded); } @@ -77,7 +77,7 @@ public void DateTime_IsAfterNow_For_Nullable_Value_Fails_When_Value_Is_Before_Da .IsAfterNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -90,7 +90,7 @@ public void DateTime_IsAfterNow_For_Nullable_Value_Fails_When_Value_Is_Null() .IsAfterNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -104,12 +104,12 @@ public DateTime_IsAfterNow_Tests() class Model { - public DateTime BeforeNowValue => DateTime.Now.AddDays(-1); + public DateTime BeforeNowValue => DateTime.Now.AddDays(-1); public DateTime AfterNowValue => DateTime.Now.AddDays(1); public DateTime? NullableBeforeNowValue => DateTime.Now.AddDays(-1); public DateTime? NullableAfterNowValue => DateTime.Now.AddDays(1); public DateTime? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/DateTime_/DateTime_IsAfterOrSameAs_Tests.cs b/tests/Valit.Tests/DateTime_/DateTime_IsAfterOrSameAs_Tests.cs index f0e3e91..1115919 100644 --- a/tests/Valit.Tests/DateTime_/DateTime_IsAfterOrSameAs_Tests.cs +++ b/tests/Valit.Tests/DateTime_/DateTime_IsAfterOrSameAs_Tests.cs @@ -14,7 +14,7 @@ public void DateTime_IsAfterOrSameAs_For_Not_Nullable_Values_Throws_When_Null_Ru ((IValitRule)null) .IsAfterOrSameAs(DateTime.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void DateTime_IsAfterOrSameAs_For_Not_Nullable_Value_And_Nullable_Value_T ((IValitRule)null) .IsAfterOrSameAs((DateTime?)DateTime.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -36,9 +36,9 @@ public void DateTime_IsAfterOrSameAs_For_Nullable_Value_And_Not_Nullable_Value_T ((IValitRule)null) .IsAfterOrSameAs(DateTime.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); - } + } [Fact] public void DateTime_IsAfterOrSameAs_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() @@ -47,16 +47,16 @@ public void DateTime_IsAfterOrSameAs_For_Nullable_Values_Throws_When_Null_Rule_I ((IValitRule)null) .IsAfterOrSameAs((DateTime?) DateTime.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData("2017-06-09", true)] [InlineData("2017-06-10", true)] - [InlineData("2017-06-11", false)] + [InlineData("2017-06-11", false)] public void DateTime_IsAfterOrSameAs_Returns_Proper_Results_For_Not_Nullable_Values(DateTime value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -65,15 +65,15 @@ public void DateTime_IsAfterOrSameAs_Returns_Proper_Results_For_Not_Nullable_Val .Validate(); Assert.Equal(result.Succeeded, expected); - } + } [Theory] [InlineData("2017-06-09", true)] [InlineData("2017-06-10", true)] - [InlineData("2017-06-11", false)] - [InlineData(null, false)] + [InlineData("2017-06-11", false)] + [InlineData(null, false)] public void DateTime_IsAfterOrSameAs_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(string stringValue, bool expected) - { + { DateTime? value = stringValue.AsNullableDateTime(); IValitResult result = ValitRules @@ -88,11 +88,11 @@ public void DateTime_IsAfterOrSameAs_Returns_Proper_Results_For_Not_Nullable_Val [Theory] [InlineData(false, "2017-06-09", true)] - [InlineData(false, "2017-06-10", true)] - [InlineData(false, "2017-06-11", false)] - [InlineData(true, "2017-06-09", false)] + [InlineData(false, "2017-06-10", true)] + [InlineData(false, "2017-06-11", false)] + [InlineData(true, "2017-06-09", false)] public void DateTime_IsAfterOrSameAs_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, DateTime value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -104,14 +104,14 @@ public void DateTime_IsAfterOrSameAs_Returns_Proper_Results_For_Nullable_Value_A } [Theory] - [InlineData(false, "2017-06-09", true)] - [InlineData(false, "2017-06-10", true)] + [InlineData(false, "2017-06-09", true)] + [InlineData(false, "2017-06-10", true)] [InlineData(false, "2017-06-11", false)] - [InlineData(false, null, false)] - [InlineData(true, "2017-06-09", false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, "2017-06-09", false)] + [InlineData(true, null, false)] public void DateTime_IsAfterOrSameAs_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, string stringValue, bool expected) - { + { DateTime? value = stringValue.AsNullableDateTime(); IValitResult result = ValitRules @@ -138,6 +138,6 @@ class Model public DateTime? NullableValue => new DateTime(2017, 6, 10); public DateTime? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/DateTime_/DateTime_IsAfterUtcNow_Tests.cs b/tests/Valit.Tests/DateTime_/DateTime_IsAfterUtcNow_Tests.cs index 8dc0ff2..06dbde6 100644 --- a/tests/Valit.Tests/DateTime_/DateTime_IsAfterUtcNow_Tests.cs +++ b/tests/Valit.Tests/DateTime_/DateTime_IsAfterUtcNow_Tests.cs @@ -7,14 +7,14 @@ namespace Valit.Tests.DateTime_ { public class DateTime_IsAfterUtcNow_Tests { - [Fact] + [Fact] public void DateTime_IsAfterUtcNow_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsAfterUtcNow(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void DateTime_IsAfterUtcNow_For_Nullable_Value_Throws_When_Null_Rule_Is_G ((IValitRule)null) .IsAfterUtcNow(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -38,7 +38,7 @@ public void DateTime_IsAfterUtcNow_For_Not_Nullable_Value_Succeeds_When_Value_Is .IsAfterUtcNow()) .For(_model) .Validate(); - + Assert.True(result.Succeeded); } @@ -51,7 +51,7 @@ public void DateTime_IsAfterUtcNow_For_Not_Nullable_Value_Fails_When_Value_Is_Be .IsAfterUtcNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -64,7 +64,7 @@ public void DateTime_IsAfterUtcNow_For_Nullable_Value_Succeeds_When_Value_Is_Aft .IsAfterUtcNow()) .For(_model) .Validate(); - + Assert.True(result.Succeeded); } @@ -77,7 +77,7 @@ public void DateTime_IsAfterUtcNow_For_Nullable_Value_Fails_When_Value_Is_Before .IsAfterUtcNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -90,7 +90,7 @@ public void DateTime_IsAfterUtcNow_For_Nullable_Value_Fails_When_Value_Is_Null() .IsAfterUtcNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -104,12 +104,12 @@ public DateTime_IsAfterUtcNow_Tests() class Model { - public DateTime BeforeNowValue => DateTime.UtcNow.AddDays(-1); + public DateTime BeforeNowValue => DateTime.UtcNow.AddDays(-1); public DateTime AfterNowValue => DateTime.UtcNow.AddDays(1); public DateTime? NullableBeforeNowValue => DateTime.UtcNow.AddDays(-1); public DateTime? NullableAfterNowValue => DateTime.UtcNow.AddDays(1); public DateTime? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/DateTime_/DateTime_IsAfter_Tests.cs b/tests/Valit.Tests/DateTime_/DateTime_IsAfter_Tests.cs index 2fe5f2c..0589253 100644 --- a/tests/Valit.Tests/DateTime_/DateTime_IsAfter_Tests.cs +++ b/tests/Valit.Tests/DateTime_/DateTime_IsAfter_Tests.cs @@ -14,7 +14,7 @@ public void DateTime_IsAfter_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Gi ((IValitRule)null) .IsAfter(DateTime.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void DateTime_IsAfter_For_Not_Nullable_Value_And_Nullable_Value_Throws_Wh ((IValitRule)null) .IsAfter((DateTime?)DateTime.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -36,9 +36,9 @@ public void DateTime_IsAfter_For_Nullable_Value_And_Not_Nullable_Value_Throws_Wh ((IValitRule)null) .IsAfter(DateTime.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); - } + } [Fact] public void DateTime_IsAfter_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() @@ -47,16 +47,16 @@ public void DateTime_IsAfter_For_Nullable_Values_Throws_When_Null_Rule_Is_Given( ((IValitRule)null) .IsAfter((DateTime?) DateTime.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData("2017-06-09", true)] [InlineData("2017-06-10", false)] - [InlineData("2017-06-11", false)] + [InlineData("2017-06-11", false)] public void DateTime_IsAfter_Returns_Proper_Results_For_Not_Nullable_Values(DateTime value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -65,15 +65,15 @@ public void DateTime_IsAfter_Returns_Proper_Results_For_Not_Nullable_Values(Date .Validate(); Assert.Equal(result.Succeeded, expected); - } + } [Theory] [InlineData("2017-06-09", true)] [InlineData("2017-06-10", false)] - [InlineData("2017-06-11", false)] - [InlineData(null, false)] + [InlineData("2017-06-11", false)] + [InlineData(null, false)] public void DateTime_IsAfter_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(string stringValue, bool expected) - { + { DateTime? value = stringValue.AsNullableDateTime(); IValitResult result = ValitRules @@ -88,11 +88,11 @@ public void DateTime_IsAfter_Returns_Proper_Results_For_Not_Nullable_Value_And_N [Theory] [InlineData(false, "2017-06-09", true)] - [InlineData(false, "2017-06-10", false)] - [InlineData(false, "2017-06-11", false)] - [InlineData(true, "2017-06-09", false)] + [InlineData(false, "2017-06-10", false)] + [InlineData(false, "2017-06-11", false)] + [InlineData(true, "2017-06-09", false)] public void DateTime_IsAfter_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, DateTime value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -104,14 +104,14 @@ public void DateTime_IsAfter_Returns_Proper_Results_For_Nullable_Value_And_Not_N } [Theory] - [InlineData(false, "2017-06-09", true)] - [InlineData(false, "2017-06-10", false)] + [InlineData(false, "2017-06-09", true)] + [InlineData(false, "2017-06-10", false)] [InlineData(false, "2017-06-11", false)] - [InlineData(false, null, false)] - [InlineData(true, "2017-06-09", false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, "2017-06-09", false)] + [InlineData(true, null, false)] public void DateTime_IsAfter_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, string stringValue, bool expected) - { + { DateTime? value = stringValue.AsNullableDateTime(); IValitResult result = ValitRules @@ -138,6 +138,6 @@ class Model public DateTime? NullableValue => new DateTime(2017, 6, 10); public DateTime? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/DateTime_/DateTime_IsBeforeNow_Tests.cs b/tests/Valit.Tests/DateTime_/DateTime_IsBeforeNow_Tests.cs index 28be1ae..45f82fd 100644 --- a/tests/Valit.Tests/DateTime_/DateTime_IsBeforeNow_Tests.cs +++ b/tests/Valit.Tests/DateTime_/DateTime_IsBeforeNow_Tests.cs @@ -7,14 +7,14 @@ namespace Valit.Tests.DateTime_ { public class DateTime_IsBeforeNow_Tests { - [Fact] + [Fact] public void DateTime_IsBeforeNow_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsBeforeNow(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void DateTime_IsBeforeNow_For_Nullable_Value_Throws_When_Null_Rule_Is_Giv ((IValitRule)null) .IsBeforeNow(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -38,7 +38,7 @@ public void DateTime_IsBeforeNow_For_Not_Nullable_Value_Succeeds_When_Value_Is_B .IsBeforeNow()) .For(_model) .Validate(); - + Assert.True(result.Succeeded); } @@ -51,7 +51,7 @@ public void DateTime_IsBeforeNow_For_Not_Nullable_Value_Fails_When_Value_Is_Afte .IsBeforeNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -64,7 +64,7 @@ public void DateTime_IsBeforeNow_For_Nullable_Value_Succeeds_When_Value_Is_Befor .IsBeforeNow()) .For(_model) .Validate(); - + Assert.True(result.Succeeded); } @@ -77,7 +77,7 @@ public void DateTime_IsBeforeNow_For_Nullable_Value_Fails_When_Value_Is_After_Da .IsBeforeNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -90,7 +90,7 @@ public void DateTime_IsBeforeNow_For_Nullable_Value_Fails_When_Value_Is_Null() .IsBeforeNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -104,12 +104,12 @@ public DateTime_IsBeforeNow_Tests() class Model { - public DateTime BeforeNowValue => DateTime.Now.AddDays(-1); + public DateTime BeforeNowValue => DateTime.Now.AddDays(-1); public DateTime AfterNowValue => DateTime.Now.AddDays(1); public DateTime? NullableBeforeNowValue => DateTime.Now.AddDays(-1); public DateTime? NullableAfterNowValue => DateTime.Now.AddDays(1); public DateTime? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/DateTime_/DateTime_IsBeforeOrSameAs_Tests.cs b/tests/Valit.Tests/DateTime_/DateTime_IsBeforeOrSameAs_Tests.cs index bbec74e..142a47b 100644 --- a/tests/Valit.Tests/DateTime_/DateTime_IsBeforeOrSameAs_Tests.cs +++ b/tests/Valit.Tests/DateTime_/DateTime_IsBeforeOrSameAs_Tests.cs @@ -14,7 +14,7 @@ public void DateTime_IsBeforeOrSameAs_For_Not_Nullable_Values_Throws_When_Null_R ((IValitRule)null) .IsBeforeOrSameAs(DateTime.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void DateTime_IsBeforeOrSameAs_For_Not_Nullable_Value_And_Nullable_Value_ ((IValitRule)null) .IsBeforeOrSameAs((DateTime?)DateTime.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -36,9 +36,9 @@ public void DateTime_IsBeforeOrSameAs_For_Nullable_Value_And_Not_Nullable_Value_ ((IValitRule)null) .IsBeforeOrSameAs(DateTime.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); - } + } [Fact] public void DateTime_IsBeforeOrSameAs_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() @@ -47,16 +47,16 @@ public void DateTime_IsBeforeOrSameAs_For_Nullable_Values_Throws_When_Null_Rule_ ((IValitRule)null) .IsBeforeOrSameAs((DateTime?) DateTime.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData("2017-06-11", true)] [InlineData("2017-06-10", true)] - [InlineData("2017-06-09", false)] + [InlineData("2017-06-09", false)] public void DateTime_IsBeforeOrSameAs_Returns_Proper_Results_For_Not_Nullable_Values(DateTime value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -65,15 +65,15 @@ public void DateTime_IsBeforeOrSameAs_Returns_Proper_Results_For_Not_Nullable_Va .Validate(); Assert.Equal(result.Succeeded, expected); - } + } [Theory] [InlineData("2017-06-11", true)] [InlineData("2017-06-10", true)] - [InlineData("2017-06-09", false)] - [InlineData(null, false)] + [InlineData("2017-06-09", false)] + [InlineData(null, false)] public void DateTime_IsBeforeOrSameAs_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(string stringValue, bool expected) - { + { DateTime? value = stringValue.AsNullableDateTime(); IValitResult result = ValitRules @@ -88,11 +88,11 @@ public void DateTime_IsBeforeOrSameAs_Returns_Proper_Results_For_Not_Nullable_Va [Theory] [InlineData(false, "2017-06-11", true)] - [InlineData(false, "2017-06-10", true)] - [InlineData(false, "2017-06-09", false)] - [InlineData(true, "2017-06-11", false)] + [InlineData(false, "2017-06-10", true)] + [InlineData(false, "2017-06-09", false)] + [InlineData(true, "2017-06-11", false)] public void DateTime_IsBeforeOrSameAs_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, DateTime value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -104,14 +104,14 @@ public void DateTime_IsBeforeOrSameAs_Returns_Proper_Results_For_Nullable_Value_ } [Theory] - [InlineData(false, "2017-06-11", true)] - [InlineData(false, "2017-06-10", true)] + [InlineData(false, "2017-06-11", true)] + [InlineData(false, "2017-06-10", true)] [InlineData(false, "2017-06-09", false)] - [InlineData(false, null, false)] - [InlineData(true, "2017-06-11", false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, "2017-06-11", false)] + [InlineData(true, null, false)] public void DateTime_IsBeforeOrSameAs_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, string stringValue, bool expected) - { + { DateTime? value = stringValue.AsNullableDateTime(); IValitResult result = ValitRules @@ -138,6 +138,6 @@ class Model public DateTime? NullableValue => new DateTime(2017, 6, 10); public DateTime? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/DateTime_/DateTime_IsBeforeUtcNow_Tests.cs b/tests/Valit.Tests/DateTime_/DateTime_IsBeforeUtcNow_Tests.cs index 977afad..e5066fb 100644 --- a/tests/Valit.Tests/DateTime_/DateTime_IsBeforeUtcNow_Tests.cs +++ b/tests/Valit.Tests/DateTime_/DateTime_IsBeforeUtcNow_Tests.cs @@ -7,14 +7,14 @@ namespace Valit.Tests.DateTime_ { public class DateTime_IsBeforeUtcNow_Tests { - [Fact] + [Fact] public void DateTime_IsBeforeUtcNow_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsBeforeUtcNow(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void DateTime_IsBeforeUtcNow_For_Nullable_Value_Throws_When_Null_Rule_Is_ ((IValitRule)null) .IsBeforeUtcNow(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -38,7 +38,7 @@ public void DateTime_IsBeforeUtcNow_For_Not_Nullable_Value_Succeeds_When_Value_I .IsBeforeUtcNow()) .For(_model) .Validate(); - + Assert.True(result.Succeeded); } @@ -51,7 +51,7 @@ public void DateTime_IsBeforeUtcNow_For_Not_Nullable_Value_Fails_When_Value_Is_A .IsBeforeUtcNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -64,7 +64,7 @@ public void DateTime_IsBeforeUtcNow_For_Nullable_Value_Succeeds_When_Value_Is_Be .IsBeforeUtcNow()) .For(_model) .Validate(); - + Assert.True(result.Succeeded); } @@ -77,7 +77,7 @@ public void DateTime_IsBeforeUtcNow_For_Nullable_Value_Fails_When_Value_Is_After .IsBeforeUtcNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -90,7 +90,7 @@ public void DateTime_IsBeforeUtcNow_For_Nullable_Value_Fails_When_Value_Is_Null( .IsBeforeUtcNow()) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -104,12 +104,12 @@ public DateTime_IsBeforeUtcNow_Tests() class Model { - public DateTime BeforeNowValue => DateTime.UtcNow.AddDays(-1); + public DateTime BeforeNowValue => DateTime.UtcNow.AddDays(-1); public DateTime AfterNowValue => DateTime.UtcNow.AddDays(1); public DateTime? NullableBeforeNowValue => DateTime.UtcNow.AddDays(-1); public DateTime? NullableAfterNowValue => DateTime.UtcNow.AddDays(1); public DateTime? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/DateTime_/DateTime_IsBefore_Tests.cs b/tests/Valit.Tests/DateTime_/DateTime_IsBefore_Tests.cs index c8939e2..5c68cff 100644 --- a/tests/Valit.Tests/DateTime_/DateTime_IsBefore_Tests.cs +++ b/tests/Valit.Tests/DateTime_/DateTime_IsBefore_Tests.cs @@ -14,7 +14,7 @@ public void DateTime_IsBefore_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_G ((IValitRule)null) .IsBefore(DateTime.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void DateTime_IsBefore_For_Not_Nullable_Value_And_Nullable_Value_Throws_W ((IValitRule)null) .IsBefore((DateTime?)DateTime.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -36,9 +36,9 @@ public void DateTime_IsBefore_For_Nullable_Value_And_Not_Nullable_Value_Throws_W ((IValitRule)null) .IsBefore(DateTime.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); - } + } [Fact] public void DateTime_IsBefore_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() @@ -47,16 +47,16 @@ public void DateTime_IsBefore_For_Nullable_Values_Throws_When_Null_Rule_Is_Given ((IValitRule)null) .IsBefore((DateTime?) DateTime.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData("2017-06-11", true)] [InlineData("2017-06-10", false)] - [InlineData("2017-06-09", false)] + [InlineData("2017-06-09", false)] public void DateTime_IsBefore_Returns_Proper_Results_For_Not_Nullable_Values(DateTime value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -65,15 +65,15 @@ public void DateTime_IsBefore_Returns_Proper_Results_For_Not_Nullable_Values(Dat .Validate(); Assert.Equal(result.Succeeded, expected); - } + } [Theory] [InlineData("2017-06-11", true)] [InlineData("2017-06-10", false)] - [InlineData("2017-06-09", false)] - [InlineData(null, false)] + [InlineData("2017-06-09", false)] + [InlineData(null, false)] public void DateTime_IsBefore_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(string stringValue, bool expected) - { + { DateTime? value = stringValue.AsNullableDateTime(); IValitResult result = ValitRules @@ -88,11 +88,11 @@ public void DateTime_IsBefore_Returns_Proper_Results_For_Not_Nullable_Value_And_ [Theory] [InlineData(false, "2017-06-11", true)] - [InlineData(false, "2017-06-10", false)] - [InlineData(false, "2017-06-09", false)] - [InlineData(true, "2017-06-11", false)] + [InlineData(false, "2017-06-10", false)] + [InlineData(false, "2017-06-09", false)] + [InlineData(true, "2017-06-11", false)] public void DateTime_IsBefore_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, DateTime value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -104,14 +104,14 @@ public void DateTime_IsBefore_Returns_Proper_Results_For_Nullable_Value_And_Not_ } [Theory] - [InlineData(false, "2017-06-11", true)] - [InlineData(false, "2017-06-10", false)] + [InlineData(false, "2017-06-11", true)] + [InlineData(false, "2017-06-10", false)] [InlineData(false, "2017-06-09", false)] - [InlineData(false, null, false)] - [InlineData(true, "2017-06-11", false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, "2017-06-11", false)] + [InlineData(true, null, false)] public void DateTime_IsBefore_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, string stringValue, bool expected) - { + { DateTime? value = stringValue.AsNullableDateTime(); IValitResult result = ValitRules @@ -138,6 +138,6 @@ class Model public DateTime? NullableValue => new DateTime(2017, 6, 10); public DateTime? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/DateTime_/DateTime_IsSameAs_Tests.cs b/tests/Valit.Tests/DateTime_/DateTime_IsSameAs_Tests.cs index 0c36cd4..756161b 100644 --- a/tests/Valit.Tests/DateTime_/DateTime_IsSameAs_Tests.cs +++ b/tests/Valit.Tests/DateTime_/DateTime_IsSameAs_Tests.cs @@ -14,7 +14,7 @@ public void DateTime_IsSameAs_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_G ((IValitRule)null) .IsSameAs(DateTime.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void DateTime_IsSameAs_For_Not_Nullable_Value_And_Nullable_Value_Throws_W ((IValitRule)null) .IsSameAs((DateTime?)DateTime.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -36,9 +36,9 @@ public void DateTime_IsSameAs_For_Nullable_Value_And_Not_Nullable_Value_Throws_W ((IValitRule)null) .IsSameAs(DateTime.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); - } + } [Fact] public void DateTime_IsSameAs_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() @@ -47,16 +47,16 @@ public void DateTime_IsSameAs_For_Nullable_Values_Throws_When_Null_Rule_Is_Given ((IValitRule)null) .IsSameAs((DateTime?) DateTime.Now); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData("2017-06-10", true)] [InlineData("2017-06-09", false)] - [InlineData("2017-06-11", false)] + [InlineData("2017-06-11", false)] public void DateTime_IsSameAs_Returns_Proper_Results_For_Not_Nullable_Values(DateTime value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -65,15 +65,15 @@ public void DateTime_IsSameAs_Returns_Proper_Results_For_Not_Nullable_Values(Dat .Validate(); Assert.Equal(result.Succeeded, expected); - } + } [Theory] [InlineData("2017-06-10", true)] [InlineData("2017-06-09", false)] - [InlineData("2017-06-11", false)] - [InlineData(null, false)] + [InlineData("2017-06-11", false)] + [InlineData(null, false)] public void DateTime_IsSameAs_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(string stringValue, bool expected) - { + { DateTime? value = stringValue.AsNullableDateTime(); IValitResult result = ValitRules @@ -88,11 +88,11 @@ public void DateTime_IsSameAs_Returns_Proper_Results_For_Not_Nullable_Value_And_ [Theory] [InlineData(false, "2017-06-10", true)] - [InlineData(false, "2017-06-09", false)] - [InlineData(false, "2017-06-11", false)] - [InlineData(true, "2017-06-10", false)] + [InlineData(false, "2017-06-09", false)] + [InlineData(false, "2017-06-11", false)] + [InlineData(true, "2017-06-10", false)] public void DateTime_IsSameAs_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, DateTime value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -104,14 +104,14 @@ public void DateTime_IsSameAs_Returns_Proper_Results_For_Nullable_Value_And_Not_ } [Theory] - [InlineData(false, "2017-06-10", true)] - [InlineData(false, "2017-06-09", false)] + [InlineData(false, "2017-06-10", true)] + [InlineData(false, "2017-06-09", false)] [InlineData(false, "2017-06-11", false)] - [InlineData(false, null, false)] - [InlineData(true, "2017-06-10", false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, "2017-06-10", false)] + [InlineData(true, null, false)] public void DateTime_IsSameAs_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, string stringValue, bool expected) - { + { DateTime? value = stringValue.AsNullableDateTime(); IValitResult result = ValitRules @@ -138,6 +138,6 @@ class Model public DateTime? NullableValue => new DateTime(2017, 6, 10); public DateTime? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/DateTime_/DateTime_Required_Tests.cs b/tests/Valit.Tests/DateTime_/DateTime_Required_Tests.cs index 4653fe9..1da42b8 100644 --- a/tests/Valit.Tests/DateTime_/DateTime_Required_Tests.cs +++ b/tests/Valit.Tests/DateTime_/DateTime_Required_Tests.cs @@ -14,16 +14,16 @@ public void DateTime_Required_For_Nullable_Value_Throws_When_Null_Rule_Is_Given( ((IValitRule)null) .Required(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void DateTime_Required_Returns_Proper_Results_For_Nullable_Value(bool useNullValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -49,4 +49,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Decimal/Decimal_IsEqual_To_Tests.cs b/tests/Valit.Tests/Decimal/Decimal_IsEqual_To_Tests.cs index 3b2409c..c006c68 100644 --- a/tests/Valit.Tests/Decimal/Decimal_IsEqual_To_Tests.cs +++ b/tests/Valit.Tests/Decimal/Decimal_IsEqual_To_Tests.cs @@ -14,7 +14,7 @@ public void Decimal_IsEqualTo_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_G ((IValitRule)null) .IsEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void Decimal_IsEqualTo_For_Not_Nullable_Value_And_Nullable_Value_Throws_W ((IValitRule)null) .IsEqualTo((decimal?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -36,7 +36,7 @@ public void Decimal_IsEqualTo_For_Nullable_Value_And_Not_Nullable_Value_Throws_W ((IValitRule)null) .IsEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -47,7 +47,7 @@ public void Decimal_IsEqualTo_For_Nullable_Values_Throws_When_Null_Rule_Is_Given ((IValitRule)null) .IsEqualTo((decimal?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -55,9 +55,9 @@ public void Decimal_IsEqualTo_For_Nullable_Values_Throws_When_Null_Rule_Is_Given [Theory] [InlineData(10, true)] [InlineData(9, false)] - [InlineData(11, false)] + [InlineData(11, false)] public void Decimal_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(decimal value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -71,10 +71,10 @@ public void Decimal_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(dec [Theory] [InlineData("10", true)] [InlineData("9", false)] - [InlineData("11", false)] - [InlineData(null, false)] + [InlineData("11", false)] + [InlineData(null, false)] public void Decimal_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(string stringValue, bool expected) - { + { decimal? value = stringValue.AsNullableDecimal(); IValitResult result = ValitRules @@ -89,11 +89,11 @@ public void Decimal_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_ [Theory] [InlineData(false, 10, true)] - [InlineData(false, 9, false)] - [InlineData(false, 11, false)] - [InlineData(true, 10, false)] + [InlineData(false, 9, false)] + [InlineData(false, 11, false)] + [InlineData(true, 10, false)] public void Decimal_IsEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, decimal value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -105,15 +105,15 @@ public void Decimal_IsEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_ } [Theory] - [InlineData(false, "10", true)] - [InlineData(false, "9", false)] + [InlineData(false, "10", true)] + [InlineData(false, "9", false)] [InlineData(false, "11", false)] - [InlineData(false, null, false)] - [InlineData(true, "10", false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, "10", false)] + [InlineData(true, null, false)] public void Decimal_IsEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, string stringValue, bool expected) - { - decimal? value = stringValue.AsNullableDecimal(); + { + decimal? value = stringValue.AsNullableDecimal(); IValitResult result = ValitRules .Create() @@ -139,6 +139,6 @@ class Model public decimal? NullableValue => 10; public decimal? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Decimal/Decimal_IsGreaterThanOrEqualTo_Tests.cs b/tests/Valit.Tests/Decimal/Decimal_IsGreaterThanOrEqualTo_Tests.cs index 791dfe4..9c3e2af 100644 --- a/tests/Valit.Tests/Decimal/Decimal_IsGreaterThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/Decimal/Decimal_IsGreaterThanOrEqualTo_Tests.cs @@ -14,7 +14,7 @@ public void Decimal_IsGreaterThanOrEqualTo_For_Not_Nullable_Values_Throws_When_N ((IValitRule)null) .IsGreaterThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void Decimal_IsGreaterThanOrEqualTo_For_Not_Nullable_Value_And_Nullable_V ((IValitRule)null) .IsGreaterThanOrEqualTo((decimal?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -36,7 +36,7 @@ public void Decimal_IsGreaterThanOrEqualTo_For_Nullable_Value_And_Not_Nullable_V ((IValitRule)null) .IsGreaterThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -47,7 +47,7 @@ public void Decimal_IsGreaterThanOrEqualTo_For_Nullable_Values_Throws_When_Null_ ((IValitRule)null) .IsGreaterThanOrEqualTo((decimal?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -55,9 +55,9 @@ public void Decimal_IsGreaterThanOrEqualTo_For_Nullable_Values_Throws_When_Null_ [Theory] [InlineData(9, true)] [InlineData(10, true)] - [InlineData(11, false)] + [InlineData(11, false)] public void Decimal_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(decimal value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -71,12 +71,12 @@ public void Decimal_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullab [Theory] [InlineData("9", true)] [InlineData("10", true)] - [InlineData("11", false)] - [InlineData(null, false)] + [InlineData("11", false)] + [InlineData(null, false)] public void Decimal_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(string stringValue, bool expected) - { + { decimal? value = stringValue.AsNullableDecimal(); - + IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -89,11 +89,11 @@ public void Decimal_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullab [Theory] [InlineData(false, 9, true)] - [InlineData(false, 10, true)] - [InlineData(false, 11, false)] - [InlineData(true, 9, false)] + [InlineData(false, 10, true)] + [InlineData(false, 11, false)] + [InlineData(true, 9, false)] public void Decimal_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, decimal value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -105,14 +105,14 @@ public void Decimal_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_V } [Theory] - [InlineData(false, "9", true)] - [InlineData(false, "10", true)] + [InlineData(false, "9", true)] + [InlineData(false, "10", true)] [InlineData(false, "11", false)] - [InlineData(false, null, false)] - [InlineData(true, "9", false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, "9", false)] + [InlineData(true, null, false)] public void Decimal_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, string stringValue, bool expected) - { + { decimal? value = stringValue.AsNullableDecimal(); IValitResult result = ValitRules @@ -141,4 +141,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Decimal/Decimal_IsGreaterThan_Tests.cs b/tests/Valit.Tests/Decimal/Decimal_IsGreaterThan_Tests.cs index 78a382e..99c3e09 100644 --- a/tests/Valit.Tests/Decimal/Decimal_IsGreaterThan_Tests.cs +++ b/tests/Valit.Tests/Decimal/Decimal_IsGreaterThan_Tests.cs @@ -14,7 +14,7 @@ public void Decimal_IsGreaterThan_For_Not_Nullable_Values_Throws_When_Null_Rule_ ((IValitRule)null) .IsGreaterThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void Decimal_IsGreaterThan_For_Not_Nullable_Value_And_Nullable_Value_Thro ((IValitRule)null) .IsGreaterThan((decimal?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -36,7 +36,7 @@ public void Decimal_IsGreaterThan_For_Nullable_Value_And_Not_Nullable_Value_Thro ((IValitRule)null) .IsGreaterThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -47,7 +47,7 @@ public void Decimal_IsGreaterThan_For_Nullable_Values_Throws_When_Null_Rule_Is_G ((IValitRule)null) .IsGreaterThan((decimal?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -55,9 +55,9 @@ public void Decimal_IsGreaterThan_For_Nullable_Values_Throws_When_Null_Rule_Is_G [Theory] [InlineData(9, true)] [InlineData(10, false)] - [InlineData(11, false)] + [InlineData(11, false)] public void Decimal_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Values(decimal value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -71,10 +71,10 @@ public void Decimal_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Values [Theory] [InlineData("9", true)] [InlineData("10", false)] - [InlineData("11", false)] - [InlineData(null, false)] + [InlineData("11", false)] + [InlineData(null, false)] public void Decimal_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(string stringValue, bool expected) - { + { decimal? value = stringValue.AsNullableDecimal(); IValitResult result = ValitRules @@ -89,11 +89,11 @@ public void Decimal_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Value_ [Theory] [InlineData(false, 9, true)] - [InlineData(false, 10, false)] - [InlineData(false, 11, false)] - [InlineData(true, 9, false)] + [InlineData(false, 10, false)] + [InlineData(false, 11, false)] + [InlineData(true, 9, false)] public void Decimal_IsGreaterThan_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, decimal value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -105,16 +105,16 @@ public void Decimal_IsGreaterThan_Returns_Proper_Results_For_Nullable_Value_And_ } [Theory] - [InlineData(false, "9", true)] - [InlineData(false, "10", false)] + [InlineData(false, "9", true)] + [InlineData(false, "10", false)] [InlineData(false, "11", false)] - [InlineData(false, null, false)] - [InlineData(true, "9", false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, "9", false)] + [InlineData(true, null, false)] public void Decimal_IsGreaterThan_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, string stringValue, bool expected) - { + { decimal? value = stringValue.AsNullableDecimal(); - + IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -141,4 +141,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Decimal/Decimal_IsLessThanOrEqualTo_Tests.cs b/tests/Valit.Tests/Decimal/Decimal_IsLessThanOrEqualTo_Tests.cs index 421f661..44e46ae 100644 --- a/tests/Valit.Tests/Decimal/Decimal_IsLessThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/Decimal/Decimal_IsLessThanOrEqualTo_Tests.cs @@ -14,7 +14,7 @@ public void Decimal_IsLessThanOrEqualTo_For_Not_Nullable_Values_Throws_When_Null ((IValitRule)null) .IsLessThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void Decimal_IsLessThanOrEqualTo_For_Not_Nullable_Value_And_Nullable_Valu ((IValitRule)null) .IsLessThanOrEqualTo((decimal?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -36,7 +36,7 @@ public void Decimal_IsLessThanOrEqualTo_For_Nullable_Value_And_Not_Nullable_Valu ((IValitRule)null) .IsLessThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -47,7 +47,7 @@ public void Decimal_IsLessThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Rul ((IValitRule)null) .IsLessThanOrEqualTo((decimal?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -55,9 +55,9 @@ public void Decimal_IsLessThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Rul [Theory] [InlineData(11, true)] [InlineData(10, true)] - [InlineData(9, false)] + [InlineData(9, false)] public void Decimal_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(decimal value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -71,12 +71,12 @@ public void Decimal_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_ [Theory] [InlineData("11", true)] [InlineData("10", true)] - [InlineData("9", false)] - [InlineData(null, false)] + [InlineData("9", false)] + [InlineData(null, false)] public void Decimal_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(string stringValue, bool expected) - { + { decimal? value = stringValue.AsNullableDecimal(); - + IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -89,11 +89,11 @@ public void Decimal_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_ [Theory] [InlineData(false, 11, true)] - [InlineData(false, 10, true)] - [InlineData(false, 9, false)] - [InlineData(true, 11, false)] + [InlineData(false, 10, true)] + [InlineData(false, 9, false)] + [InlineData(true, 11, false)] public void Decimal_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, decimal value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -105,16 +105,16 @@ public void Decimal_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Valu } [Theory] - [InlineData(false, "11", true)] - [InlineData(false, "10", true)] + [InlineData(false, "11", true)] + [InlineData(false, "10", true)] [InlineData(false, "9", false)] - [InlineData(false, null, false)] - [InlineData(true, "11", false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, "11", false)] + [InlineData(true, null, false)] public void Decimal_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, string stringValue, bool expected) - { + { decimal? value = stringValue.AsNullableDecimal(); - + IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -139,6 +139,6 @@ class Model public decimal? NullableValue => 10; public decimal? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Decimal/Decimal_IsLessThan_Tests.cs b/tests/Valit.Tests/Decimal/Decimal_IsLessThan_Tests.cs index 8a8e5dd..a6041bb 100644 --- a/tests/Valit.Tests/Decimal/Decimal_IsLessThan_Tests.cs +++ b/tests/Valit.Tests/Decimal/Decimal_IsLessThan_Tests.cs @@ -7,14 +7,14 @@ namespace Valit.Tests.Decimal { public class Decimal_IsLessThan_Tests { - [Fact] + [Fact] public void Decimal_IsLessThan_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsLessThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -25,7 +25,7 @@ public void Decimal_IsLessThan_For_Not_Nullable_Value_And_Nullable_Value_Throws_ ((IValitRule)null) .IsLessThan((decimal?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -36,7 +36,7 @@ public void Decimal_IsLessThan_For_Nullable_Value_And_Not_Nullable_Value_Throws_ ((IValitRule)null) .IsLessThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -47,7 +47,7 @@ public void Decimal_IsLessThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Give ((IValitRule)null) .IsLessThan((decimal?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -55,9 +55,9 @@ public void Decimal_IsLessThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Give [Theory] [InlineData(11, true)] [InlineData(10, false)] - [InlineData(9, false)] + [InlineData(9, false)] public void Decimal_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Values(decimal value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -71,10 +71,10 @@ public void Decimal_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Values(de [Theory] [InlineData("11", true)] [InlineData("10", false)] - [InlineData("9", false)] - [InlineData(null, false)] + [InlineData("9", false)] + [InlineData(null, false)] public void Decimal_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(string stringValue, bool expected) - { + { decimal? value = stringValue.AsNullableDecimal(); IValitResult result = ValitRules @@ -89,11 +89,11 @@ public void Decimal_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Value_And [Theory] [InlineData(false, 11, true)] - [InlineData(false, 10, false)] - [InlineData(false, 9, false)] - [InlineData(true, 11, false)] + [InlineData(false, 10, false)] + [InlineData(false, 9, false)] + [InlineData(true, 11, false)] public void Decimal_IsLessThan_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, decimal value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -105,14 +105,14 @@ public void Decimal_IsLessThan_Returns_Proper_Results_For_Nullable_Value_And_Not } [Theory] - [InlineData(false, "11", true)] - [InlineData(false, "10", false)] + [InlineData(false, "11", true)] + [InlineData(false, "10", false)] [InlineData(false, "9", false)] - [InlineData(false, null, false)] - [InlineData(true, "11", false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, "11", false)] + [InlineData(true, null, false)] public void Decimal_IsLessThan_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, string stringValue, bool expected) - { + { decimal? value = stringValue.AsNullableDecimal(); IValitResult result = ValitRules @@ -141,5 +141,5 @@ class Model } #endregion } - -} \ No newline at end of file + +} diff --git a/tests/Valit.Tests/Decimal/Decimal_IsNegative_Tests.cs b/tests/Valit.Tests/Decimal/Decimal_IsNegative_Tests.cs index 0297cb2..8752356 100644 --- a/tests/Valit.Tests/Decimal/Decimal_IsNegative_Tests.cs +++ b/tests/Valit.Tests/Decimal/Decimal_IsNegative_Tests.cs @@ -5,14 +5,14 @@ namespace Valit.Tests.Decimal { public class Decimal_IsNegative_Tests { - [Fact] + [Fact] public void Decimal_IsNegative_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsNegative(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,14 +23,14 @@ public void Decimal_IsNegative_For_Nullable_Value_Throws_When_Null_Rule_Is_Given ((IValitRule)null) .IsNegative(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Fact] public void Decimal_IsNegative_Succeeds_When_Given_Value_Is_Negative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NegativeValue, _=>_ @@ -43,7 +43,7 @@ public void Decimal_IsNegative_Succeeds_When_Given_Value_Is_Negative() [Fact] public void Decimal_IsNegative_Fails_When_Given_Value_Is_Zero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.ZeroValue, _=>_ @@ -56,7 +56,7 @@ public void Decimal_IsNegative_Fails_When_Given_Value_Is_Zero() [Fact] public void Decimal_IsNegative_Fails_When_Given_Value_Is_Positive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.PositiveValue, _=>_ @@ -69,7 +69,7 @@ public void Decimal_IsNegative_Fails_When_Given_Value_Is_Positive() [Fact] public void Decimal_IsNegative_Succeeds_When_Given_Value_Is_NullableNegative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableNegativeValue, _=>_ @@ -82,7 +82,7 @@ public void Decimal_IsNegative_Succeeds_When_Given_Value_Is_NullableNegative() [Fact] public void Decimal_IsNegative_Fails_When_Given_Value_Is_NullableZero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableZeroValue, _=>_ @@ -95,7 +95,7 @@ public void Decimal_IsNegative_Fails_When_Given_Value_Is_NullableZero() [Fact] public void Decimal_IsNegative_Fails_When_Given_Value_Is_NullablePositive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullablePositiveValue, _=>_ @@ -108,7 +108,7 @@ public void Decimal_IsNegative_Fails_When_Given_Value_Is_NullablePositive() [Fact] public void Decimal_IsNegative_Fails_When_Given_Value_Is_Null() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullValue, _=>_ @@ -137,6 +137,6 @@ class Model public decimal? NullableNegativeValue => -10; public decimal? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Decimal/Decimal_IsNonZero_Tests.cs b/tests/Valit.Tests/Decimal/Decimal_IsNonZero_Tests.cs index 9d58029..c039303 100644 --- a/tests/Valit.Tests/Decimal/Decimal_IsNonZero_Tests.cs +++ b/tests/Valit.Tests/Decimal/Decimal_IsNonZero_Tests.cs @@ -5,14 +5,14 @@ namespace Valit.Tests.Decimal { public class Decimal_IsNonZero_Tests { - [Fact] + [Fact] public void Decimal_IsNonZero_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsNonZero(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,16 +23,16 @@ public void Decimal_IsNonZero_For_Nullable_Value_Throws_When_Null_Rule_Is_Given( ((IValitRule)null) .IsNonZero(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void Decimal_IsNonZero_Returns_Proper_Results_For_Not_Nullable_Value(bool useZeroValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useZeroValue? m.ZeroValue : m.Value, _=>_ @@ -45,9 +45,9 @@ public void Decimal_IsNonZero_Returns_Proper_Results_For_Not_Nullable_Value(bool [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void Decimal_IsNonZero_Returns_Proper_Results_For_Nullable_Value(bool useZeroValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useZeroValue? m.NullableZeroValue : m.NullableValue, _=>_ @@ -60,7 +60,7 @@ public void Decimal_IsNonZero_Returns_Proper_Results_For_Nullable_Value(bool use [Fact] public void Decimal_IsNonZero_Fails_For_Null_Value() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullValue, _=>_ @@ -89,4 +89,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Decimal/Decimal_IsPositive_Tests.cs b/tests/Valit.Tests/Decimal/Decimal_IsPositive_Tests.cs index abc5e74..97fa6ba 100644 --- a/tests/Valit.Tests/Decimal/Decimal_IsPositive_Tests.cs +++ b/tests/Valit.Tests/Decimal/Decimal_IsPositive_Tests.cs @@ -5,14 +5,14 @@ namespace Valit.Tests.Decimal { public class Decimal_IsPositive_Tests { - [Fact] + [Fact] public void Decimal_IsPositive_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsPositive(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,14 +23,14 @@ public void Decimal_IsPositive_For_Nullable_Value_Throws_When_Null_Rule_Is_Given ((IValitRule)null) .IsPositive(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Fact] public void Decimal_IsPositive_Succeeds_When_Given_Value_Is_Postive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.PositiveValue, _=>_ @@ -43,7 +43,7 @@ public void Decimal_IsPositive_Succeeds_When_Given_Value_Is_Postive() [Fact] public void Decimal_IsPositive_Fails_When_Given_Value_Is_Zero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.ZeroValue, _=>_ @@ -56,7 +56,7 @@ public void Decimal_IsPositive_Fails_When_Given_Value_Is_Zero() [Fact] public void Decimal_IsPositive_Fails_When_Given_Value_Is_Negative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NegativeValue, _=>_ @@ -69,7 +69,7 @@ public void Decimal_IsPositive_Fails_When_Given_Value_Is_Negative() [Fact] public void Decimal_IsPositive_Succeeds_When_Given_Value_Is_NullablePostive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullablePositiveValue, _=>_ @@ -82,7 +82,7 @@ public void Decimal_IsPositive_Succeeds_When_Given_Value_Is_NullablePostive() [Fact] public void Decimal_IsPositive_Fails_When_Given_Value_Is_NullableZero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableZeroValue, _=>_ @@ -95,7 +95,7 @@ public void Decimal_IsPositive_Fails_When_Given_Value_Is_NullableZero() [Fact] public void Decimal_IsPositive_Fails_When_Given_Value_Is_NullableNegative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableNegativeValue, _=>_ @@ -108,7 +108,7 @@ public void Decimal_IsPositive_Fails_When_Given_Value_Is_NullableNegative() [Fact] public void Decimal_IsPositive_Fails_When_Given_Value_Is_Null() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullValue, _=>_ @@ -137,6 +137,6 @@ class Model public decimal? NullableNegativeValue => -10; public decimal? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Decimal/Decimal_Required_Tests.cs b/tests/Valit.Tests/Decimal/Decimal_Required_Tests.cs index 5c35d96..3712922 100644 --- a/tests/Valit.Tests/Decimal/Decimal_Required_Tests.cs +++ b/tests/Valit.Tests/Decimal/Decimal_Required_Tests.cs @@ -13,16 +13,16 @@ public void Decimal_Required_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .Required(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void Decimal_Required_Returns_Proper_Results_For_Nullable_Value(bool useNullValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -51,4 +51,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Double/Double_IsEqualTo_Tests.cs b/tests/Valit.Tests/Double/Double_IsEqualTo_Tests.cs index 14ee46f..a8317b3 100644 --- a/tests/Valit.Tests/Double/Double_IsEqualTo_Tests.cs +++ b/tests/Valit.Tests/Double/Double_IsEqualTo_Tests.cs @@ -1,4 +1,4 @@ -using Shouldly; +using Shouldly; using System; using Xunit; @@ -159,7 +159,7 @@ public void Double_IsEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_N IValitResult result = ValitRules .Create() .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ - .IsEqualTo(value)) + .IsEqualTo(value)) .For(_model) .Validate(); @@ -180,7 +180,7 @@ public void Double_IsEqualTo_Returns_Proper_Results_For_Nullable_Values(bool use IValitResult result = ValitRules .Create() .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ - .IsEqualTo(value)) + .IsEqualTo(value)) .For(_model) .Validate(); diff --git a/tests/Valit.Tests/Double/Double_IsGreaterThanOrEqualTo_Tests.cs b/tests/Valit.Tests/Double/Double_IsGreaterThanOrEqualTo_Tests.cs index d9f506b..151967b 100644 --- a/tests/Valit.Tests/Double/Double_IsGreaterThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/Double/Double_IsGreaterThanOrEqualTo_Tests.cs @@ -1,4 +1,4 @@ -using Shouldly; +using Shouldly; using System; using Xunit; @@ -158,7 +158,7 @@ public void Double_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Va IValitResult result = ValitRules .Create() .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ - .IsGreaterThanOrEqualTo(value)) + .IsGreaterThanOrEqualTo(value)) .For(_model) .Validate(); @@ -179,7 +179,7 @@ public void Double_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Va IValitResult result = ValitRules .Create() .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ - .IsGreaterThanOrEqualTo(value)) + .IsGreaterThanOrEqualTo(value)) .For(_model) .Validate(); diff --git a/tests/Valit.Tests/Double/Double_IsGreaterThan_Tests.cs b/tests/Valit.Tests/Double/Double_IsGreaterThan_Tests.cs index ffeeeaf..f964cc5 100644 --- a/tests/Valit.Tests/Double/Double_IsGreaterThan_Tests.cs +++ b/tests/Valit.Tests/Double/Double_IsGreaterThan_Tests.cs @@ -1,4 +1,4 @@ -using Shouldly; +using Shouldly; using System; using Xunit; @@ -157,7 +157,7 @@ public void Double_IsGreaterThan_Returns_Proper_Results_For_Nullable_Value_And_N IValitResult result = ValitRules .Create() .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ - .IsGreaterThan(value)) + .IsGreaterThan(value)) .For(_model) .Validate(); @@ -178,7 +178,7 @@ public void Double_IsGreaterThan_Returns_Proper_Results_For_Nullable_Values(bool IValitResult result = ValitRules .Create() .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ - .IsGreaterThan(value)) + .IsGreaterThan(value)) .For(_model) .Validate(); diff --git a/tests/Valit.Tests/Double/Double_IsLessThanOrEqualTo_Tests.cs b/tests/Valit.Tests/Double/Double_IsLessThanOrEqualTo_Tests.cs index b01b18a..1bc5f90 100644 --- a/tests/Valit.Tests/Double/Double_IsLessThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/Double/Double_IsLessThanOrEqualTo_Tests.cs @@ -1,4 +1,4 @@ -using Shouldly; +using Shouldly; using System; using Xunit; @@ -158,7 +158,7 @@ public void Double_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value IValitResult result = ValitRules .Create() .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ - .IsLessThanOrEqualTo(value)) + .IsLessThanOrEqualTo(value)) .For(_model) .Validate(); @@ -179,7 +179,7 @@ public void Double_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value IValitResult result = ValitRules .Create() .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ - .IsLessThanOrEqualTo(value)) + .IsLessThanOrEqualTo(value)) .For(_model) .Validate(); diff --git a/tests/Valit.Tests/Double/Double_IsLessThan_Tests.cs b/tests/Valit.Tests/Double/Double_IsLessThan_Tests.cs index c5182ae..4a024ab 100644 --- a/tests/Valit.Tests/Double/Double_IsLessThan_Tests.cs +++ b/tests/Valit.Tests/Double/Double_IsLessThan_Tests.cs @@ -1,4 +1,4 @@ -using Shouldly; +using Shouldly; using System; using Xunit; @@ -159,7 +159,7 @@ public void Double_IsLessThan_Returns_Proper_Results_For_Nullable_Value_And_Not_ IValitResult result = ValitRules .Create() .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ - .IsLessThan(value)) + .IsLessThan(value)) .For(_model) .Validate(); @@ -180,7 +180,7 @@ public void Double_IsLessThan_Returns_Proper_Results_For_Nullable_Values(bool us IValitResult result = ValitRules .Create() .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ - .IsLessThan(value)) + .IsLessThan(value)) .For(_model) .Validate(); diff --git a/tests/Valit.Tests/Double/Double_IsNaN_Tests.cs b/tests/Valit.Tests/Double/Double_IsNaN_Tests.cs index 2f040ac..f77ce5e 100644 --- a/tests/Valit.Tests/Double/Double_IsNaN_Tests.cs +++ b/tests/Valit.Tests/Double/Double_IsNaN_Tests.cs @@ -1,4 +1,4 @@ -using Shouldly; +using Shouldly; using System; using Xunit; diff --git a/tests/Valit.Tests/Double/Double_IsNegative_Tests.cs b/tests/Valit.Tests/Double/Double_IsNegative_Tests.cs index e7ffbf5..fc3c320 100644 --- a/tests/Valit.Tests/Double/Double_IsNegative_Tests.cs +++ b/tests/Valit.Tests/Double/Double_IsNegative_Tests.cs @@ -6,14 +6,14 @@ namespace Valit.Tests.Double { public class Double_IsNegative_Tests { - [Fact] + [Fact] public void Double_IsNegative_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsNegative(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -24,14 +24,14 @@ public void Double_IsNegative_For_Nullable_Value_Throws_When_Null_Rule_Is_Given( ((IValitRule)null) .IsNegative(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Fact] public void Double_IsNegative_Fails_When_Given_Value_Is_Postive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.PositiveValue, _=>_ @@ -44,7 +44,7 @@ public void Double_IsNegative_Fails_When_Given_Value_Is_Postive() [Fact] public void Double_IsNegative_Fails_When_Given_Value_Is_Zero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.ZeroValue, _=>_ @@ -83,7 +83,7 @@ public void Double_IsNegative_Fails_When_Given_Value_Is_NaN() [Fact] public void Double_IsNegative_Fails_When_Given_Value_Is_NullablePostive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullablePositiveValue, _=>_ @@ -96,7 +96,7 @@ public void Double_IsNegative_Fails_When_Given_Value_Is_NullablePostive() [Fact] public void Double_IsNegative_Fails_When_Given_Value_Is_NullableZero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableZeroValue, _=>_ @@ -109,7 +109,7 @@ public void Double_IsNegative_Fails_When_Given_Value_Is_NullableZero() [Fact] public void Double_IsNegative_Succeeds_When_Given_Value_Is_NullableNegative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableNegativeValue, _=>_ @@ -166,6 +166,6 @@ class Model public double? NullValue => null; public double? NullableNaN => double.NaN; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Double/Double_IsNonZero_Tests.cs b/tests/Valit.Tests/Double/Double_IsNonZero_Tests.cs index d31909a..7f6a460 100644 --- a/tests/Valit.Tests/Double/Double_IsNonZero_Tests.cs +++ b/tests/Valit.Tests/Double/Double_IsNonZero_Tests.cs @@ -6,14 +6,14 @@ namespace Valit.Tests.Double { public class Double_IsNonZero_Tests { - [Fact] + [Fact] public void Double_IsNonZero_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsNonZero(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -24,7 +24,7 @@ public void Double_IsNonZero_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsNonZero(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -33,7 +33,7 @@ public void Double_IsNonZero_Returns_Proper_Results_For_Not_Nullable_Value(bool IValitResult result = ValitRules .Create() .Ensure(m => useZeroValue ? m.ZeroValue : m.Value, _ => _ - .IsNonZero()) + .IsNonZero()) .For(_model) .Validate(); @@ -68,9 +68,9 @@ public void Double_IsNonZero_Fails_For_NullableNaN() [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void Double_IsNonZero_Returns_Proper_Results_For_Nullable_Value(bool useZeroValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useZeroValue? m.NullableZeroValue : m.NullableValue, _=>_ @@ -83,7 +83,7 @@ public void Double_IsNonZero_Returns_Proper_Results_For_Nullable_Value(bool useZ [Fact] public void Double_IsNonZero_Fails_For_Null_Value() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullValue, _=>_ @@ -114,4 +114,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Double/Double_IsNumber_Tests.cs b/tests/Valit.Tests/Double/Double_IsNumber_Tests.cs index b336ae4..a13fbe4 100644 --- a/tests/Valit.Tests/Double/Double_IsNumber_Tests.cs +++ b/tests/Valit.Tests/Double/Double_IsNumber_Tests.cs @@ -1,4 +1,4 @@ -using Shouldly; +using Shouldly; using System; using Xunit; diff --git a/tests/Valit.Tests/Double/Double_IsPositive_Tests.cs b/tests/Valit.Tests/Double/Double_IsPositive_Tests.cs index 4d2a3f9..20f2ef4 100644 --- a/tests/Valit.Tests/Double/Double_IsPositive_Tests.cs +++ b/tests/Valit.Tests/Double/Double_IsPositive_Tests.cs @@ -6,14 +6,14 @@ namespace Valit.Tests.Double { public class Double_IsPositive_Tests { - [Fact] + [Fact] public void Double_IsPositive_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsPositive(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -24,14 +24,14 @@ public void Double_IsPositive_For_Nullable_Value_Throws_When_Null_Rule_Is_Given( ((IValitRule)null) .IsPositive(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Fact] public void Double_IsPositive_Succeeds_When_Given_Value_Is_Postive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.PositiveValue, _=>_ @@ -44,7 +44,7 @@ public void Double_IsPositive_Succeeds_When_Given_Value_Is_Postive() [Fact] public void Double_IsPositive_Fails_When_Given_Value_Is_Zero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.ZeroValue, _=>_ @@ -83,7 +83,7 @@ public void Double_IsPositive_Fails_When_Given_Value_Is_NaN() [Fact] public void Double_IsPositive_Succeeds_When_Given_Value_Is_NullablePostive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullablePositiveValue, _=>_ @@ -96,7 +96,7 @@ public void Double_IsPositive_Succeeds_When_Given_Value_Is_NullablePostive() [Fact] public void Double_IsPositive_Fails_When_Given_Value_Is_NullableZero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableZeroValue, _=>_ @@ -109,7 +109,7 @@ public void Double_IsPositive_Fails_When_Given_Value_Is_NullableZero() [Fact] public void Double_IsPositive_Fails_When_Given_Value_Is_NullableNegative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableNegativeValue, _=>_ @@ -166,6 +166,6 @@ class Model public double? NullValue => null; public double? NullableNaN => double.NaN; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Double/Double_Required_Tests.cs b/tests/Valit.Tests/Double/Double_Required_Tests.cs index 3672db7..8fb9df7 100644 --- a/tests/Valit.Tests/Double/Double_Required_Tests.cs +++ b/tests/Valit.Tests/Double/Double_Required_Tests.cs @@ -14,7 +14,7 @@ public void Double_Required_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .Required(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -73,4 +73,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Enumerable/Enumerable_MaxItems_Tests.cs b/tests/Valit.Tests/Enumerable/Enumerable_MaxItems_Tests.cs index d1525f9..2cc744f 100644 --- a/tests/Valit.Tests/Enumerable/Enumerable_MaxItems_Tests.cs +++ b/tests/Valit.Tests/Enumerable/Enumerable_MaxItems_Tests.cs @@ -14,9 +14,9 @@ public void Enumerable_MaxItems_Throws_When_Null_Rule_Is_Given() ((IValitRule>)null) .MaxItems(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); - } + } [Fact] public void Enumerable_MaxItems_Succeeds_If_ExpectedItemsNumber_Is_Greater_Than_Number_Of_Items_In_Collection() @@ -27,9 +27,9 @@ public void Enumerable_MaxItems_Succeeds_If_ExpectedItemsNumber_Is_Greater_Than_ .MaxItems(5)) .For(_model) .Validate(); - + Assert.True(result.Succeeded); - } + } [Fact] public void Enumerable_MaxItems_Succeeds_If_ExpectedItemsNumber_Is_Equal_To_Number_Of_Items_In_Collection() @@ -40,9 +40,9 @@ public void Enumerable_MaxItems_Succeeds_If_ExpectedItemsNumber_Is_Equal_To_Numb .MaxItems(3)) .For(_model) .Validate(); - + Assert.True(result.Succeeded); - } + } [Fact] public void Enumerable_MaxItems_Fails_If_ExpectedItemsNumber_Is_Less_Than_Number_Of_Items_In_Collection() @@ -53,7 +53,7 @@ public void Enumerable_MaxItems_Fails_If_ExpectedItemsNumber_Is_Less_Than_Number .MaxItems(2)) .For(_model) .Validate(); - + Assert.False(result.Succeeded); } @@ -66,9 +66,9 @@ public void Enumerable_MaxItems_Fails_If_Null_Collection_Is_Given() .MaxItems(5)) .For(_model) .Validate(); - + Assert.False(result.Succeeded); - } + } #region ARRANGE public Enumerable_MaxItems_Tests() @@ -83,6 +83,6 @@ class Model public IEnumerable Collection => new List { 1, 2, 3 }; public IEnumerable NullCollection => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Enumerable/Enumerable_MinItems_Tests.cs b/tests/Valit.Tests/Enumerable/Enumerable_MinItems_Tests.cs index 5735524..3c68836 100644 --- a/tests/Valit.Tests/Enumerable/Enumerable_MinItems_Tests.cs +++ b/tests/Valit.Tests/Enumerable/Enumerable_MinItems_Tests.cs @@ -13,9 +13,9 @@ public void Enumerable_MinItems_Throws_When_Null_Rule_Is_Given() ((IValitRule>)null) .MinItems(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); - } + } [Fact] public void Enumerable_MinItems_Succeeds_If_ExpectedItemsNumber_Is_Less_Than_Number_Of_Items_In_Collection() @@ -26,9 +26,9 @@ public void Enumerable_MinItems_Succeeds_If_ExpectedItemsNumber_Is_Less_Than_Num .MinItems(1)) .For(_model) .Validate(); - + Assert.True(result.Succeeded); - } + } [Fact] public void Enumerable_MinItems_Succeeds_If_ExpectedItemsNumber_Is_Equal_To_Number_Of_Items_In_Collection() @@ -39,9 +39,9 @@ public void Enumerable_MinItems_Succeeds_If_ExpectedItemsNumber_Is_Equal_To_Numb .MinItems(3)) .For(_model) .Validate(); - + Assert.True(result.Succeeded); - } + } [Fact] public void Enumerable_MinItems_Fails_If_ExpectedItemsNumber_Is_Greater_Than_Number_Of_Items_In_Collection() @@ -52,9 +52,9 @@ public void Enumerable_MinItems_Fails_If_ExpectedItemsNumber_Is_Greater_Than_Num .MinItems(5)) .For(_model) .Validate(); - + Assert.False(result.Succeeded); - } + } [Fact] public void Enumerable_MaxItems_Fails_If_Null_Collection_Is_Given() @@ -65,9 +65,9 @@ public void Enumerable_MaxItems_Fails_If_Null_Collection_Is_Given() .MinItems(1)) .For(_model) .Validate(); - + Assert.False(result.Succeeded); - } + } #region ARRANGE @@ -83,6 +83,6 @@ class Model public IEnumerable Collection => new List { 1, 2, 3 }; public IEnumerable NullCollection => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Float/Float_IsEqualTo_Tests.cs b/tests/Valit.Tests/Float/Float_IsEqualTo_Tests.cs index 2893a42..dcab47a 100644 --- a/tests/Valit.Tests/Float/Float_IsEqualTo_Tests.cs +++ b/tests/Valit.Tests/Float/Float_IsEqualTo_Tests.cs @@ -1,4 +1,4 @@ -using Shouldly; +using Shouldly; using System; using Xunit; @@ -159,7 +159,7 @@ public void Float_IsEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nu IValitResult result = ValitRules .Create() .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ - .IsEqualTo(value)) + .IsEqualTo(value)) .For(_model) .Validate(); @@ -180,7 +180,7 @@ public void Float_IsEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useN IValitResult result = ValitRules .Create() .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ - .IsEqualTo(value)) + .IsEqualTo(value)) .For(_model) .Validate(); diff --git a/tests/Valit.Tests/Float/Float_IsGreaterThanOrEqualTo_Tests.cs b/tests/Valit.Tests/Float/Float_IsGreaterThanOrEqualTo_Tests.cs index 081f983..2b3d567 100644 --- a/tests/Valit.Tests/Float/Float_IsGreaterThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/Float/Float_IsGreaterThanOrEqualTo_Tests.cs @@ -1,4 +1,4 @@ -using Shouldly; +using Shouldly; using System; using Xunit; @@ -158,7 +158,7 @@ public void Float_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Val IValitResult result = ValitRules .Create() .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ - .IsGreaterThanOrEqualTo(value)) + .IsGreaterThanOrEqualTo(value)) .For(_model) .Validate(); @@ -179,7 +179,7 @@ public void Float_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Val IValitResult result = ValitRules .Create() .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ - .IsGreaterThanOrEqualTo(value)) + .IsGreaterThanOrEqualTo(value)) .For(_model) .Validate(); diff --git a/tests/Valit.Tests/Float/Float_IsGreaterThan_Tests.cs b/tests/Valit.Tests/Float/Float_IsGreaterThan_Tests.cs index a18f8d7..7811010 100644 --- a/tests/Valit.Tests/Float/Float_IsGreaterThan_Tests.cs +++ b/tests/Valit.Tests/Float/Float_IsGreaterThan_Tests.cs @@ -1,4 +1,4 @@ -using Shouldly; +using Shouldly; using System; using Xunit; @@ -157,7 +157,7 @@ public void Float_IsGreaterThan_Returns_Proper_Results_For_Nullable_Value_And_No IValitResult result = ValitRules .Create() .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ - .IsGreaterThan(value)) + .IsGreaterThan(value)) .For(_model) .Validate(); @@ -178,7 +178,7 @@ public void Float_IsGreaterThan_Returns_Proper_Results_For_Nullable_Values(bool IValitResult result = ValitRules .Create() .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ - .IsGreaterThan(value)) + .IsGreaterThan(value)) .For(_model) .Validate(); diff --git a/tests/Valit.Tests/Float/Float_IsLessThanOrEqualTo_Tests.cs b/tests/Valit.Tests/Float/Float_IsLessThanOrEqualTo_Tests.cs index 12cc810..c057784 100644 --- a/tests/Valit.Tests/Float/Float_IsLessThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/Float/Float_IsLessThanOrEqualTo_Tests.cs @@ -1,4 +1,4 @@ -using Shouldly; +using Shouldly; using System; using Xunit; @@ -158,7 +158,7 @@ public void Float_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_ IValitResult result = ValitRules .Create() .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ - .IsLessThanOrEqualTo(value)) + .IsLessThanOrEqualTo(value)) .For(_model) .Validate(); @@ -179,7 +179,7 @@ public void Float_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Values IValitResult result = ValitRules .Create() .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ - .IsLessThanOrEqualTo(value)) + .IsLessThanOrEqualTo(value)) .For(_model) .Validate(); diff --git a/tests/Valit.Tests/Float/Float_IsLessThan_Tests.cs b/tests/Valit.Tests/Float/Float_IsLessThan_Tests.cs index d791845..ac5eb33 100644 --- a/tests/Valit.Tests/Float/Float_IsLessThan_Tests.cs +++ b/tests/Valit.Tests/Float/Float_IsLessThan_Tests.cs @@ -1,4 +1,4 @@ -using Shouldly; +using Shouldly; using System; using Xunit; @@ -159,7 +159,7 @@ public void Float_IsLessThan_Returns_Proper_Results_For_Nullable_Value_And_Not_N IValitResult result = ValitRules .Create() .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ - .IsLessThan(value)) + .IsLessThan(value)) .For(_model) .Validate(); @@ -180,7 +180,7 @@ public void Float_IsLessThan_Returns_Proper_Results_For_Nullable_Values(bool use IValitResult result = ValitRules .Create() .Ensure(m => useNullValue ? m.NullValue : m.NullableValue, _ => _ - .IsLessThan(value)) + .IsLessThan(value)) .For(_model) .Validate(); diff --git a/tests/Valit.Tests/Float/Float_IsNaN_Tests.cs b/tests/Valit.Tests/Float/Float_IsNaN_Tests.cs index 946bd8c..ce389fc 100644 --- a/tests/Valit.Tests/Float/Float_IsNaN_Tests.cs +++ b/tests/Valit.Tests/Float/Float_IsNaN_Tests.cs @@ -1,4 +1,4 @@ -using Shouldly; +using Shouldly; using System; using Xunit; diff --git a/tests/Valit.Tests/Float/Float_IsNegative_Tests.cs b/tests/Valit.Tests/Float/Float_IsNegative_Tests.cs index 05bf239..f5d6bc4 100644 --- a/tests/Valit.Tests/Float/Float_IsNegative_Tests.cs +++ b/tests/Valit.Tests/Float/Float_IsNegative_Tests.cs @@ -6,14 +6,14 @@ namespace Valit.Tests.Float { public class Float_IsNegative_Tests { - [Fact] + [Fact] public void Float_IsNegative_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsNegative(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -24,14 +24,14 @@ public void Float_IsNegative_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsNegative(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Fact] public void Float_IsNegative_Fails_When_Given_Value_Is_Postive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.PositiveValue, _=>_ @@ -44,7 +44,7 @@ public void Float_IsNegative_Fails_When_Given_Value_Is_Postive() [Fact] public void Float_IsNegative_Fails_When_Given_Value_Is_Zero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.ZeroValue, _=>_ @@ -83,7 +83,7 @@ public void Float_IsNegative_Fails_When_Given_Value_Is_NaN() [Fact] public void Float_IsNegative_Fails_When_Given_Value_Is_NullablePostive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullablePositiveValue, _=>_ @@ -96,7 +96,7 @@ public void Float_IsNegative_Fails_When_Given_Value_Is_NullablePostive() [Fact] public void Float_IsNegative_Fails_When_Given_Value_Is_NullableZero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableZeroValue, _=>_ @@ -109,7 +109,7 @@ public void Float_IsNegative_Fails_When_Given_Value_Is_NullableZero() [Fact] public void Float_IsNegative_Succeeds_When_Given_Value_Is_NullableNegative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableNegativeValue, _=>_ @@ -166,6 +166,6 @@ class Model public float? NullValue => null; public float? NullableNaN => Single.NaN; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Float/Float_IsNonZero_Tests.cs b/tests/Valit.Tests/Float/Float_IsNonZero_Tests.cs index ed9728a..78f60f2 100644 --- a/tests/Valit.Tests/Float/Float_IsNonZero_Tests.cs +++ b/tests/Valit.Tests/Float/Float_IsNonZero_Tests.cs @@ -6,14 +6,14 @@ namespace Valit.Tests.Float { public class Float_IsNonZero_Tests { - [Fact] + [Fact] public void Float_IsNonZero_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsNonZero(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -24,7 +24,7 @@ public void Float_IsNonZero_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsNonZero(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -33,7 +33,7 @@ public void Float_IsNonZero_Returns_Proper_Results_For_Not_Nullable_Value(bool u IValitResult result = ValitRules .Create() .Ensure(m => useZeroValue ? m.ZeroValue : m.Value, _ => _ - .IsNonZero()) + .IsNonZero()) .For(_model) .Validate(); @@ -68,9 +68,9 @@ public void Float_IsNonZero_Fails_For_NullableNaN() [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void Float_IsNonZero_Returns_Proper_Results_For_Nullable_Value(bool useZeroValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useZeroValue? m.NullableZeroValue : m.NullableValue, _=>_ @@ -83,7 +83,7 @@ public void Float_IsNonZero_Returns_Proper_Results_For_Nullable_Value(bool useZe [Fact] public void Float_IsNonZero_Fails_For_Null_Value() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullValue, _=>_ @@ -114,4 +114,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Float/Float_IsNumber_Tests.cs b/tests/Valit.Tests/Float/Float_IsNumber_Tests.cs index ef0e32b..1d3f2e2 100644 --- a/tests/Valit.Tests/Float/Float_IsNumber_Tests.cs +++ b/tests/Valit.Tests/Float/Float_IsNumber_Tests.cs @@ -1,4 +1,4 @@ -using Shouldly; +using Shouldly; using System; using Xunit; diff --git a/tests/Valit.Tests/Float/Float_IsPositive_Tests.cs b/tests/Valit.Tests/Float/Float_IsPositive_Tests.cs index b6811ba..1cd1122 100644 --- a/tests/Valit.Tests/Float/Float_IsPositive_Tests.cs +++ b/tests/Valit.Tests/Float/Float_IsPositive_Tests.cs @@ -6,14 +6,14 @@ namespace Valit.Tests.Float { public class Float_IsPositive_Tests { - [Fact] + [Fact] public void Float_IsPositive_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsPositive(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -24,14 +24,14 @@ public void Float_IsPositive_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsPositive(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Fact] public void Float_IsPositive_Succeeds_When_Given_Value_Is_Postive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.PositiveValue, _=>_ @@ -44,7 +44,7 @@ public void Float_IsPositive_Succeeds_When_Given_Value_Is_Postive() [Fact] public void Float_IsPositive_Fails_When_Given_Value_Is_Zero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.ZeroValue, _=>_ @@ -83,7 +83,7 @@ public void Float_IsPositive_Fails_When_Given_Value_Is_NaN() [Fact] public void Float_IsPositive_Succeeds_When_Given_Value_Is_NullablePostive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullablePositiveValue, _=>_ @@ -96,7 +96,7 @@ public void Float_IsPositive_Succeeds_When_Given_Value_Is_NullablePostive() [Fact] public void Float_IsPositive_Fails_When_Given_Value_Is_NullableZero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableZeroValue, _=>_ @@ -109,7 +109,7 @@ public void Float_IsPositive_Fails_When_Given_Value_Is_NullableZero() [Fact] public void Float_IsPositive_Fails_When_Given_Value_Is_NullableNegative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableNegativeValue, _=>_ @@ -166,6 +166,6 @@ class Model public float? NullValue => null; public float? NullableNaN => Single.NaN; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Float/Float_Required_Tests.cs b/tests/Valit.Tests/Float/Float_Required_Tests.cs index a485c40..bed1f89 100644 --- a/tests/Valit.Tests/Float/Float_Required_Tests.cs +++ b/tests/Valit.Tests/Float/Float_Required_Tests.cs @@ -14,7 +14,7 @@ public void Float_Required_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .Required(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -73,4 +73,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Guid_/Guid_IsEqualTo_Tests.cs b/tests/Valit.Tests/Guid_/Guid_IsEqualTo_Tests.cs index 6ee8eee..53133aa 100644 --- a/tests/Valit.Tests/Guid_/Guid_IsEqualTo_Tests.cs +++ b/tests/Valit.Tests/Guid_/Guid_IsEqualTo_Tests.cs @@ -67,7 +67,7 @@ public void Guid_IsEqualTo_Returns_Proper_Result_For_Left_Value(string strValue, result.Succeeded.ShouldBe(expected); } - [Theory] + [Theory] [InlineData("7dca6d8e-255c-401c-b701-f18af9b2e191", false)] [InlineData("6f72f4ab-c2fc-4fca-b70e-b5ac7eccd054", true)] [InlineData("5c7ad720-6813-4c45-89c9-c4484bbbc34d", false)] @@ -145,7 +145,7 @@ public void Guid_IsEqualTo_Returns_Proper_Result_For_Nullable_Values(string strV public Guid_IsEqualTo_Tests() { _model = new Model(); - + } private readonly Model _model; @@ -158,4 +158,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Guid_/Guid_IsNotEmpty_Tests.cs b/tests/Valit.Tests/Guid_/Guid_IsNotEmpty_Tests.cs index 934d1ec..7db8a52 100644 --- a/tests/Valit.Tests/Guid_/Guid_IsNotEmpty_Tests.cs +++ b/tests/Valit.Tests/Guid_/Guid_IsNotEmpty_Tests.cs @@ -111,4 +111,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Guid_/Guid_Required_Tests.cs b/tests/Valit.Tests/Guid_/Guid_Required_Tests.cs index 2364519..a266f5d 100644 --- a/tests/Valit.Tests/Guid_/Guid_Required_Tests.cs +++ b/tests/Valit.Tests/Guid_/Guid_Required_Tests.cs @@ -58,4 +58,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/HelperExtensions/DateTimeExtensions.cs b/tests/Valit.Tests/HelperExtensions/DateTimeExtensions.cs index 6e1bc3f..abcc984 100644 --- a/tests/Valit.Tests/HelperExtensions/DateTimeExtensions.cs +++ b/tests/Valit.Tests/HelperExtensions/DateTimeExtensions.cs @@ -8,4 +8,4 @@ public static class DateTimeExtensions => string.IsNullOrWhiteSpace(stringValue)? (DateTime?)null : Convert.ToDateTime(stringValue); } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/HelperExtensions/DateTimeOffsetExtensions.cs b/tests/Valit.Tests/HelperExtensions/DateTimeOffsetExtensions.cs index 6fa36dd..c83db6e 100644 --- a/tests/Valit.Tests/HelperExtensions/DateTimeOffsetExtensions.cs +++ b/tests/Valit.Tests/HelperExtensions/DateTimeOffsetExtensions.cs @@ -6,8 +6,8 @@ public static class DateTimeOffsetExtensions { public static DateTimeOffset AsDateTimeOffset(this string stringValue) => Convert.ToDateTime(stringValue); - + public static DateTimeOffset? AsNullableDateTimeOffset(this string stringValue) => string.IsNullOrWhiteSpace(stringValue)? (DateTimeOffset?)null : Convert.ToDateTime(stringValue); } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/HelperExtensions/DecimalExtensions.cs b/tests/Valit.Tests/HelperExtensions/DecimalExtensions.cs index 87cf958..eccc1f5 100644 --- a/tests/Valit.Tests/HelperExtensions/DecimalExtensions.cs +++ b/tests/Valit.Tests/HelperExtensions/DecimalExtensions.cs @@ -8,4 +8,4 @@ public static class DecimalExtensions => Convert.ToDecimal(stringValue) > 0? Convert.ToDecimal(stringValue) : (decimal?) null; } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int16/Int16_IsEqual_To_Tests.cs b/tests/Valit.Tests/Int16/Int16_IsEqual_To_Tests.cs index f1adc85..c889cb8 100644 --- a/tests/Valit.Tests/Int16/Int16_IsEqual_To_Tests.cs +++ b/tests/Valit.Tests/Int16/Int16_IsEqual_To_Tests.cs @@ -12,7 +12,7 @@ public void Int16_IsEqualTo_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Giv ((IValitRule)null) .IsEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void Int16_IsEqualTo_For_Not_Nullable_Value_And_Nullable_Value_Throws_Whe ((IValitRule)null) .IsEqualTo((short?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void Int16_IsEqualTo_For_Nullable_Value_And_Not_Nullable_Value_Throws_Whe ((IValitRule)null) .IsEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void Int16_IsEqualTo_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsEqualTo((short?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void Int16_IsEqualTo_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() [Theory] [InlineData(10, true)] [InlineData(9, false)] - [InlineData(11, false)] + [InlineData(11, false)] public void Int16_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(short value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void Int16_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(short [Theory] [InlineData((short) 10, true)] [InlineData((short) 9, false)] - [InlineData((short) 11, false)] - [InlineData(null, false)] + [InlineData((short) 11, false)] + [InlineData(null, false)] public void Int16_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(short? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void Int16_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nu [Theory] [InlineData(false, 10, true)] - [InlineData(false, 9, false)] - [InlineData(false, 11, false)] - [InlineData(true, 10, false)] + [InlineData(false, 9, false)] + [InlineData(false, 11, false)] + [InlineData(true, 10, false)] public void Int16_IsEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, short value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void Int16_IsEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nu } [Theory] - [InlineData(false, (short) 10, true)] - [InlineData(false, (short) 9, false)] + [InlineData(false, (short) 10, true)] + [InlineData(false, (short) 9, false)] [InlineData(false, (short) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (short) 10, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (short) 10, false)] + [InlineData(true, null, false)] public void Int16_IsEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, short? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -133,6 +133,6 @@ class Model public short? NullableValue => 10; public short? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int16/Int16_IsGreaterThanOrEqualTo_Tests.cs b/tests/Valit.Tests/Int16/Int16_IsGreaterThanOrEqualTo_Tests.cs index b6db356..d42ba97 100644 --- a/tests/Valit.Tests/Int16/Int16_IsGreaterThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/Int16/Int16_IsGreaterThanOrEqualTo_Tests.cs @@ -12,7 +12,7 @@ public void Int16_IsGreaterThanOrEqualTo_For_Not_Nullable_Values_Throws_When_Nul ((IValitRule)null) .IsGreaterThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void Int16_IsGreaterThanOrEqualTo_For_Not_Nullable_Value_And_Nullable_Val ((IValitRule)null) .IsGreaterThanOrEqualTo((short?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void Int16_IsGreaterThanOrEqualTo_For_Nullable_Value_And_Not_Nullable_Val ((IValitRule)null) .IsGreaterThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void Int16_IsGreaterThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Ru ((IValitRule)null) .IsGreaterThanOrEqualTo((short?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void Int16_IsGreaterThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Ru [Theory] [InlineData(9, true)] [InlineData(10, true)] - [InlineData(11, false)] + [InlineData(11, false)] public void Int16_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(short value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void Int16_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable [Theory] [InlineData((short) 9, true)] [InlineData((short) 10, true)] - [InlineData((short) 11, false)] - [InlineData(null, false)] + [InlineData((short) 11, false)] + [InlineData(null, false)] public void Int16_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(short? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void Int16_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable [Theory] [InlineData(false, 9, true)] - [InlineData(false, 10, true)] - [InlineData(false, 11, false)] - [InlineData(true, 9, false)] + [InlineData(false, 10, true)] + [InlineData(false, 11, false)] + [InlineData(true, 9, false)] public void Int16_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, short value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void Int16_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Val } [Theory] - [InlineData(false, (short) 9, true)] - [InlineData(false, (short) 10, true)] + [InlineData(false, (short) 9, true)] + [InlineData(false, (short) 10, true)] [InlineData(false, (short) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (short) 9, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (short) 9, false)] + [InlineData(true, null, false)] public void Int16_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, short? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -135,4 +135,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int16/Int16_IsGreaterThan_Tests.cs b/tests/Valit.Tests/Int16/Int16_IsGreaterThan_Tests.cs index 4e0d873..43b87f2 100644 --- a/tests/Valit.Tests/Int16/Int16_IsGreaterThan_Tests.cs +++ b/tests/Valit.Tests/Int16/Int16_IsGreaterThan_Tests.cs @@ -13,7 +13,7 @@ public void Int16_IsGreaterThan_For_Not_Nullable_Values_Throws_When_Null_Rule_Is ((IValitRule)null) .IsGreaterThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -24,7 +24,7 @@ public void Int16_IsGreaterThan_For_Not_Nullable_Value_And_Nullable_Value_Throws ((IValitRule)null) .IsGreaterThan((short?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -35,7 +35,7 @@ public void Int16_IsGreaterThan_For_Nullable_Value_And_Not_Nullable_Value_Throws ((IValitRule)null) .IsGreaterThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -46,7 +46,7 @@ public void Int16_IsGreaterThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Giv ((IValitRule)null) .IsGreaterThan((short?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -54,9 +54,9 @@ public void Int16_IsGreaterThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Giv [Theory] [InlineData(9, true)] [InlineData(10, false)] - [InlineData(11, false)] + [InlineData(11, false)] public void Int16_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Values(short value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -70,10 +70,10 @@ public void Int16_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Values(s [Theory] [InlineData((short) 9, true)] [InlineData((short) 10, false)] - [InlineData((short) 11, false)] - [InlineData(null, false)] + [InlineData((short) 11, false)] + [InlineData(null, false)] public void Int16_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(short? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -86,11 +86,11 @@ public void Int16_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Value_An [Theory] [InlineData(false, 9, true)] - [InlineData(false, 10, false)] - [InlineData(false, 11, false)] - [InlineData(true, 9, false)] + [InlineData(false, 10, false)] + [InlineData(false, 11, false)] + [InlineData(true, 9, false)] public void Int16_IsGreaterThan_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, short value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -102,14 +102,14 @@ public void Int16_IsGreaterThan_Returns_Proper_Results_For_Nullable_Value_And_No } [Theory] - [InlineData(false, (short) 9, true)] - [InlineData(false, (short) 10, false)] + [InlineData(false, (short) 9, true)] + [InlineData(false, (short) 10, false)] [InlineData(false, (short) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (short) 9, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (short) 9, false)] + [InlineData(true, null, false)] public void Int16_IsGreaterThan_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, short? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -136,4 +136,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int16/Int16_IsLessThanOrEqualTo_Tests.cs b/tests/Valit.Tests/Int16/Int16_IsLessThanOrEqualTo_Tests.cs index 0f8f633..9d2206d 100644 --- a/tests/Valit.Tests/Int16/Int16_IsLessThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/Int16/Int16_IsLessThanOrEqualTo_Tests.cs @@ -12,7 +12,7 @@ public void Int16_IsLessThanOrEqualTo_For_Not_Nullable_Values_Throws_When_Null_R ((IValitRule)null) .IsLessThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void Int16_IsLessThanOrEqualTo_For_Not_Nullable_Value_And_Nullable_Value_ ((IValitRule)null) .IsLessThanOrEqualTo((short?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void Int16_IsLessThanOrEqualTo_For_Nullable_Value_And_Not_Nullable_Value_ ((IValitRule)null) .IsLessThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void Int16_IsLessThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Rule_ ((IValitRule)null) .IsLessThanOrEqualTo((short?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void Int16_IsLessThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Rule_ [Theory] [InlineData(11, true)] [InlineData(10, true)] - [InlineData(9, false)] + [InlineData(9, false)] public void Int16_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(short value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void Int16_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Va [Theory] [InlineData((short) 11, true)] [InlineData((short) 10, true)] - [InlineData((short) 9, false)] - [InlineData(null, false)] + [InlineData((short) 9, false)] + [InlineData(null, false)] public void Int16_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(short? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void Int16_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Va [Theory] [InlineData(false, 11, true)] - [InlineData(false, 10, true)] - [InlineData(false, 9, false)] - [InlineData(true, 11, false)] + [InlineData(false, 10, true)] + [InlineData(false, 9, false)] + [InlineData(true, 11, false)] public void Int16_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, short value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void Int16_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_ } [Theory] - [InlineData(false, (short) 11, true)] - [InlineData(false, (short) 10, true)] + [InlineData(false, (short) 11, true)] + [InlineData(false, (short) 10, true)] [InlineData(false, (short) 9, false)] - [InlineData(false, null, false)] - [InlineData(true, (short) 11, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (short) 11, false)] + [InlineData(true, null, false)] public void Int16_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, short? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -133,6 +133,6 @@ class Model public short? NullableValue => 10; public short? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int16/Int16_IsLessThan_Tests.cs b/tests/Valit.Tests/Int16/Int16_IsLessThan_Tests.cs index 701ea3c..6aeb917 100644 --- a/tests/Valit.Tests/Int16/Int16_IsLessThan_Tests.cs +++ b/tests/Valit.Tests/Int16/Int16_IsLessThan_Tests.cs @@ -5,7 +5,7 @@ namespace Valit.Tests.Int16 { public class Int16_IsLessThan_Tests { - + [Fact] public void Int16_IsLessThan_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Given() { @@ -13,7 +13,7 @@ public void Int16_IsLessThan_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Gi ((IValitRule)null) .IsLessThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -24,7 +24,7 @@ public void Int16_IsLessThan_For_Not_Nullable_Value_And_Nullable_Value_Throws_Wh ((IValitRule)null) .IsLessThan((short?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -35,7 +35,7 @@ public void Int16_IsLessThan_For_Nullable_Value_And_Not_Nullable_Value_Throws_Wh ((IValitRule)null) .IsLessThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -46,7 +46,7 @@ public void Int16_IsLessThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Given( ((IValitRule)null) .IsLessThan((short?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -54,9 +54,9 @@ public void Int16_IsLessThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Given( [Theory] [InlineData(11, true)] [InlineData(10, false)] - [InlineData(9, false)] + [InlineData(9, false)] public void Int16_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Values(short value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -70,10 +70,10 @@ public void Int16_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Values(shor [Theory] [InlineData((short) 11, true)] [InlineData((short) 10, false)] - [InlineData((short) 9, false)] - [InlineData(null, false)] + [InlineData((short) 9, false)] + [InlineData(null, false)] public void Int16_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(short? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -86,11 +86,11 @@ public void Int16_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Value_And_N [Theory] [InlineData(false, 11, true)] - [InlineData(false, 10, false)] - [InlineData(false, 9, false)] - [InlineData(true, 11, false)] + [InlineData(false, 10, false)] + [InlineData(false, 9, false)] + [InlineData(true, 11, false)] public void Int16_IsLessThan_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, short value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -102,14 +102,14 @@ public void Int16_IsLessThan_Returns_Proper_Results_For_Nullable_Value_And_Not_N } [Theory] - [InlineData(false, (short) 11, true)] - [InlineData(false, (short) 10, false)] + [InlineData(false, (short) 11, true)] + [InlineData(false, (short) 10, false)] [InlineData(false, (short) 9, false)] - [InlineData(false, null, false)] - [InlineData(true, (short) 11, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (short) 11, false)] + [InlineData(true, null, false)] public void Int16_IsLessThan_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, short? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -136,5 +136,5 @@ class Model } #endregion } - -} \ No newline at end of file + +} diff --git a/tests/Valit.Tests/Int16/Int16_IsNegative_Tests.cs b/tests/Valit.Tests/Int16/Int16_IsNegative_Tests.cs index 4b60cec..00a847b 100644 --- a/tests/Valit.Tests/Int16/Int16_IsNegative_Tests.cs +++ b/tests/Valit.Tests/Int16/Int16_IsNegative_Tests.cs @@ -5,14 +5,14 @@ namespace Valit.Tests.Int16 { public class Int16_IsNegative_Tests { - [Fact] + [Fact] public void Int16_IsNegative_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsNegative(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,14 +23,14 @@ public void Int16_IsNegative_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsNegative(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Fact] public void Int16_IsNegative_Succeeds_When_Given_Value_Is_Negative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NegativeValue, _=>_ @@ -43,7 +43,7 @@ public void Int16_IsNegative_Succeeds_When_Given_Value_Is_Negative() [Fact] public void Int16_IsNegative_Fails_When_Given_Value_Is_Zero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.ZeroValue, _=>_ @@ -56,7 +56,7 @@ public void Int16_IsNegative_Fails_When_Given_Value_Is_Zero() [Fact] public void Int16_IsNegative_Fails_When_Given_Value_Is_Positive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.PositiveValue, _=>_ @@ -69,7 +69,7 @@ public void Int16_IsNegative_Fails_When_Given_Value_Is_Positive() [Fact] public void Int16_IsNegative_Succeeds_When_Given_Value_Is_NullableNegative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableNegativeValue, _=>_ @@ -82,7 +82,7 @@ public void Int16_IsNegative_Succeeds_When_Given_Value_Is_NullableNegative() [Fact] public void Int16_IsNegative_Fails_When_Given_Value_Is_NullableZero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableZeroValue, _=>_ @@ -95,7 +95,7 @@ public void Int16_IsNegative_Fails_When_Given_Value_Is_NullableZero() [Fact] public void Int16_IsNegative_Fails_When_Given_Value_Is_NullablePositive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullablePositiveValue, _=>_ @@ -108,7 +108,7 @@ public void Int16_IsNegative_Fails_When_Given_Value_Is_NullablePositive() [Fact] public void Int16_IsNegative_Fails_When_Given_Value_Is_Null() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullValue, _=>_ @@ -137,6 +137,6 @@ class Model public short? NullableNegativeValue => -10; public short? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int16/Int16_IsNonZero_Tests.cs b/tests/Valit.Tests/Int16/Int16_IsNonZero_Tests.cs index b300dbf..9eb5760 100644 --- a/tests/Valit.Tests/Int16/Int16_IsNonZero_Tests.cs +++ b/tests/Valit.Tests/Int16/Int16_IsNonZero_Tests.cs @@ -5,14 +5,14 @@ namespace Valit.Tests.Int16 { public class Int16_IsNonZero_Tests { - [Fact] + [Fact] public void Int16_IsNonZero_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsNonZero(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,16 +23,16 @@ public void Int16_IsNonZero_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsNonZero(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void Int16_IsNonZero_Returns_Proper_Results_For_Not_Nullable_Value(bool useZeroValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useZeroValue? m.ZeroValue : m.Value, _=>_ @@ -45,9 +45,9 @@ public void Int16_IsNonZero_Returns_Proper_Results_For_Not_Nullable_Value(bool u [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void Int16_IsNonZero_Returns_Proper_Results_For_Nullable_Value(bool useZeroValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useZeroValue? m.NullableZeroValue : m.NullableValue, _=>_ @@ -60,7 +60,7 @@ public void Int16_IsNonZero_Returns_Proper_Results_For_Nullable_Value(bool useZe [Fact] public void Int16_IsNonZero_Fails_For_Null_Value() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullValue, _=>_ @@ -89,4 +89,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int16/Int16_IsPositive_Tests.cs b/tests/Valit.Tests/Int16/Int16_IsPositive_Tests.cs index edca0bb..4604772 100644 --- a/tests/Valit.Tests/Int16/Int16_IsPositive_Tests.cs +++ b/tests/Valit.Tests/Int16/Int16_IsPositive_Tests.cs @@ -5,14 +5,14 @@ namespace Valit.Tests.Int16 { public class Int16_IsPositive_Tests { - [Fact] + [Fact] public void Int16_IsPositive_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsPositive(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,14 +23,14 @@ public void Int16_IsPositive_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsPositive(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Fact] public void Int16_IsPositive_Succeeds_When_Given_Value_Is_Postive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.PositiveValue, _=>_ @@ -43,7 +43,7 @@ public void Int16_IsPositive_Succeeds_When_Given_Value_Is_Postive() [Fact] public void Int16_IsPositive_Fails_When_Given_Value_Is_Zero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.ZeroValue, _=>_ @@ -56,7 +56,7 @@ public void Int16_IsPositive_Fails_When_Given_Value_Is_Zero() [Fact] public void Int16_IsPositive_Fails_When_Given_Value_Is_Negative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NegativeValue, _=>_ @@ -69,7 +69,7 @@ public void Int16_IsPositive_Fails_When_Given_Value_Is_Negative() [Fact] public void Int16_IsPositive_Succeeds_When_Given_Value_Is_NullablePostive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullablePositiveValue, _=>_ @@ -82,7 +82,7 @@ public void Int16_IsPositive_Succeeds_When_Given_Value_Is_NullablePostive() [Fact] public void Int16_IsPositive_Fails_When_Given_Value_Is_NullableZero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableZeroValue, _=>_ @@ -95,7 +95,7 @@ public void Int16_IsPositive_Fails_When_Given_Value_Is_NullableZero() [Fact] public void Int16_IsPositive_Fails_When_Given_Value_Is_NullableNegative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableNegativeValue, _=>_ @@ -108,7 +108,7 @@ public void Int16_IsPositive_Fails_When_Given_Value_Is_NullableNegative() [Fact] public void Int16_IsPositive_Fails_When_Given_Value_Is_Null() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullValue, _=>_ @@ -137,6 +137,6 @@ class Model public short? NullableNegativeValue => -10; public short? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int16/Int16_Required_Tests.cs b/tests/Valit.Tests/Int16/Int16_Required_Tests.cs index 1889ff7..9286625 100644 --- a/tests/Valit.Tests/Int16/Int16_Required_Tests.cs +++ b/tests/Valit.Tests/Int16/Int16_Required_Tests.cs @@ -13,16 +13,16 @@ public void Int16_Required_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .Required(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void Int16_Required_Returns_Proper_Results_For_Nullable_Value(bool useNullValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -51,4 +51,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int32/Int32_IsEqual_To_Tests.cs b/tests/Valit.Tests/Int32/Int32_IsEqual_To_Tests.cs index d2af935..26839f3 100644 --- a/tests/Valit.Tests/Int32/Int32_IsEqual_To_Tests.cs +++ b/tests/Valit.Tests/Int32/Int32_IsEqual_To_Tests.cs @@ -12,7 +12,7 @@ public void Int32_IsEqualTo_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Giv ((IValitRule)null) .IsEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void Int32_IsEqualTo_For_Not_Nullable_Value_And_Nullable_Value_Throws_Whe ((IValitRule)null) .IsEqualTo((int?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void Int32_IsEqualTo_For_Nullable_Value_And_Not_Nullable_Value_Throws_Whe ((IValitRule)null) .IsEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void Int32_IsEqualTo_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsEqualTo((int?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void Int32_IsEqualTo_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() [Theory] [InlineData(10, true)] [InlineData(9, false)] - [InlineData(11, false)] + [InlineData(11, false)] public void Int32_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(int value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void Int32_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(int v [Theory] [InlineData((int) 10, true)] [InlineData((int) 9, false)] - [InlineData((int) 11, false)] - [InlineData(null, false)] + [InlineData((int) 11, false)] + [InlineData(null, false)] public void Int32_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(int? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void Int32_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nu [Theory] [InlineData(false, 10, true)] - [InlineData(false, 9, false)] - [InlineData(false, 11, false)] - [InlineData(true, 10, false)] + [InlineData(false, 9, false)] + [InlineData(false, 11, false)] + [InlineData(true, 10, false)] public void Int32_IsEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, int value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void Int32_IsEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nu } [Theory] - [InlineData(false, (int) 10, true)] - [InlineData(false, (int) 9, false)] + [InlineData(false, (int) 10, true)] + [InlineData(false, (int) 9, false)] [InlineData(false, (int) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (int) 10, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (int) 10, false)] + [InlineData(true, null, false)] public void Int32_IsEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, int? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -133,6 +133,6 @@ class Model public int? NullableValue => 10; public int? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int32/Int32_IsGreaterThanOrEqualTo_Tests.cs b/tests/Valit.Tests/Int32/Int32_IsGreaterThanOrEqualTo_Tests.cs index 42a5e20..3dfbd1c 100644 --- a/tests/Valit.Tests/Int32/Int32_IsGreaterThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/Int32/Int32_IsGreaterThanOrEqualTo_Tests.cs @@ -12,7 +12,7 @@ public void Int32_IsGreaterThanOrEqualTo_For_Not_Nullable_Values_Throws_When_Nul ((IValitRule)null) .IsGreaterThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void Int32_IsGreaterThanOrEqualTo_For_Not_Nullable_Value_And_Nullable_Val ((IValitRule)null) .IsGreaterThanOrEqualTo((int?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void Int32_IsGreaterThanOrEqualTo_For_Nullable_Value_And_Not_Nullable_Val ((IValitRule)null) .IsGreaterThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void Int32_IsGreaterThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Ru ((IValitRule)null) .IsGreaterThanOrEqualTo((int?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void Int32_IsGreaterThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Ru [Theory] [InlineData(9, true)] [InlineData(10, true)] - [InlineData(11, false)] + [InlineData(11, false)] public void Int32_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(int value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void Int32_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable [Theory] [InlineData((int) 9, true)] [InlineData((int) 10, true)] - [InlineData((int) 11, false)] - [InlineData(null, false)] + [InlineData((int) 11, false)] + [InlineData(null, false)] public void Int32_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(int? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void Int32_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable [Theory] [InlineData(false, 9, true)] - [InlineData(false, 10, true)] - [InlineData(false, 11, false)] - [InlineData(true, 9, false)] + [InlineData(false, 10, true)] + [InlineData(false, 11, false)] + [InlineData(true, 9, false)] public void Int32_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, int value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void Int32_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Val } [Theory] - [InlineData(false, (int) 9, true)] - [InlineData(false, (int) 10, true)] + [InlineData(false, (int) 9, true)] + [InlineData(false, (int) 10, true)] [InlineData(false, (int) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (int) 9, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (int) 9, false)] + [InlineData(true, null, false)] public void Int32_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, int? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -135,4 +135,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int32/Int32_IsGreaterThan_Tests.cs b/tests/Valit.Tests/Int32/Int32_IsGreaterThan_Tests.cs index a789c06..bdd43a7 100644 --- a/tests/Valit.Tests/Int32/Int32_IsGreaterThan_Tests.cs +++ b/tests/Valit.Tests/Int32/Int32_IsGreaterThan_Tests.cs @@ -13,7 +13,7 @@ public void Int32_IsGreaterThan_For_Not_Nullable_Values_Throws_When_Null_Rule_Is ((IValitRule)null) .IsGreaterThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -24,7 +24,7 @@ public void Int32_IsGreaterThan_For_Not_Nullable_Value_And_Nullable_Value_Throws ((IValitRule)null) .IsGreaterThan((int?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -35,7 +35,7 @@ public void Int32_IsGreaterThan_For_Nullable_Value_And_Not_Nullable_Value_Throws ((IValitRule)null) .IsGreaterThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -46,7 +46,7 @@ public void Int32_IsGreaterThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Giv ((IValitRule)null) .IsGreaterThan((int?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -54,9 +54,9 @@ public void Int32_IsGreaterThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Giv [Theory] [InlineData(9, true)] [InlineData(10, false)] - [InlineData(11, false)] + [InlineData(11, false)] public void Int32_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Values(int value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -70,10 +70,10 @@ public void Int32_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Values(i [Theory] [InlineData((int) 9, true)] [InlineData((int) 10, false)] - [InlineData((int) 11, false)] - [InlineData(null, false)] + [InlineData((int) 11, false)] + [InlineData(null, false)] public void Int32_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(int? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -86,11 +86,11 @@ public void Int32_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Value_An [Theory] [InlineData(false, 9, true)] - [InlineData(false, 10, false)] - [InlineData(false, 11, false)] - [InlineData(true, 9, false)] + [InlineData(false, 10, false)] + [InlineData(false, 11, false)] + [InlineData(true, 9, false)] public void Int32_IsGreaterThan_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, int value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -102,14 +102,14 @@ public void Int32_IsGreaterThan_Returns_Proper_Results_For_Nullable_Value_And_No } [Theory] - [InlineData(false, (int) 9, true)] - [InlineData(false, (int) 10, false)] + [InlineData(false, (int) 9, true)] + [InlineData(false, (int) 10, false)] [InlineData(false, (int) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (int) 9, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (int) 9, false)] + [InlineData(true, null, false)] public void Int32_IsGreaterThan_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, int? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -136,4 +136,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int32/Int32_IsLessThanOrEqualTo_Tests.cs b/tests/Valit.Tests/Int32/Int32_IsLessThanOrEqualTo_Tests.cs index 4df696a..252d661 100644 --- a/tests/Valit.Tests/Int32/Int32_IsLessThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/Int32/Int32_IsLessThanOrEqualTo_Tests.cs @@ -12,7 +12,7 @@ public void Int32_IsLessThanOrEqualTo_For_Not_Nullable_Values_Throws_When_Null_R ((IValitRule)null) .IsLessThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void Int32_IsLessThanOrEqualTo_For_Not_Nullable_Value_And_Nullable_Value_ ((IValitRule)null) .IsLessThanOrEqualTo((int?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void Int32_IsLessThanOrEqualTo_For_Nullable_Value_And_Not_Nullable_Value_ ((IValitRule)null) .IsLessThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void Int32_IsLessThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Rule_ ((IValitRule)null) .IsLessThanOrEqualTo((int?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void Int32_IsLessThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Rule_ [Theory] [InlineData(11, true)] [InlineData(10, true)] - [InlineData(9, false)] + [InlineData(9, false)] public void Int32_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(int value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void Int32_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Va [Theory] [InlineData((int) 11, true)] [InlineData((int) 10, true)] - [InlineData((int) 9, false)] - [InlineData(null, false)] + [InlineData((int) 9, false)] + [InlineData(null, false)] public void Int32_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(int? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void Int32_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Va [Theory] [InlineData(false, 11, true)] - [InlineData(false, 10, true)] - [InlineData(false, 9, false)] - [InlineData(true, 11, false)] + [InlineData(false, 10, true)] + [InlineData(false, 9, false)] + [InlineData(true, 11, false)] public void Int32_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, int value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void Int32_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_ } [Theory] - [InlineData(false, (int) 11, true)] - [InlineData(false, (int) 10, true)] + [InlineData(false, (int) 11, true)] + [InlineData(false, (int) 10, true)] [InlineData(false, (int) 9, false)] - [InlineData(false, null, false)] - [InlineData(true, (int) 11, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (int) 11, false)] + [InlineData(true, null, false)] public void Int32_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, int? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -133,6 +133,6 @@ class Model public int? NullableValue => 10; public int? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int32/Int32_IsLessThan_Tests.cs b/tests/Valit.Tests/Int32/Int32_IsLessThan_Tests.cs index 61de1d0..f86f28b 100644 --- a/tests/Valit.Tests/Int32/Int32_IsLessThan_Tests.cs +++ b/tests/Valit.Tests/Int32/Int32_IsLessThan_Tests.cs @@ -5,7 +5,7 @@ namespace Valit.Tests.Int32 { public class Int32_IsLessThan_Tests { - + [Fact] public void Int32_IsLessThan_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Given() { @@ -13,7 +13,7 @@ public void Int32_IsLessThan_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Gi ((IValitRule)null) .IsLessThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -24,7 +24,7 @@ public void Int32_IsLessThan_For_Not_Nullable_Value_And_Nullable_Value_Throws_Wh ((IValitRule)null) .IsLessThan((int?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -35,7 +35,7 @@ public void Int32_IsLessThan_For_Nullable_Value_And_Not_Nullable_Value_Throws_Wh ((IValitRule)null) .IsLessThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -46,7 +46,7 @@ public void Int32_IsLessThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Given( ((IValitRule)null) .IsLessThan((int?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -54,9 +54,9 @@ public void Int32_IsLessThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Given( [Theory] [InlineData(11, true)] [InlineData(10, false)] - [InlineData(9, false)] + [InlineData(9, false)] public void Int32_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Values(int value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -70,10 +70,10 @@ public void Int32_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Values(int [Theory] [InlineData((int) 11, true)] [InlineData((int) 10, false)] - [InlineData((int) 9, false)] - [InlineData(null, false)] + [InlineData((int) 9, false)] + [InlineData(null, false)] public void Int32_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(int? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -86,11 +86,11 @@ public void Int32_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Value_And_N [Theory] [InlineData(false, 11, true)] - [InlineData(false, 10, false)] - [InlineData(false, 9, false)] - [InlineData(true, 11, false)] + [InlineData(false, 10, false)] + [InlineData(false, 9, false)] + [InlineData(true, 11, false)] public void Int32_IsLessThan_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, int value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -102,14 +102,14 @@ public void Int32_IsLessThan_Returns_Proper_Results_For_Nullable_Value_And_Not_N } [Theory] - [InlineData(false, (int) 11, true)] - [InlineData(false, (int) 10, false)] + [InlineData(false, (int) 11, true)] + [InlineData(false, (int) 10, false)] [InlineData(false, (int) 9, false)] - [InlineData(false, null, false)] - [InlineData(true, (int) 11, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (int) 11, false)] + [InlineData(true, null, false)] public void Int32_IsLessThan_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, int? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -136,5 +136,5 @@ class Model } #endregion } - -} \ No newline at end of file + +} diff --git a/tests/Valit.Tests/Int32/Int32_IsNegative_Tests.cs b/tests/Valit.Tests/Int32/Int32_IsNegative_Tests.cs index 441138c..944b8e0 100644 --- a/tests/Valit.Tests/Int32/Int32_IsNegative_Tests.cs +++ b/tests/Valit.Tests/Int32/Int32_IsNegative_Tests.cs @@ -5,14 +5,14 @@ namespace Valit.Tests.Int32 { public class Int32_IsNegative_Tests { - [Fact] + [Fact] public void Int32_IsNegative_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsNegative(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,14 +23,14 @@ public void Int32_IsNegative_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsNegative(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Fact] public void Int32_IsNegative_Succeeds_When_Given_Value_Is_Negative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NegativeValue, _=>_ @@ -43,7 +43,7 @@ public void Int32_IsNegative_Succeeds_When_Given_Value_Is_Negative() [Fact] public void Int32_IsNegative_Fails_When_Given_Value_Is_Zero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.ZeroValue, _=>_ @@ -56,7 +56,7 @@ public void Int32_IsNegative_Fails_When_Given_Value_Is_Zero() [Fact] public void Int32_IsNegative_Fails_When_Given_Value_Is_Positive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.PositiveValue, _=>_ @@ -69,7 +69,7 @@ public void Int32_IsNegative_Fails_When_Given_Value_Is_Positive() [Fact] public void Int32_IsNegative_Succeeds_When_Given_Value_Is_NullableNegative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableNegativeValue, _=>_ @@ -82,7 +82,7 @@ public void Int32_IsNegative_Succeeds_When_Given_Value_Is_NullableNegative() [Fact] public void Int32_IsNegative_Fails_When_Given_Value_Is_NullableZero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableZeroValue, _=>_ @@ -95,7 +95,7 @@ public void Int32_IsNegative_Fails_When_Given_Value_Is_NullableZero() [Fact] public void Int32_IsNegative_Fails_When_Given_Value_Is_NullablePositive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullablePositiveValue, _=>_ @@ -108,7 +108,7 @@ public void Int32_IsNegative_Fails_When_Given_Value_Is_NullablePositive() [Fact] public void Int32_IsNegative_Fails_When_Given_Value_Is_Null() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullValue, _=>_ @@ -137,6 +137,6 @@ class Model public int? NullableNegativeValue => -10; public int? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int32/Int32_IsNonZero_Tests.cs b/tests/Valit.Tests/Int32/Int32_IsNonZero_Tests.cs index 68567ab..477ac29 100644 --- a/tests/Valit.Tests/Int32/Int32_IsNonZero_Tests.cs +++ b/tests/Valit.Tests/Int32/Int32_IsNonZero_Tests.cs @@ -5,14 +5,14 @@ namespace Valit.Tests.Int32 { public class Int32_IsNonZero_Tests { - [Fact] + [Fact] public void Int32_IsNonZero_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsNonZero(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,16 +23,16 @@ public void Int32_IsNonZero_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsNonZero(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void Int32_IsNonZero_Returns_Proper_Results_For_Not_Nullable_Value(bool useZeroValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useZeroValue? m.ZeroValue : m.Value, _=>_ @@ -45,9 +45,9 @@ public void Int32_IsNonZero_Returns_Proper_Results_For_Not_Nullable_Value(bool u [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void Int32_IsNonZero_Returns_Proper_Results_For_Nullable_Value(bool useZeroValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useZeroValue? m.NullableZeroValue : m.NullableValue, _=>_ @@ -60,7 +60,7 @@ public void Int32_IsNonZero_Returns_Proper_Results_For_Nullable_Value(bool useZe [Fact] public void Int32_IsNonZero_Fails_For_Null_Value() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullValue, _=>_ @@ -89,4 +89,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int32/Int32_IsPositive_Tests.cs b/tests/Valit.Tests/Int32/Int32_IsPositive_Tests.cs index 18efcce..3502740 100644 --- a/tests/Valit.Tests/Int32/Int32_IsPositive_Tests.cs +++ b/tests/Valit.Tests/Int32/Int32_IsPositive_Tests.cs @@ -5,14 +5,14 @@ namespace Valit.Tests.Int32 { public class Int32_IsPositive_Tests { - [Fact] + [Fact] public void Int32_IsPositive_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsPositive(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,14 +23,14 @@ public void Int32_IsPositive_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsPositive(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Fact] public void Int32_IsPositive_Succeeds_When_Given_Value_Is_Postive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.PositiveValue, _=>_ @@ -43,7 +43,7 @@ public void Int32_IsPositive_Succeeds_When_Given_Value_Is_Postive() [Fact] public void Int32_IsPositive_Fails_When_Given_Value_Is_Zero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.ZeroValue, _=>_ @@ -56,7 +56,7 @@ public void Int32_IsPositive_Fails_When_Given_Value_Is_Zero() [Fact] public void Int32_IsPositive_Fails_When_Given_Value_Is_Negative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NegativeValue, _=>_ @@ -69,7 +69,7 @@ public void Int32_IsPositive_Fails_When_Given_Value_Is_Negative() [Fact] public void Int32_IsPositive_Succeeds_When_Given_Value_Is_NullablePostive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullablePositiveValue, _=>_ @@ -82,7 +82,7 @@ public void Int32_IsPositive_Succeeds_When_Given_Value_Is_NullablePostive() [Fact] public void Int32_IsPositive_Fails_When_Given_Value_Is_NullableZero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableZeroValue, _=>_ @@ -95,7 +95,7 @@ public void Int32_IsPositive_Fails_When_Given_Value_Is_NullableZero() [Fact] public void Int32_IsPositive_Fails_When_Given_Value_Is_NullableNegative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableNegativeValue, _=>_ @@ -108,7 +108,7 @@ public void Int32_IsPositive_Fails_When_Given_Value_Is_NullableNegative() [Fact] public void Int32_IsPositive_Fails_When_Given_Value_Is_Null() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullValue, _=>_ @@ -137,6 +137,6 @@ class Model public int? NullableNegativeValue => -10; public int? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int32/Int32_Required_Tests.cs b/tests/Valit.Tests/Int32/Int32_Required_Tests.cs index 6c02d0a..0f9fe18 100644 --- a/tests/Valit.Tests/Int32/Int32_Required_Tests.cs +++ b/tests/Valit.Tests/Int32/Int32_Required_Tests.cs @@ -13,16 +13,16 @@ public void Int32_Required_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .Required(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void Int32_Required_Returns_Proper_Results_For_Nullable_Value(bool useNullValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -51,4 +51,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int64/Int64_IsEqual_To_Tests.cs b/tests/Valit.Tests/Int64/Int64_IsEqual_To_Tests.cs index fdd63e2..4614138 100644 --- a/tests/Valit.Tests/Int64/Int64_IsEqual_To_Tests.cs +++ b/tests/Valit.Tests/Int64/Int64_IsEqual_To_Tests.cs @@ -12,7 +12,7 @@ public void Int64_IsEqualTo_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Giv ((IValitRule)null) .IsEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void Int64_IsEqualTo_For_Not_Nullable_Value_And_Nullable_Value_Throws_Whe ((IValitRule)null) .IsEqualTo((long?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void Int64_IsEqualTo_For_Nullable_Value_And_Not_Nullable_Value_Throws_Whe ((IValitRule)null) .IsEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void Int64_IsEqualTo_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsEqualTo((long?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void Int64_IsEqualTo_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() [Theory] [InlineData(10, true)] [InlineData(9, false)] - [InlineData(11, false)] + [InlineData(11, false)] public void Int64_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(long value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void Int64_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(long [Theory] [InlineData((long) 10, true)] [InlineData((long) 9, false)] - [InlineData((long) 11, false)] - [InlineData(null, false)] + [InlineData((long) 11, false)] + [InlineData(null, false)] public void Int64_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(long? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void Int64_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nu [Theory] [InlineData(false, 10, true)] - [InlineData(false, 9, false)] - [InlineData(false, 11, false)] - [InlineData(true, 10, false)] + [InlineData(false, 9, false)] + [InlineData(false, 11, false)] + [InlineData(true, 10, false)] public void Int64_IsEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, long value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void Int64_IsEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nu } [Theory] - [InlineData(false, (long) 10, true)] - [InlineData(false, (long) 9, false)] + [InlineData(false, (long) 10, true)] + [InlineData(false, (long) 9, false)] [InlineData(false, (long) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (long) 10, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (long) 10, false)] + [InlineData(true, null, false)] public void Int64_IsEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, long? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -133,6 +133,6 @@ class Model public long? NullableValue => 10; public long? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int64/Int64_IsGreaterThanOrEqualTo_Tests.cs b/tests/Valit.Tests/Int64/Int64_IsGreaterThanOrEqualTo_Tests.cs index 98f6dc6..74e157a 100644 --- a/tests/Valit.Tests/Int64/Int64_IsGreaterThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/Int64/Int64_IsGreaterThanOrEqualTo_Tests.cs @@ -12,7 +12,7 @@ public void Int64_IsGreaterThanOrEqualTo_For_Not_Nullable_Values_Throws_When_Nul ((IValitRule)null) .IsGreaterThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void Int64_IsGreaterThanOrEqualTo_For_Not_Nullable_Value_And_Nullable_Val ((IValitRule)null) .IsGreaterThanOrEqualTo((long?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void Int64_IsGreaterThanOrEqualTo_For_Nullable_Value_And_Not_Nullable_Val ((IValitRule)null) .IsGreaterThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void Int64_IsGreaterThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Ru ((IValitRule)null) .IsGreaterThanOrEqualTo((long?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void Int64_IsGreaterThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Ru [Theory] [InlineData(9, true)] [InlineData(10, true)] - [InlineData(11, false)] + [InlineData(11, false)] public void Int64_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(long value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void Int64_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable [Theory] [InlineData((long) 9, true)] [InlineData((long) 10, true)] - [InlineData((long) 11, false)] - [InlineData(null, false)] + [InlineData((long) 11, false)] + [InlineData(null, false)] public void Int64_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(long? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void Int64_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable [Theory] [InlineData(false, 9, true)] - [InlineData(false, 10, true)] - [InlineData(false, 11, false)] - [InlineData(true, 9, false)] + [InlineData(false, 10, true)] + [InlineData(false, 11, false)] + [InlineData(true, 9, false)] public void Int64_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, long value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void Int64_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Val } [Theory] - [InlineData(false, (long) 9, true)] - [InlineData(false, (long) 10, true)] + [InlineData(false, (long) 9, true)] + [InlineData(false, (long) 10, true)] [InlineData(false, (long) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (long) 9, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (long) 9, false)] + [InlineData(true, null, false)] public void Int64_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, long? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -135,4 +135,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int64/Int64_IsGreaterThan_Tests.cs b/tests/Valit.Tests/Int64/Int64_IsGreaterThan_Tests.cs index 04a5cef..fd0469b 100644 --- a/tests/Valit.Tests/Int64/Int64_IsGreaterThan_Tests.cs +++ b/tests/Valit.Tests/Int64/Int64_IsGreaterThan_Tests.cs @@ -13,7 +13,7 @@ public void Int64_IsGreaterThan_For_Not_Nullable_Values_Throws_When_Null_Rule_Is ((IValitRule)null) .IsGreaterThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -24,7 +24,7 @@ public void Int64_IsGreaterThan_For_Not_Nullable_Value_And_Nullable_Value_Throws ((IValitRule)null) .IsGreaterThan((long?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -35,7 +35,7 @@ public void Int64_IsGreaterThan_For_Nullable_Value_And_Not_Nullable_Value_Throws ((IValitRule)null) .IsGreaterThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -46,7 +46,7 @@ public void Int64_IsGreaterThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Giv ((IValitRule)null) .IsGreaterThan((long?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -54,9 +54,9 @@ public void Int64_IsGreaterThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Giv [Theory] [InlineData(9, true)] [InlineData(10, false)] - [InlineData(11, false)] + [InlineData(11, false)] public void Int64_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Values(long value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -70,10 +70,10 @@ public void Int64_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Values(l [Theory] [InlineData((long) 9, true)] [InlineData((long) 10, false)] - [InlineData((long) 11, false)] - [InlineData(null, false)] + [InlineData((long) 11, false)] + [InlineData(null, false)] public void Int64_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(long? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -86,11 +86,11 @@ public void Int64_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Value_An [Theory] [InlineData(false, 9, true)] - [InlineData(false, 10, false)] - [InlineData(false, 11, false)] - [InlineData(true, 9, false)] + [InlineData(false, 10, false)] + [InlineData(false, 11, false)] + [InlineData(true, 9, false)] public void Int64_IsGreaterThan_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, long value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -102,14 +102,14 @@ public void Int64_IsGreaterThan_Returns_Proper_Results_For_Nullable_Value_And_No } [Theory] - [InlineData(false, (long) 9, true)] - [InlineData(false, (long) 10, false)] + [InlineData(false, (long) 9, true)] + [InlineData(false, (long) 10, false)] [InlineData(false, (long) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (long) 9, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (long) 9, false)] + [InlineData(true, null, false)] public void Int64_IsGreaterThan_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, long? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -136,4 +136,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int64/Int64_IsLessThanOrEqualTo_Tests.cs b/tests/Valit.Tests/Int64/Int64_IsLessThanOrEqualTo_Tests.cs index 52f257e..75127c2 100644 --- a/tests/Valit.Tests/Int64/Int64_IsLessThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/Int64/Int64_IsLessThanOrEqualTo_Tests.cs @@ -12,7 +12,7 @@ public void Int64_IsLessThanOrEqualTo_For_Not_Nullable_Values_Throws_When_Null_R ((IValitRule)null) .IsLessThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void Int64_IsLessThanOrEqualTo_For_Not_Nullable_Value_And_Nullable_Value_ ((IValitRule)null) .IsLessThanOrEqualTo((long?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void Int64_IsLessThanOrEqualTo_For_Nullable_Value_And_Not_Nullable_Value_ ((IValitRule)null) .IsLessThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void Int64_IsLessThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Rule_ ((IValitRule)null) .IsLessThanOrEqualTo((long?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void Int64_IsLessThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Rule_ [Theory] [InlineData(11, true)] [InlineData(10, true)] - [InlineData(9, false)] + [InlineData(9, false)] public void Int64_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(long value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void Int64_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Va [Theory] [InlineData((long) 11, true)] [InlineData((long) 10, true)] - [InlineData((long) 9, false)] - [InlineData(null, false)] + [InlineData((long) 9, false)] + [InlineData(null, false)] public void Int64_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(long? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void Int64_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Va [Theory] [InlineData(false, 11, true)] - [InlineData(false, 10, true)] - [InlineData(false, 9, false)] - [InlineData(true, 11, false)] + [InlineData(false, 10, true)] + [InlineData(false, 9, false)] + [InlineData(true, 11, false)] public void Int64_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, long value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void Int64_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_ } [Theory] - [InlineData(false, (long) 11, true)] - [InlineData(false, (long) 10, true)] + [InlineData(false, (long) 11, true)] + [InlineData(false, (long) 10, true)] [InlineData(false, (long) 9, false)] - [InlineData(false, null, false)] - [InlineData(true, (long) 11, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (long) 11, false)] + [InlineData(true, null, false)] public void Int64_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, long? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -133,6 +133,6 @@ class Model public long? NullableValue => 10; public long? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int64/Int64_IsLessThan_Tests.cs b/tests/Valit.Tests/Int64/Int64_IsLessThan_Tests.cs index d5236e9..5563c4c 100644 --- a/tests/Valit.Tests/Int64/Int64_IsLessThan_Tests.cs +++ b/tests/Valit.Tests/Int64/Int64_IsLessThan_Tests.cs @@ -5,7 +5,7 @@ namespace Valit.Tests.Int64 { public class Int64_IsLessThan_Tests { - + [Fact] public void Int64_IsLessThan_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Given() { @@ -13,7 +13,7 @@ public void Int64_IsLessThan_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Gi ((IValitRule)null) .IsLessThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -24,7 +24,7 @@ public void Int64_IsLessThan_For_Not_Nullable_Value_And_Nullable_Value_Throws_Wh ((IValitRule)null) .IsLessThan((long?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -35,7 +35,7 @@ public void Int64_IsLessThan_For_Nullable_Value_And_Not_Nullable_Value_Throws_Wh ((IValitRule)null) .IsLessThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -46,7 +46,7 @@ public void Int64_IsLessThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Given( ((IValitRule)null) .IsLessThan((long?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -54,9 +54,9 @@ public void Int64_IsLessThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Given( [Theory] [InlineData(11, true)] [InlineData(10, false)] - [InlineData(9, false)] + [InlineData(9, false)] public void Int64_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Values(long value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -70,10 +70,10 @@ public void Int64_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Values(long [Theory] [InlineData((long) 11, true)] [InlineData((long) 10, false)] - [InlineData((long) 9, false)] - [InlineData(null, false)] + [InlineData((long) 9, false)] + [InlineData(null, false)] public void Int64_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(long? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -86,11 +86,11 @@ public void Int64_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Value_And_N [Theory] [InlineData(false, 11, true)] - [InlineData(false, 10, false)] - [InlineData(false, 9, false)] - [InlineData(true, 11, false)] + [InlineData(false, 10, false)] + [InlineData(false, 9, false)] + [InlineData(true, 11, false)] public void Int64_IsLessThan_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, long value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -102,14 +102,14 @@ public void Int64_IsLessThan_Returns_Proper_Results_For_Nullable_Value_And_Not_N } [Theory] - [InlineData(false, (long) 11, true)] - [InlineData(false, (long) 10, false)] + [InlineData(false, (long) 11, true)] + [InlineData(false, (long) 10, false)] [InlineData(false, (long) 9, false)] - [InlineData(false, null, false)] - [InlineData(true, (long) 11, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (long) 11, false)] + [InlineData(true, null, false)] public void Int64_IsLessThan_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, long? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -136,5 +136,5 @@ class Model } #endregion } - -} \ No newline at end of file + +} diff --git a/tests/Valit.Tests/Int64/Int64_IsNegative_Tests.cs b/tests/Valit.Tests/Int64/Int64_IsNegative_Tests.cs index 6aa0f9b..29f9a4d 100644 --- a/tests/Valit.Tests/Int64/Int64_IsNegative_Tests.cs +++ b/tests/Valit.Tests/Int64/Int64_IsNegative_Tests.cs @@ -5,14 +5,14 @@ namespace Valit.Tests.Int64 { public class Int64_IsNegative_Tests { - [Fact] + [Fact] public void Int64_IsNegative_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsNegative(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,14 +23,14 @@ public void Int64_IsNegative_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsNegative(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Fact] public void Int64_IsNegative_Succeeds_When_Given_Value_Is_Negative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NegativeValue, _=>_ @@ -43,7 +43,7 @@ public void Int64_IsNegative_Succeeds_When_Given_Value_Is_Negative() [Fact] public void Int64_IsNegative_Fails_When_Given_Value_Is_Zero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.ZeroValue, _=>_ @@ -56,7 +56,7 @@ public void Int64_IsNegative_Fails_When_Given_Value_Is_Zero() [Fact] public void Int64_IsNegative_Fails_When_Given_Value_Is_Positive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.PositiveValue, _=>_ @@ -69,7 +69,7 @@ public void Int64_IsNegative_Fails_When_Given_Value_Is_Positive() [Fact] public void Int64_IsNegative_Succeeds_When_Given_Value_Is_NullableNegative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableNegativeValue, _=>_ @@ -82,7 +82,7 @@ public void Int64_IsNegative_Succeeds_When_Given_Value_Is_NullableNegative() [Fact] public void Int64_IsNegative_Fails_When_Given_Value_Is_NullableZero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableZeroValue, _=>_ @@ -95,7 +95,7 @@ public void Int64_IsNegative_Fails_When_Given_Value_Is_NullableZero() [Fact] public void Int64_IsNegative_Fails_When_Given_Value_Is_NullablePositive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullablePositiveValue, _=>_ @@ -108,7 +108,7 @@ public void Int64_IsNegative_Fails_When_Given_Value_Is_NullablePositive() [Fact] public void Int64_IsNegative_Fails_When_Given_Value_Is_Null() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullValue, _=>_ @@ -137,6 +137,6 @@ class Model public long? NullableNegativeValue => -10; public long? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int64/Int64_IsNonZero_Tests.cs b/tests/Valit.Tests/Int64/Int64_IsNonZero_Tests.cs index f8ac481..0be772d 100644 --- a/tests/Valit.Tests/Int64/Int64_IsNonZero_Tests.cs +++ b/tests/Valit.Tests/Int64/Int64_IsNonZero_Tests.cs @@ -5,14 +5,14 @@ namespace Valit.Tests.Int64 { public class Int64_IsNonZero_Tests { - [Fact] + [Fact] public void Int64_IsNonZero_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsNonZero(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,16 +23,16 @@ public void Int64_IsNonZero_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsNonZero(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void Int64_IsNonZero_Returns_Proper_Results_For_Not_Nullable_Value(bool useZeroValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useZeroValue? m.ZeroValue : m.Value, _=>_ @@ -45,9 +45,9 @@ public void Int64_IsNonZero_Returns_Proper_Results_For_Not_Nullable_Value(bool u [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void Int64_IsNonZero_Returns_Proper_Results_For_Nullable_Value(bool useZeroValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useZeroValue? m.NullableZeroValue : m.NullableValue, _=>_ @@ -60,7 +60,7 @@ public void Int64_IsNonZero_Returns_Proper_Results_For_Nullable_Value(bool useZe [Fact] public void Int64_IsNonZero_Fails_For_Null_Value() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullValue, _=>_ @@ -89,4 +89,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int64/Int64_IsPositive_Tests.cs b/tests/Valit.Tests/Int64/Int64_IsPositive_Tests.cs index ab9dc80..7a9d268 100644 --- a/tests/Valit.Tests/Int64/Int64_IsPositive_Tests.cs +++ b/tests/Valit.Tests/Int64/Int64_IsPositive_Tests.cs @@ -5,14 +5,14 @@ namespace Valit.Tests.Int64 { public class Int64_IsPositive_Tests { - [Fact] + [Fact] public void Int64_IsPositive_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsPositive(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,14 +23,14 @@ public void Int64_IsPositive_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsPositive(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Fact] public void Int64_IsPositive_Succeeds_When_Given_Value_Is_Postive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.PositiveValue, _=>_ @@ -43,7 +43,7 @@ public void Int64_IsPositive_Succeeds_When_Given_Value_Is_Postive() [Fact] public void Int64_IsPositive_Fails_When_Given_Value_Is_Zero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.ZeroValue, _=>_ @@ -56,7 +56,7 @@ public void Int64_IsPositive_Fails_When_Given_Value_Is_Zero() [Fact] public void Int64_IsPositive_Fails_When_Given_Value_Is_Negative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NegativeValue, _=>_ @@ -69,7 +69,7 @@ public void Int64_IsPositive_Fails_When_Given_Value_Is_Negative() [Fact] public void Int64_IsPositive_Succeeds_When_Given_Value_Is_NullablePostive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullablePositiveValue, _=>_ @@ -82,7 +82,7 @@ public void Int64_IsPositive_Succeeds_When_Given_Value_Is_NullablePostive() [Fact] public void Int64_IsPositive_Fails_When_Given_Value_Is_NullableZero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableZeroValue, _=>_ @@ -95,7 +95,7 @@ public void Int64_IsPositive_Fails_When_Given_Value_Is_NullableZero() [Fact] public void Int64_IsPositive_Fails_When_Given_Value_Is_NullableNegative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableNegativeValue, _=>_ @@ -108,7 +108,7 @@ public void Int64_IsPositive_Fails_When_Given_Value_Is_NullableNegative() [Fact] public void Int64_IsPositive_Fails_When_Given_Value_Is_Null() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullValue, _=>_ @@ -137,6 +137,6 @@ class Model public long? NullableNegativeValue => -10; public long? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Int64/Int64_Required_Tests.cs b/tests/Valit.Tests/Int64/Int64_Required_Tests.cs index ebc7af1..81051a9 100644 --- a/tests/Valit.Tests/Int64/Int64_Required_Tests.cs +++ b/tests/Valit.Tests/Int64/Int64_Required_Tests.cs @@ -13,16 +13,16 @@ public void Int64_Required_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .Required(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void Int64_Required_Returns_Proper_Results_For_Nullable_Value(bool useNullValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -51,4 +51,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/MessageProvider/CustomMessagePrivider_Tests.cs b/tests/Valit.Tests/MessageProvider/CustomMessageProvider_Tests.cs similarity index 75% rename from tests/Valit.Tests/MessageProvider/CustomMessagePrivider_Tests.cs rename to tests/Valit.Tests/MessageProvider/CustomMessageProvider_Tests.cs index cda9b52..3ccd38d 100644 --- a/tests/Valit.Tests/MessageProvider/CustomMessagePrivider_Tests.cs +++ b/tests/Valit.Tests/MessageProvider/CustomMessageProvider_Tests.cs @@ -1,17 +1,17 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Xunit; using Shouldly; namespace Valit.Tests.MessageProvider { - public class CustomMessagePrivider_Tests + public class CustomMessageProvider_Tests { [Fact] - public void CustomMessagePrivider_Adds_Proper_Messages() + public void CustomMessageProvider_Adds_Proper_Messages() { var result = ValitRules .Create() - .WithMessageProvider(new CustomMessagePrivider()) + .WithMessageProvider(new CustomMessageProvider()) .Ensure(m => m.Value, _ => _ .MaxLength(10) .WithMessageKey(1) @@ -30,15 +30,22 @@ public void CustomMessagePrivider_Adds_Proper_Messages() result.ErrorMessages.ShouldContain("Three"); } - Model _model => new Model(); +#region ARRANGE + public CustomMessageProvider_Tests() + { + _model = new Model(); + } + + private readonly Model _model; class Model { public string Value => "This text has 28 characters!"; } +#endregion } - class CustomMessagePrivider : IValitMessageProvider + class CustomMessageProvider : IValitMessageProvider { private IDictionary _messages = new Dictionary @@ -55,4 +62,4 @@ public string GetByKey(int key) return string.Empty; } } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/MessageProvider/EmptyMessageProvider_Tests.cs b/tests/Valit.Tests/MessageProvider/EmptyMessageProvider_Tests.cs index ae6da73..bae60c3 100644 --- a/tests/Valit.Tests/MessageProvider/EmptyMessageProvider_Tests.cs +++ b/tests/Valit.Tests/MessageProvider/EmptyMessageProvider_Tests.cs @@ -1,4 +1,4 @@ -using Xunit; +using Xunit; using Shouldly; namespace Valit.Tests.MessageProvider @@ -28,4 +28,4 @@ class Model public string Value => "This text has 28 characters!"; } } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/NestedObject/Nested_Object_Collection_Validation_Tests.cs b/tests/Valit.Tests/NestedObject/Nested_Object_Collection_Validation_Tests.cs new file mode 100644 index 0000000..fdb77de --- /dev/null +++ b/tests/Valit.Tests/NestedObject/Nested_Object_Collection_Validation_Tests.cs @@ -0,0 +1,134 @@ +using System.Collections.Generic; +using System.Linq; +using Shouldly; +using Xunit; + +namespace Valit.Tests.NestedObject +{ + public class Nested_Object_Collection_Validation_Tests + { + [Fact] + public void EnsureFor_Throws_When_Null_ValitRulesProvider_Is_Given() + { + var exception = Record.Exception(() => { + ValitRules + .Create() + .EnsureFor(m => m.NestedObjectCollection, ((IValitRulesProvider)null)); + }); + + exception.ShouldBeOfType(typeof(ValitException)); + } + + [Fact] + public void Validation_With_Complete_Strategy_Fails_When_Invalid_Collection_Is_Given() + { + var rootObject = Model.GetInvalid(); + + var result = ValitRules + .Create() + .EnsureFor(m => m.NestedObjectCollection, new NestedModelRulesProvider()) + .For(rootObject) + .Validate(); + + Assert.False(result.Succeeded); + result.ErrorMessages.Count(m => m == "One").ShouldBe(1); + result.ErrorMessages.Count(m => m == "Two").ShouldBe(1); + result.ErrorMessages.Count(m => m == "Three").ShouldBe(2); + } + + [Fact] + public void Validation_With_FailFast_Strategy_Fails_When_Invalid_Collection_Is_Given() + { + var rootObject = Model.GetInvalid(); + + var result = ValitRules + .Create() + .WithStrategy(picker => picker.FailFast) + .EnsureFor(m => m.NestedObjectCollection, new NestedModelRulesProvider()) + .For(rootObject) + .Validate(); + + Assert.False(result.Succeeded); + result.ErrorMessages.Count().ShouldBe(1); + result.ErrorMessages.First().ShouldBe("Two"); + } + + [Fact] + public void Validation_With_Complete_Strategy_Succeeds_When_Valid_Collection_Is_Given() + { + var rootObject = Model.GetValid(); + + var result = ValitRules + .Create() + .EnsureFor(m => m.NestedObjectCollection, new NestedModelRulesProvider()) + .For(rootObject) + .Validate(); + + Assert.True(result.Succeeded); + } + + [Fact] + public void Validation_With_FailFast_Strategy_Succeeds_When_Valid_Collection_Is_Given() + { + var rootObject = Model.GetValid(); + + var result = ValitRules + .Create() + .WithStrategy(picker => picker.FailFast) + .EnsureFor(m => m.NestedObjectCollection, new NestedModelRulesProvider()) + .For(rootObject) + .Validate(); + + Assert.True(result.Succeeded); + } + +#region ARRANGE + class Model + { + public IEnumerable NestedObjectCollection { get; set; } + + public static Model GetInvalid() + => new Model + { + NestedObjectCollection = new List + { + new NestedModel { NumericValue = 20, StringValue = null }, + new NestedModel { NumericValue = 1, StringValue = "invali.email@" }, + } + }; + + public static Model GetValid() + => new Model + { + NestedObjectCollection = new List + { + new NestedModel { NumericValue = 20, StringValue = "valid.email@test.com" }, + new NestedModel { NumericValue = 30, StringValue = "another.valid.email@test.com" }, + } + }; + } + + class NestedModel + { + public ushort NumericValue { get; set;} + public string StringValue { get; set;} + } + + class NestedModelRulesProvider : IValitRulesProvider + { + public IEnumerable> GetRules() + => ValitRules + .Create() + .Ensure(m => m.NumericValue, _=>_ + .IsGreaterThan(10) + .WithMessage("One")) + .Ensure(m => m.StringValue, _=>_ + .Required() + .WithMessage("Two") + .Email() + .WithMessage("Three")) + .GetAllRules(); + } + } +#endregion +} diff --git a/tests/Valit.Tests/NestedObject/Nested_Object_Validation_Tests.cs b/tests/Valit.Tests/NestedObject/Nested_Object_Validation_Tests.cs new file mode 100644 index 0000000..6d2baa9 --- /dev/null +++ b/tests/Valit.Tests/NestedObject/Nested_Object_Validation_Tests.cs @@ -0,0 +1,115 @@ +using System.Collections.Generic; +using Shouldly; +using Xunit; + +namespace Valit.Tests.NestedObject +{ + public class Nested_Object_Validation_Tests + { + + [Fact] + public void Ensure_Throws_When_Null_ValitRulesProvider_Is_Given() + { + var exception = Record.Exception(() => { + ValitRules + .Create() + .Ensure(m => m.NestedObject, ((IValitRulesProvider)null)); + }); + + exception.ShouldBeOfType(typeof(ValitException)); + } + + [Fact] + public void Validation_Fails_When_Invalid_NestedObject_Is_Given() + { + var rootObject = Model.GetInvalid(); + + var result = ValitRules + .Create() + .Ensure(m => m.NestedObject, new NestedModelRulesProvider()) + .For(rootObject) + .Validate(); + + Assert.False(result.Succeeded); + } + + [Fact] + public void Validation_Returns_Proper_Messages_When_Invalid_NestedObject_Is_Given() + { + var rootObject = Model.GetInvalid(); + + var result = ValitRules + .Create() + .Ensure(m => m.NestedObject, new NestedModelRulesProvider()) + .For(rootObject) + .Validate(); + + result.ErrorMessages.ShouldNotContain("One"); + result.ErrorMessages.ShouldContain("Two"); + result.ErrorMessages.ShouldContain("Three"); + } + + [Fact] + public void Validation_Succeeds_When_Valid_NestedObject_Is_Given() + { + var rootObject = Model.GetValid(); + + var result = ValitRules + .Create() + .Ensure(m => m.NestedObject, new NestedModelRulesProvider()) + .For(rootObject) + .Validate(); + + Assert.True(result.Succeeded); + } + +#region ARRANGE + class Model + { + public NestedModel NestedObject { get; set; } + + public static Model GetInvalid() + => new Model + { + NestedObject = new NestedModel + { + NumericValue = 20, + StringValue = null + } + }; + + public static Model GetValid() + => new Model + { + NestedObject = new NestedModel + { + NumericValue = 20, + StringValue = "someemail@test.com" + } + }; + } + + class NestedModel + { + public ushort NumericValue { get; set;} + public string StringValue { get; set;} + } + + class NestedModelRulesProvider : IValitRulesProvider + { + public IEnumerable> GetRules() + => ValitRules + .Create() + .Ensure(m => m.NumericValue, _=>_ + .IsGreaterThan(10) + .WithMessage("One")) + .Ensure(m => m.StringValue, _=>_ + .Required() + .WithMessage("Two") + .Email() + .WithMessage("Three")) + .GetAllRules(); + } + } +#endregion +} diff --git a/tests/Valit.Tests/Property/Property_Required_Tests.cs b/tests/Valit.Tests/Property/Property_Required_Tests.cs index 8a1d8e1..2c3fe51 100644 --- a/tests/Valit.Tests/Property/Property_Required_Tests.cs +++ b/tests/Valit.Tests/Property/Property_Required_Tests.cs @@ -1,4 +1,4 @@ -using Shouldly; +using Shouldly; using Xunit; namespace Valit.Tests.Property diff --git a/tests/Valit.Tests/Property/Property_Tag_Tests.cs b/tests/Valit.Tests/Property/Property_Tag_Tests.cs index 1e29f2a..8707724 100644 --- a/tests/Valit.Tests/Property/Property_Tag_Tests.cs +++ b/tests/Valit.Tests/Property/Property_Tag_Tests.cs @@ -6,7 +6,7 @@ namespace Valit.Tests.Property { public class Property_Tag_Tests { - + [Fact] public void Property_Tag_Throws_When_Null_Rule_Is_Given() { @@ -90,11 +90,11 @@ public void ValitRules_GetUntaggedRules_Returns_Correct_Number_Of_Rules() [Theory] [InlineData(new [] { "Tag1" }, true)] - [InlineData(new [] { "Tag2" }, true)] - [InlineData(new [] { "Tag1", "Tag2" }, true)] - [InlineData(new [] { "Tag1", "Tag3" }, false)] - [InlineData(new [] { "Tag2", "Tag3" }, false)] - [InlineData(new [] { "Tag3" }, false)] + [InlineData(new [] { "Tag2" }, true)] + [InlineData(new [] { "Tag1", "Tag2" }, true)] + [InlineData(new [] { "Tag1", "Tag3" }, false)] + [InlineData(new [] { "Tag2", "Tag3" }, false)] + [InlineData(new [] { "Tag3" }, false)] public void ValitRules_Validate_With_Params_Should_Return_Proper_Result_Based_On_Given_Tags_Set(string[] tags, bool expected) { var result = ValitRules @@ -116,11 +116,11 @@ public void ValitRules_Validate_With_Params_Should_Return_Proper_Result_Based_On [Theory] [InlineData(new [] { "Tag1" }, true)] - [InlineData(new [] { "Tag2" }, true)] - [InlineData(new [] { "Tag1", "Tag2" }, true)] - [InlineData(new [] { "Tag1", "Tag3" }, false)] - [InlineData(new [] { "Tag2", "Tag3" }, false)] - [InlineData(new [] { "Tag3" }, false)] + [InlineData(new [] { "Tag2" }, true)] + [InlineData(new [] { "Tag1", "Tag2" }, true)] + [InlineData(new [] { "Tag1", "Tag3" }, false)] + [InlineData(new [] { "Tag2", "Tag3" }, false)] + [InlineData(new [] { "Tag3" }, false)] public void ValitRules_Validate_With_Predicate_Should_Return_Proper_Result_Based_On_Given_Tags_Set(string[] tags, bool expected) { var result = ValitRules @@ -157,7 +157,7 @@ public void ValitRules_Create_Should_Properly_Add_Given_Rules() var newRules = ValitRules .Create(rules) - .GetAllRules(); + .GetAllRules(); newRules.Count().ShouldBe(3); } @@ -170,7 +170,7 @@ class Model public string Value1 => "Text"; public string Value2 => "Text"; public string NullValue => null; - + } } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Property/Property_When_Tests.cs b/tests/Valit.Tests/Property/Property_When_Tests.cs index f1666bc..847fce2 100644 --- a/tests/Valit.Tests/Property/Property_When_Tests.cs +++ b/tests/Valit.Tests/Property/Property_When_Tests.cs @@ -1,4 +1,4 @@ -using Shouldly; +using Shouldly; using Xunit; namespace Valit.Tests.Property diff --git a/tests/Valit.Tests/Property/Property_WithErrorCode_Tests.cs b/tests/Valit.Tests/Property/Property_WithErrorCode_Tests.cs index 572d2f7..3781f4a 100644 --- a/tests/Valit.Tests/Property/Property_WithErrorCode_Tests.cs +++ b/tests/Valit.Tests/Property/Property_WithErrorCode_Tests.cs @@ -1,4 +1,4 @@ -using Shouldly; +using Shouldly; using System.Linq; using Xunit; diff --git a/tests/Valit.Tests/Property/Property_WithMessage_Tests.cs b/tests/Valit.Tests/Property/Property_WithMessage_Tests.cs index b3ca3a3..34160de 100644 --- a/tests/Valit.Tests/Property/Property_WithMessage_Tests.cs +++ b/tests/Valit.Tests/Property/Property_WithMessage_Tests.cs @@ -1,4 +1,5 @@ -using Shouldly; +using System; +using Shouldly; using System.Linq; using Xunit; @@ -44,6 +45,25 @@ public void Property_WithMessage_Is_Not_Added_For_Valid_Check_If_When_Is_Satisfi result.ErrorMessages.ShouldNotContain("Arrrgh"); } + [Fact] + public void Property_WithVariableMessage_Updates_Correctly() + { + string msg = "Message 1"; + Func msgFunc = () => msg; + var rule = ValitRules.Create() + .Ensure(m => m.NullRefProperty, _ => _ + .Required() + .WithMessage(msgFunc)) + .For(_model); + var result = rule.Validate(); + + result.ErrorMessages.ShouldContain(msg); + + msg = "New message"; + result = rule.Validate(); + result.ErrorMessages.ShouldContain(msg); + } + [Fact] public void Property_WithMessage_Is_Not_Added_For_Valid_Check_If_When_Is_Not_Satisfied() { diff --git a/tests/Valit.Tests/SByte/SByte_IsEqual_To_Tests.cs b/tests/Valit.Tests/SByte/SByte_IsEqual_To_Tests.cs index e2c00e3..2b3283a 100644 --- a/tests/Valit.Tests/SByte/SByte_IsEqual_To_Tests.cs +++ b/tests/Valit.Tests/SByte/SByte_IsEqual_To_Tests.cs @@ -12,7 +12,7 @@ public void SByte_IsEqualTo_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Giv ((IValitRule)null) .IsEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void SByte_IsEqualTo_For_Not_Nullable_Value_And_Nullable_Value_Throws_Whe ((IValitRule)null) .IsEqualTo((sbyte?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void SByte_IsEqualTo_For_Nullable_Value_And_Not_Nullable_Value_Throws_Whe ((IValitRule)null) .IsEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void SByte_IsEqualTo_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsEqualTo((sbyte?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void SByte_IsEqualTo_For_Nullable_Values_Throws_When_Null_Rule_Is_Given() [Theory] [InlineData(10, true)] [InlineData(9, false)] - [InlineData(11, false)] + [InlineData(11, false)] public void SByte_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(sbyte value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void SByte_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(sbyte [Theory] [InlineData((sbyte) 10, true)] [InlineData((sbyte) 9, false)] - [InlineData((sbyte) 11, false)] - [InlineData(null, false)] + [InlineData((sbyte) 11, false)] + [InlineData(null, false)] public void SByte_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(sbyte? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void SByte_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nu [Theory] [InlineData(false, 10, true)] - [InlineData(false, 9, false)] - [InlineData(false, 11, false)] - [InlineData(true, 10, false)] + [InlineData(false, 9, false)] + [InlineData(false, 11, false)] + [InlineData(true, 10, false)] public void SByte_IsEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, sbyte value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void SByte_IsEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nu } [Theory] - [InlineData(false, (sbyte) 10, true)] - [InlineData(false, (sbyte) 9, false)] + [InlineData(false, (sbyte) 10, true)] + [InlineData(false, (sbyte) 9, false)] [InlineData(false, (sbyte) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (sbyte) 10, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (sbyte) 10, false)] + [InlineData(true, null, false)] public void SByte_IsEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, sbyte? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -133,6 +133,6 @@ class Model public sbyte? NullableValue => 10; public sbyte? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/SByte/SByte_IsGreaterThanOrEqualTo_Tests.cs b/tests/Valit.Tests/SByte/SByte_IsGreaterThanOrEqualTo_Tests.cs index 91edb65..d7cd4ff 100644 --- a/tests/Valit.Tests/SByte/SByte_IsGreaterThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/SByte/SByte_IsGreaterThanOrEqualTo_Tests.cs @@ -12,7 +12,7 @@ public void SByte_IsGreaterThanOrEqualTo_For_Not_Nullable_Values_Throws_When_Nul ((IValitRule)null) .IsGreaterThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void SByte_IsGreaterThanOrEqualTo_For_Not_Nullable_Value_And_Nullable_Val ((IValitRule)null) .IsGreaterThanOrEqualTo((sbyte?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void SByte_IsGreaterThanOrEqualTo_For_Nullable_Value_And_Not_Nullable_Val ((IValitRule)null) .IsGreaterThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void SByte_IsGreaterThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Ru ((IValitRule)null) .IsGreaterThanOrEqualTo((sbyte?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void SByte_IsGreaterThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Ru [Theory] [InlineData(9, true)] [InlineData(10, true)] - [InlineData(11, false)] + [InlineData(11, false)] public void SByte_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(sbyte value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void SByte_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable [Theory] [InlineData((sbyte) 9, true)] [InlineData((sbyte) 10, true)] - [InlineData((sbyte) 11, false)] - [InlineData(null, false)] + [InlineData((sbyte) 11, false)] + [InlineData(null, false)] public void SByte_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(sbyte? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void SByte_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable [Theory] [InlineData(false, 9, true)] - [InlineData(false, 10, true)] - [InlineData(false, 11, false)] - [InlineData(true, 9, false)] + [InlineData(false, 10, true)] + [InlineData(false, 11, false)] + [InlineData(true, 9, false)] public void SByte_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, sbyte value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void SByte_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Val } [Theory] - [InlineData(false, (sbyte) 9, true)] - [InlineData(false, (sbyte) 10, true)] + [InlineData(false, (sbyte) 9, true)] + [InlineData(false, (sbyte) 10, true)] [InlineData(false, (sbyte) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (sbyte) 9, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (sbyte) 9, false)] + [InlineData(true, null, false)] public void SByte_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, sbyte? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -135,4 +135,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/SByte/SByte_IsGreaterThan_Tests.cs b/tests/Valit.Tests/SByte/SByte_IsGreaterThan_Tests.cs index 0394937..be58f68 100644 --- a/tests/Valit.Tests/SByte/SByte_IsGreaterThan_Tests.cs +++ b/tests/Valit.Tests/SByte/SByte_IsGreaterThan_Tests.cs @@ -13,7 +13,7 @@ public void SByte_IsGreaterThan_For_Not_Nullable_Values_Throws_When_Null_Rule_Is ((IValitRule)null) .IsGreaterThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -24,7 +24,7 @@ public void SByte_IsGreaterThan_For_Not_Nullable_Value_And_Nullable_Value_Throws ((IValitRule)null) .IsGreaterThan((sbyte?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -35,7 +35,7 @@ public void SByte_IsGreaterThan_For_Nullable_Value_And_Not_Nullable_Value_Throws ((IValitRule)null) .IsGreaterThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -46,7 +46,7 @@ public void SByte_IsGreaterThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Giv ((IValitRule)null) .IsGreaterThan((sbyte?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -54,9 +54,9 @@ public void SByte_IsGreaterThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Giv [Theory] [InlineData(9, true)] [InlineData(10, false)] - [InlineData(11, false)] + [InlineData(11, false)] public void SByte_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Values(sbyte value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -70,10 +70,10 @@ public void SByte_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Values(s [Theory] [InlineData((sbyte) 9, true)] [InlineData((sbyte) 10, false)] - [InlineData((sbyte) 11, false)] - [InlineData(null, false)] + [InlineData((sbyte) 11, false)] + [InlineData(null, false)] public void SByte_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(sbyte? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -86,11 +86,11 @@ public void SByte_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Value_An [Theory] [InlineData(false, 9, true)] - [InlineData(false, 10, false)] - [InlineData(false, 11, false)] - [InlineData(true, 9, false)] + [InlineData(false, 10, false)] + [InlineData(false, 11, false)] + [InlineData(true, 9, false)] public void SByte_IsGreaterThan_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, sbyte value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -102,14 +102,14 @@ public void SByte_IsGreaterThan_Returns_Proper_Results_For_Nullable_Value_And_No } [Theory] - [InlineData(false, (sbyte) 9, true)] - [InlineData(false, (sbyte) 10, false)] + [InlineData(false, (sbyte) 9, true)] + [InlineData(false, (sbyte) 10, false)] [InlineData(false, (sbyte) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (sbyte) 9, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (sbyte) 9, false)] + [InlineData(true, null, false)] public void SByte_IsGreaterThan_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, sbyte? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -136,4 +136,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/SByte/SByte_IsLessThanOrEqualTo_Tests.cs b/tests/Valit.Tests/SByte/SByte_IsLessThanOrEqualTo_Tests.cs index 0f7f882..bc4f5d0 100644 --- a/tests/Valit.Tests/SByte/SByte_IsLessThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/SByte/SByte_IsLessThanOrEqualTo_Tests.cs @@ -12,7 +12,7 @@ public void SByte_IsLessThanOrEqualTo_For_Not_Nullable_Values_Throws_When_Null_R ((IValitRule)null) .IsLessThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void SByte_IsLessThanOrEqualTo_For_Not_Nullable_Value_And_Nullable_Value_ ((IValitRule)null) .IsLessThanOrEqualTo((sbyte?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void SByte_IsLessThanOrEqualTo_For_Nullable_Value_And_Not_Nullable_Value_ ((IValitRule)null) .IsLessThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void SByte_IsLessThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Rule_ ((IValitRule)null) .IsLessThanOrEqualTo((sbyte?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void SByte_IsLessThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Rule_ [Theory] [InlineData(11, true)] [InlineData(10, true)] - [InlineData(9, false)] + [InlineData(9, false)] public void SByte_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(sbyte value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void SByte_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Va [Theory] [InlineData((sbyte) 11, true)] [InlineData((sbyte) 10, true)] - [InlineData((sbyte) 9, false)] - [InlineData(null, false)] + [InlineData((sbyte) 9, false)] + [InlineData(null, false)] public void SByte_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(sbyte? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void SByte_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Va [Theory] [InlineData(false, 11, true)] - [InlineData(false, 10, true)] - [InlineData(false, 9, false)] - [InlineData(true, 11, false)] + [InlineData(false, 10, true)] + [InlineData(false, 9, false)] + [InlineData(true, 11, false)] public void SByte_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, sbyte value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void SByte_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_ } [Theory] - [InlineData(false, (sbyte) 11, true)] - [InlineData(false, (sbyte) 10, true)] + [InlineData(false, (sbyte) 11, true)] + [InlineData(false, (sbyte) 10, true)] [InlineData(false, (sbyte) 9, false)] - [InlineData(false, null, false)] - [InlineData(true, (sbyte) 11, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (sbyte) 11, false)] + [InlineData(true, null, false)] public void SByte_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, sbyte? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -133,6 +133,6 @@ class Model public sbyte? NullableValue => 10; public sbyte? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/SByte/SByte_IsLessThan_Tests.cs b/tests/Valit.Tests/SByte/SByte_IsLessThan_Tests.cs index 47f6c21..8828f30 100644 --- a/tests/Valit.Tests/SByte/SByte_IsLessThan_Tests.cs +++ b/tests/Valit.Tests/SByte/SByte_IsLessThan_Tests.cs @@ -5,7 +5,7 @@ namespace Valit.Tests.SByte { public class SByte_IsLessThan_Tests { - + [Fact] public void SByte_IsLessThan_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Given() { @@ -13,7 +13,7 @@ public void SByte_IsLessThan_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Gi ((IValitRule)null) .IsLessThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -24,7 +24,7 @@ public void SByte_IsLessThan_For_Not_Nullable_Value_And_Nullable_Value_Throws_Wh ((IValitRule)null) .IsLessThan((sbyte?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -35,7 +35,7 @@ public void SByte_IsLessThan_For_Nullable_Value_And_Not_Nullable_Value_Throws_Wh ((IValitRule)null) .IsLessThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -46,7 +46,7 @@ public void SByte_IsLessThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Given( ((IValitRule)null) .IsLessThan((sbyte?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -54,9 +54,9 @@ public void SByte_IsLessThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Given( [Theory] [InlineData(11, true)] [InlineData(10, false)] - [InlineData(9, false)] + [InlineData(9, false)] public void SByte_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Values(sbyte value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -70,10 +70,10 @@ public void SByte_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Values(sbyt [Theory] [InlineData((sbyte) 11, true)] [InlineData((sbyte) 10, false)] - [InlineData((sbyte) 9, false)] - [InlineData(null, false)] + [InlineData((sbyte) 9, false)] + [InlineData(null, false)] public void SByte_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(sbyte? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -86,11 +86,11 @@ public void SByte_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Value_And_N [Theory] [InlineData(false, 11, true)] - [InlineData(false, 10, false)] - [InlineData(false, 9, false)] - [InlineData(true, 11, false)] + [InlineData(false, 10, false)] + [InlineData(false, 9, false)] + [InlineData(true, 11, false)] public void SByte_IsLessThan_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, sbyte value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -102,14 +102,14 @@ public void SByte_IsLessThan_Returns_Proper_Results_For_Nullable_Value_And_Not_N } [Theory] - [InlineData(false, (sbyte) 11, true)] - [InlineData(false, (sbyte) 10, false)] + [InlineData(false, (sbyte) 11, true)] + [InlineData(false, (sbyte) 10, false)] [InlineData(false, (sbyte) 9, false)] - [InlineData(false, null, false)] - [InlineData(true, (sbyte) 11, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (sbyte) 11, false)] + [InlineData(true, null, false)] public void SByte_IsLessThan_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, sbyte? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -136,5 +136,5 @@ class Model } #endregion } - -} \ No newline at end of file + +} diff --git a/tests/Valit.Tests/SByte/SByte_IsNegative_Tests.cs b/tests/Valit.Tests/SByte/SByte_IsNegative_Tests.cs index 161d683..8ee709a 100644 --- a/tests/Valit.Tests/SByte/SByte_IsNegative_Tests.cs +++ b/tests/Valit.Tests/SByte/SByte_IsNegative_Tests.cs @@ -5,14 +5,14 @@ namespace Valit.Tests.SByte { public class SByte_IsNegative_Tests { - [Fact] + [Fact] public void SByte_IsNegative_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsNegative(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,14 +23,14 @@ public void SByte_IsNegative_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsNegative(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Fact] public void SByte_IsNegative_Succeeds_When_Given_Value_Is_Negative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NegativeValue, _=>_ @@ -43,7 +43,7 @@ public void SByte_IsNegative_Succeeds_When_Given_Value_Is_Negative() [Fact] public void SByte_IsNegative_Fails_When_Given_Value_Is_Zero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.ZeroValue, _=>_ @@ -56,7 +56,7 @@ public void SByte_IsNegative_Fails_When_Given_Value_Is_Zero() [Fact] public void SByte_IsNegative_Fails_When_Given_Value_Is_Positive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.PositiveValue, _=>_ @@ -69,7 +69,7 @@ public void SByte_IsNegative_Fails_When_Given_Value_Is_Positive() [Fact] public void SByte_IsNegative_Succeeds_When_Given_Value_Is_NullableNegative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableNegativeValue, _=>_ @@ -82,7 +82,7 @@ public void SByte_IsNegative_Succeeds_When_Given_Value_Is_NullableNegative() [Fact] public void SByte_IsNegative_Fails_When_Given_Value_Is_NullableZero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableZeroValue, _=>_ @@ -95,7 +95,7 @@ public void SByte_IsNegative_Fails_When_Given_Value_Is_NullableZero() [Fact] public void SByte_IsNegative_Fails_When_Given_Value_Is_NullablePositive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullablePositiveValue, _=>_ @@ -108,7 +108,7 @@ public void SByte_IsNegative_Fails_When_Given_Value_Is_NullablePositive() [Fact] public void SByte_IsNegative_Fails_When_Given_Value_Is_Null() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullValue, _=>_ @@ -137,6 +137,6 @@ class Model public sbyte? NullableNegativeValue => -10; public sbyte? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/SByte/SByte_IsNonZero_Tests.cs b/tests/Valit.Tests/SByte/SByte_IsNonZero_Tests.cs index 8ab50d5..fc2c4cf 100644 --- a/tests/Valit.Tests/SByte/SByte_IsNonZero_Tests.cs +++ b/tests/Valit.Tests/SByte/SByte_IsNonZero_Tests.cs @@ -5,14 +5,14 @@ namespace Valit.Tests.SByte { public class SByte_IsNonZero_Tests { - [Fact] + [Fact] public void SByte_IsNonZero_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsNonZero(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,16 +23,16 @@ public void SByte_IsNonZero_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsNonZero(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void SByte_IsNonZero_Returns_Proper_Results_For_Not_Nullable_Value(bool useZeroValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useZeroValue? m.ZeroValue : m.Value, _=>_ @@ -45,9 +45,9 @@ public void SByte_IsNonZero_Returns_Proper_Results_For_Not_Nullable_Value(bool u [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void SByte_IsNonZero_Returns_Proper_Results_For_Nullable_Value(bool useZeroValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useZeroValue? m.NullableZeroValue : m.NullableValue, _=>_ @@ -60,7 +60,7 @@ public void SByte_IsNonZero_Returns_Proper_Results_For_Nullable_Value(bool useZe [Fact] public void SByte_IsNonZero_Fails_For_Null_Value() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullValue, _=>_ @@ -89,4 +89,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/SByte/SByte_IsPositive_Tests.cs b/tests/Valit.Tests/SByte/SByte_IsPositive_Tests.cs index f62734b..9439b6f 100644 --- a/tests/Valit.Tests/SByte/SByte_IsPositive_Tests.cs +++ b/tests/Valit.Tests/SByte/SByte_IsPositive_Tests.cs @@ -5,14 +5,14 @@ namespace Valit.Tests.SByte { public class SByte_IsPositive_Tests { - [Fact] + [Fact] public void SByte_IsPositive_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsPositive(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,14 +23,14 @@ public void SByte_IsPositive_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsPositive(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Fact] public void SByte_IsPositive_Succeeds_When_Given_Value_Is_Postive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.PositiveValue, _=>_ @@ -43,7 +43,7 @@ public void SByte_IsPositive_Succeeds_When_Given_Value_Is_Postive() [Fact] public void SByte_IsPositive_Fails_When_Given_Value_Is_Zero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.ZeroValue, _=>_ @@ -56,7 +56,7 @@ public void SByte_IsPositive_Fails_When_Given_Value_Is_Zero() [Fact] public void SByte_IsPositive_Fails_When_Given_Value_Is_Negative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NegativeValue, _=>_ @@ -69,7 +69,7 @@ public void SByte_IsPositive_Fails_When_Given_Value_Is_Negative() [Fact] public void SByte_IsPositive_Succeeds_When_Given_Value_Is_NullablePostive() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullablePositiveValue, _=>_ @@ -82,7 +82,7 @@ public void SByte_IsPositive_Succeeds_When_Given_Value_Is_NullablePostive() [Fact] public void SByte_IsPositive_Fails_When_Given_Value_Is_NullableZero() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableZeroValue, _=>_ @@ -95,7 +95,7 @@ public void SByte_IsPositive_Fails_When_Given_Value_Is_NullableZero() [Fact] public void SByte_IsPositive_Fails_When_Given_Value_Is_NullableNegative() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullableNegativeValue, _=>_ @@ -108,7 +108,7 @@ public void SByte_IsPositive_Fails_When_Given_Value_Is_NullableNegative() [Fact] public void SByte_IsPositive_Fails_When_Given_Value_Is_Null() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullValue, _=>_ @@ -137,6 +137,6 @@ class Model public sbyte? NullableNegativeValue => -10; public sbyte? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/SByte/SByte_Required_Tests.cs b/tests/Valit.Tests/SByte/SByte_Required_Tests.cs index a0cbbe9..c374e56 100644 --- a/tests/Valit.Tests/SByte/SByte_Required_Tests.cs +++ b/tests/Valit.Tests/SByte/SByte_Required_Tests.cs @@ -13,16 +13,16 @@ public void SByte_Required_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .Required(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void SByte_Required_Returns_Proper_Results_For_Nullable_Value(bool useNullValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -51,4 +51,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Strategies/Complete.cs b/tests/Valit.Tests/Strategies/Complete.cs index 53b31d3..b2fad76 100644 --- a/tests/Valit.Tests/Strategies/Complete.cs +++ b/tests/Valit.Tests/Strategies/Complete.cs @@ -1,4 +1,4 @@ -using Shouldly; +using Shouldly; using System; using System.Collections.Generic; using System.Linq; @@ -9,14 +9,6 @@ namespace Valit.Tests.Strategies { public class Complete { - const string M1 = "Our framework doesn't support future born babies"; - const string M2 = "Name is required"; - const string M3 = "Name shorter than 3 are not supported"; - const string M4 = "Lastname is required"; - const string M5 = "Lastname shorter than 3 are not supported"; - const string M6 = "Email is required"; - const string M7 = "Invalid email"; - [Fact] public void Complete_Strategy_Checks_All_Ensure() { @@ -44,7 +36,7 @@ public void Complete_Strategy_Checks_All_Ensure() .Validate(); result.Succeeded.ShouldBe(false); - result.ErrorMessages.Count().ShouldBe(5); + result.ErrorMessages.Count().ShouldBe(6); result.ErrorMessages.ShouldContain(M1); result.ErrorMessages.ShouldContain(M3); result.ErrorMessages.ShouldContain(M4); @@ -52,6 +44,16 @@ public void Complete_Strategy_Checks_All_Ensure() result.ErrorMessages.ShouldContain(M7); } +#region ARRANGE + + const string M1 = "Our framework doesn't support future born babies"; + const string M2 = "Name is required"; + const string M3 = "Name shorter than 3 are not supported"; + const string M4 = "Lastname is required"; + const string M5 = "Lastname shorter than 3 are not supported"; + const string M6 = "Email is required"; + const string M7 = "Invalid email"; + Model _model => new Model(); class Model @@ -61,5 +63,6 @@ class Model public string LastName => null; public string Email => "a@a"; } +#endregion } } diff --git a/tests/Valit.Tests/Strategies/FailFast.cs b/tests/Valit.Tests/Strategies/FailFast.cs index 108ee56..35d13bb 100644 --- a/tests/Valit.Tests/Strategies/FailFast.cs +++ b/tests/Valit.Tests/Strategies/FailFast.cs @@ -1,4 +1,4 @@ -using Shouldly; +using Shouldly; using System; using System.Collections.Generic; using System.Linq; @@ -9,15 +9,6 @@ namespace Valit.Tests.Strategies { public class FailFast { - const string M1 = "Our framework doesn't support future born babies"; - const string M2 = "Name is required"; - const string M3 = "Name shorter than 3 are not supported"; - const string M4 = "Lastname is required"; - const string M5 = "Lastname shorter than 3 are not supported"; - const string M6 = "Email is required"; - const string M7 = "Invalid email"; - const string M8 = "Old people are not supported"; - [Fact] public void FailFast_Strategy_Checks_Until_First_Error() { @@ -77,9 +68,20 @@ public void FailFast_Strategy_Checks_Until_First_Error_While_Error_Is_Not_First( result.Succeeded.ShouldBe(false); result.ErrorMessages.Count().ShouldBe(1); - result.ErrorMessages.ShouldContain(M3); + result.ErrorMessages.ShouldContain(M2); } +#region ARRANGE + + const string M1 = "Our framework doesn't support future born babies"; + const string M2 = "Name is required"; + const string M3 = "Name shorter than 3 are not supported"; + const string M4 = "Lastname is required"; + const string M5 = "Lastname shorter than 3 are not supported"; + const string M6 = "Email is required"; + const string M7 = "Invalid email"; + const string M8 = "Old people are not supported"; + Model _model => new Model(); class Model @@ -89,5 +91,6 @@ class Model public string LastName => null; public string Email => "a@a"; } +#endregion } } diff --git a/tests/Valit.Tests/String/String_Email_Tests.cs b/tests/Valit.Tests/String/String_Email_Tests.cs index d04eb18..c87290f 100644 --- a/tests/Valit.Tests/String/String_Email_Tests.cs +++ b/tests/Valit.Tests/String/String_Email_Tests.cs @@ -1,4 +1,4 @@ -using Xunit; +using Xunit; using Shouldly; namespace Valit.Tests.String diff --git a/tests/Valit.Tests/String/String_IsEqualTo_Tests.cs b/tests/Valit.Tests/String/String_IsEqualTo_Tests.cs index 7a27e89..c0d644e 100644 --- a/tests/Valit.Tests/String/String_IsEqualTo_Tests.cs +++ b/tests/Valit.Tests/String/String_IsEqualTo_Tests.cs @@ -1,4 +1,4 @@ -using Xunit; +using Xunit; using Shouldly; namespace Valit.Tests.String @@ -67,6 +67,18 @@ public void String_IsEqualTo_Returns_Proper_Result_For_Left_Null_Value(string va result.Succeeded.ShouldBe(expected); } + [Fact] + public void String_IsEqualTo_Another_Property_Returns_Proper_Result() + { + IValitResult result = ValitRules + .Create() + .Ensure(s => s.Value, (_, m) => _.IsEqualTo(m.Value)) + .For(_model) + .Validate(); + + result.Succeeded.ShouldBe(true); + } + #region ARRANGE public String_IsEqualTo_Tests() { diff --git a/tests/Valit.Tests/String/String_Matches_Tests.cs b/tests/Valit.Tests/String/String_Matches_Tests.cs index 27ec794..e44ae3d 100644 --- a/tests/Valit.Tests/String/String_Matches_Tests.cs +++ b/tests/Valit.Tests/String/String_Matches_Tests.cs @@ -1,4 +1,4 @@ -using Xunit; +using Xunit; using Shouldly; namespace Valit.Tests.String diff --git a/tests/Valit.Tests/String/String_MaxLenght_Tests.cs b/tests/Valit.Tests/String/String_MaxLenght_Tests.cs index 92d0312..51fc93a 100644 --- a/tests/Valit.Tests/String/String_MaxLenght_Tests.cs +++ b/tests/Valit.Tests/String/String_MaxLenght_Tests.cs @@ -1,4 +1,4 @@ -using Xunit; +using Xunit; using Shouldly; namespace Valit.Tests.String diff --git a/tests/Valit.Tests/String/String_MinLenght_Tests.cs b/tests/Valit.Tests/String/String_MinLenght_Tests.cs index a59b0aa..745cdd7 100644 --- a/tests/Valit.Tests/String/String_MinLenght_Tests.cs +++ b/tests/Valit.Tests/String/String_MinLenght_Tests.cs @@ -1,4 +1,4 @@ -using Xunit; +using Xunit; using Shouldly; namespace Valit.Tests.String diff --git a/tests/Valit.Tests/String/String_Required_Tests.cs b/tests/Valit.Tests/String/String_Required_Tests.cs new file mode 100644 index 0000000..5941c12 --- /dev/null +++ b/tests/Valit.Tests/String/String_Required_Tests.cs @@ -0,0 +1,76 @@ +using Shouldly; +using Xunit; + +namespace Valit.Tests.String +{ + public class String_Required_Tests + { + + [Fact] + public void String_Required_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() + { + var exception = Record.Exception(() => { + ((IValitRule)null) + .Required(); + }); + + exception.ShouldBeOfType(typeof(ValitException)); + } + + + [Fact] + public void String_Required_Fails_For_Null_Value() + { + IValitResult result = ValitRules + .Create() + .Ensure(m => m.NullValue, _=>_ + .Required()) + .For(_model) + .Validate(); + + Assert.False(result.Succeeded); + } + + [Fact] + public void String_Required_Fails_For_Empty_Value() + { + IValitResult result = ValitRules + .Create() + .Ensure(m => m.EmptyValue, _=>_ + .Required()) + .For(_model) + .Validate(); + + Assert.False(result.Succeeded); + } + + [Fact] + public void String_Required_Succeeds_For_Not_Empty_Value() + { + IValitResult result = ValitRules + .Create() + .Ensure(m => m.Value, _=>_ + .Required()) + .For(_model) + .Validate(); + + Assert.True(result.Succeeded); + } + +#region ARRANGE + public String_Required_Tests() + { + _model = new Model(); + } + + private readonly Model _model; + + class Model + { + public string EmptyValue => string.Empty; + public string Value => "text"; + public string NullValue => null; + } +#endregion + } +} diff --git a/tests/Valit.Tests/TimeSpan_/TimeSpan_IsEqualTo_Tests.cs b/tests/Valit.Tests/TimeSpan_/TimeSpan_IsEqualTo_Tests.cs index 7dbb071..524ecb0 100644 --- a/tests/Valit.Tests/TimeSpan_/TimeSpan_IsEqualTo_Tests.cs +++ b/tests/Valit.Tests/TimeSpan_/TimeSpan_IsEqualTo_Tests.cs @@ -1,4 +1,4 @@ -using System; +using System; using Shouldly; using Xunit; diff --git a/tests/Valit.Tests/TimeSpan_/TimeSpan_IsGreaterThanOrEqualTo_Tests.cs b/tests/Valit.Tests/TimeSpan_/TimeSpan_IsGreaterThanOrEqualTo_Tests.cs index 1600fdb..eb25c63 100644 --- a/tests/Valit.Tests/TimeSpan_/TimeSpan_IsGreaterThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/TimeSpan_/TimeSpan_IsGreaterThanOrEqualTo_Tests.cs @@ -1,4 +1,4 @@ -using System; +using System; using Shouldly; using Xunit; diff --git a/tests/Valit.Tests/TimeSpan_/TimeSpan_IsGreaterThan_Tests.cs b/tests/Valit.Tests/TimeSpan_/TimeSpan_IsGreaterThan_Tests.cs index 10b938d..80605a0 100644 --- a/tests/Valit.Tests/TimeSpan_/TimeSpan_IsGreaterThan_Tests.cs +++ b/tests/Valit.Tests/TimeSpan_/TimeSpan_IsGreaterThan_Tests.cs @@ -1,4 +1,4 @@ -using System; +using System; using Shouldly; using Xunit; diff --git a/tests/Valit.Tests/TimeSpan_/TimeSpan_IsLessThanOrEqualTo_Tests.cs b/tests/Valit.Tests/TimeSpan_/TimeSpan_IsLessThanOrEqualTo_Tests.cs index aa10fec..165450e 100644 --- a/tests/Valit.Tests/TimeSpan_/TimeSpan_IsLessThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/TimeSpan_/TimeSpan_IsLessThanOrEqualTo_Tests.cs @@ -1,4 +1,4 @@ -using System; +using System; using Shouldly; using Xunit; diff --git a/tests/Valit.Tests/TimeSpan_/TimeSpan_IsLessThan_Tests.cs b/tests/Valit.Tests/TimeSpan_/TimeSpan_IsLessThan_Tests.cs index 4541434..026b315 100644 --- a/tests/Valit.Tests/TimeSpan_/TimeSpan_IsLessThan_Tests.cs +++ b/tests/Valit.Tests/TimeSpan_/TimeSpan_IsLessThan_Tests.cs @@ -1,4 +1,4 @@ -using System; +using System; using Shouldly; using Xunit; diff --git a/tests/Valit.Tests/TimeSpan_/TimeSpan_IsNonZero_Tests.cs b/tests/Valit.Tests/TimeSpan_/TimeSpan_IsNonZero_Tests.cs index 806407d..833a23e 100644 --- a/tests/Valit.Tests/TimeSpan_/TimeSpan_IsNonZero_Tests.cs +++ b/tests/Valit.Tests/TimeSpan_/TimeSpan_IsNonZero_Tests.cs @@ -1,4 +1,4 @@ -using System; +using System; using Shouldly; using Xunit; diff --git a/tests/Valit.Tests/TimeSpan_/TimeSpan_Required_Tests.cs b/tests/Valit.Tests/TimeSpan_/TimeSpan_Required_Tests.cs index 2b27504..4080dc7 100644 --- a/tests/Valit.Tests/TimeSpan_/TimeSpan_Required_Tests.cs +++ b/tests/Valit.Tests/TimeSpan_/TimeSpan_Required_Tests.cs @@ -1,4 +1,4 @@ -using System; +using System; using Shouldly; using Xunit; diff --git a/tests/Valit.Tests/UInt16/UInt16_IsEqual_To_Tests.cs b/tests/Valit.Tests/UInt16/UInt16_IsEqual_To_Tests.cs index 2a98ef1..e6a51a8 100644 --- a/tests/Valit.Tests/UInt16/UInt16_IsEqual_To_Tests.cs +++ b/tests/Valit.Tests/UInt16/UInt16_IsEqual_To_Tests.cs @@ -12,7 +12,7 @@ public void UInt16_IsEqualTo_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Gi ((IValitRule)null) .IsEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void UInt16_IsEqualTo_For_Not_Nullable_Value_And_Nullable_Value_Throws_Wh ((IValitRule)null) .IsEqualTo((ushort?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void UInt16_IsEqualTo_For_Nullable_Value_And_Not_Nullable_Value_Throws_Wh ((IValitRule)null) .IsEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void UInt16_IsEqualTo_For_Nullable_Values_Throws_When_Null_Rule_Is_Given( ((IValitRule)null) .IsEqualTo((ushort?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void UInt16_IsEqualTo_For_Nullable_Values_Throws_When_Null_Rule_Is_Given( [Theory] [InlineData(10, true)] [InlineData(9, false)] - [InlineData(11, false)] + [InlineData(11, false)] public void UInt16_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(ushort value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void UInt16_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(usho [Theory] [InlineData((ushort) 10, true)] [InlineData((ushort) 9, false)] - [InlineData((ushort) 11, false)] - [InlineData(null, false)] + [InlineData((ushort) 11, false)] + [InlineData(null, false)] public void UInt16_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(ushort? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void UInt16_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_N [Theory] [InlineData(false, 10, true)] - [InlineData(false, 9, false)] - [InlineData(false, 11, false)] - [InlineData(true, 10, false)] + [InlineData(false, 9, false)] + [InlineData(false, 11, false)] + [InlineData(true, 10, false)] public void UInt16_IsEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, ushort value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void UInt16_IsEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_N } [Theory] - [InlineData(false, (ushort) 10, true)] - [InlineData(false, (ushort) 9, false)] + [InlineData(false, (ushort) 10, true)] + [InlineData(false, (ushort) 9, false)] [InlineData(false, (ushort) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (ushort) 10, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (ushort) 10, false)] + [InlineData(true, null, false)] public void UInt16_IsEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, ushort? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -133,6 +133,6 @@ class Model public ushort? NullableValue => 10; public ushort? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/UInt16/UInt16_IsGreaterThanOrEqualTo_Tests.cs b/tests/Valit.Tests/UInt16/UInt16_IsGreaterThanOrEqualTo_Tests.cs index fdd9ce3..48f1390 100644 --- a/tests/Valit.Tests/UInt16/UInt16_IsGreaterThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/UInt16/UInt16_IsGreaterThanOrEqualTo_Tests.cs @@ -12,7 +12,7 @@ public void UInt16_IsGreaterThanOrEqualTo_For_Not_Nullable_Values_Throws_When_Nu ((IValitRule)null) .IsGreaterThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void UInt16_IsGreaterThanOrEqualTo_For_Not_Nullable_Value_And_Nullable_Va ((IValitRule)null) .IsGreaterThanOrEqualTo((ushort?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void UInt16_IsGreaterThanOrEqualTo_For_Nullable_Value_And_Not_Nullable_Va ((IValitRule)null) .IsGreaterThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void UInt16_IsGreaterThanOrEqualTo_For_Nullable_Values_Throws_When_Null_R ((IValitRule)null) .IsGreaterThanOrEqualTo((ushort?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void UInt16_IsGreaterThanOrEqualTo_For_Nullable_Values_Throws_When_Null_R [Theory] [InlineData(9, true)] [InlineData(10, true)] - [InlineData(11, false)] + [InlineData(11, false)] public void UInt16_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(ushort value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void UInt16_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullabl [Theory] [InlineData((ushort) 9, true)] [InlineData((ushort) 10, true)] - [InlineData((ushort) 11, false)] - [InlineData(null, false)] + [InlineData((ushort) 11, false)] + [InlineData(null, false)] public void UInt16_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(ushort? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void UInt16_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullabl [Theory] [InlineData(false, 9, true)] - [InlineData(false, 10, true)] - [InlineData(false, 11, false)] - [InlineData(true, 9, false)] + [InlineData(false, 10, true)] + [InlineData(false, 11, false)] + [InlineData(true, 9, false)] public void UInt16_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, ushort value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void UInt16_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Va } [Theory] - [InlineData(false, (ushort) 9, true)] - [InlineData(false, (ushort) 10, true)] + [InlineData(false, (ushort) 9, true)] + [InlineData(false, (ushort) 10, true)] [InlineData(false, (ushort) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (ushort) 9, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (ushort) 9, false)] + [InlineData(true, null, false)] public void UInt16_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, ushort? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -135,4 +135,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/UInt16/UInt16_IsGreaterThan_Tests.cs b/tests/Valit.Tests/UInt16/UInt16_IsGreaterThan_Tests.cs index b4eb153..28f7d2d 100644 --- a/tests/Valit.Tests/UInt16/UInt16_IsGreaterThan_Tests.cs +++ b/tests/Valit.Tests/UInt16/UInt16_IsGreaterThan_Tests.cs @@ -13,7 +13,7 @@ public void UInt16_IsGreaterThan_For_Not_Nullable_Values_Throws_When_Null_Rule_I ((IValitRule)null) .IsGreaterThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -24,7 +24,7 @@ public void UInt16_IsGreaterThan_For_Not_Nullable_Value_And_Nullable_Value_Throw ((IValitRule)null) .IsGreaterThan((ushort?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -35,7 +35,7 @@ public void UInt16_IsGreaterThan_For_Nullable_Value_And_Not_Nullable_Value_Throw ((IValitRule)null) .IsGreaterThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -46,7 +46,7 @@ public void UInt16_IsGreaterThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Gi ((IValitRule)null) .IsGreaterThan((ushort?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -54,9 +54,9 @@ public void UInt16_IsGreaterThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Gi [Theory] [InlineData(9, true)] [InlineData(10, false)] - [InlineData(11, false)] + [InlineData(11, false)] public void UInt16_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Values(ushort value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -70,10 +70,10 @@ public void UInt16_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Values( [Theory] [InlineData((ushort) 9, true)] [InlineData((ushort) 10, false)] - [InlineData((ushort) 11, false)] - [InlineData(null, false)] + [InlineData((ushort) 11, false)] + [InlineData(null, false)] public void UInt16_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(ushort? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -86,11 +86,11 @@ public void UInt16_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Value_A [Theory] [InlineData(false, 9, true)] - [InlineData(false, 10, false)] - [InlineData(false, 11, false)] - [InlineData(true, 9, false)] + [InlineData(false, 10, false)] + [InlineData(false, 11, false)] + [InlineData(true, 9, false)] public void UInt16_IsGreaterThan_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, ushort value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -102,14 +102,14 @@ public void UInt16_IsGreaterThan_Returns_Proper_Results_For_Nullable_Value_And_N } [Theory] - [InlineData(false, (ushort) 9, true)] - [InlineData(false, (ushort) 10, false)] + [InlineData(false, (ushort) 9, true)] + [InlineData(false, (ushort) 10, false)] [InlineData(false, (ushort) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (ushort) 9, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (ushort) 9, false)] + [InlineData(true, null, false)] public void UInt16_IsGreaterThan_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, ushort? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -136,4 +136,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/UInt16/UInt16_IsLessThanOrEqualTo_Tests.cs b/tests/Valit.Tests/UInt16/UInt16_IsLessThanOrEqualTo_Tests.cs index dcc575c..ecca3e7 100644 --- a/tests/Valit.Tests/UInt16/UInt16_IsLessThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/UInt16/UInt16_IsLessThanOrEqualTo_Tests.cs @@ -12,7 +12,7 @@ public void UInt16_IsLessThanOrEqualTo_For_Not_Nullable_Values_Throws_When_Null_ ((IValitRule)null) .IsLessThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void UInt16_IsLessThanOrEqualTo_For_Not_Nullable_Value_And_Nullable_Value ((IValitRule)null) .IsLessThanOrEqualTo((ushort?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void UInt16_IsLessThanOrEqualTo_For_Nullable_Value_And_Not_Nullable_Value ((IValitRule)null) .IsLessThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void UInt16_IsLessThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Rule ((IValitRule)null) .IsLessThanOrEqualTo((ushort?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void UInt16_IsLessThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Rule [Theory] [InlineData(11, true)] [InlineData(10, true)] - [InlineData(9, false)] + [InlineData(9, false)] public void UInt16_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(ushort value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void UInt16_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_V [Theory] [InlineData((ushort) 11, true)] [InlineData((ushort) 10, true)] - [InlineData((ushort) 9, false)] - [InlineData(null, false)] + [InlineData((ushort) 9, false)] + [InlineData(null, false)] public void UInt16_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(ushort? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void UInt16_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_V [Theory] [InlineData(false, 11, true)] - [InlineData(false, 10, true)] - [InlineData(false, 9, false)] - [InlineData(true, 11, false)] + [InlineData(false, 10, true)] + [InlineData(false, 9, false)] + [InlineData(true, 11, false)] public void UInt16_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, ushort value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void UInt16_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value } [Theory] - [InlineData(false, (ushort) 11, true)] - [InlineData(false, (ushort) 10, true)] + [InlineData(false, (ushort) 11, true)] + [InlineData(false, (ushort) 10, true)] [InlineData(false, (ushort) 9, false)] - [InlineData(false, null, false)] - [InlineData(true, (ushort) 11, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (ushort) 11, false)] + [InlineData(true, null, false)] public void UInt16_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, ushort? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -133,6 +133,6 @@ class Model public ushort? NullableValue => 10; public ushort? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/UInt16/UInt16_IsLessThan_Tests.cs b/tests/Valit.Tests/UInt16/UInt16_IsLessThan_Tests.cs index dc3637c..54fbba8 100644 --- a/tests/Valit.Tests/UInt16/UInt16_IsLessThan_Tests.cs +++ b/tests/Valit.Tests/UInt16/UInt16_IsLessThan_Tests.cs @@ -5,7 +5,7 @@ namespace Valit.Tests.UInt16 { public class UInt16_IsLessThan_Tests { - + [Fact] public void UInt16_IsLessThan_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Given() { @@ -13,7 +13,7 @@ public void UInt16_IsLessThan_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_G ((IValitRule)null) .IsLessThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -24,7 +24,7 @@ public void UInt16_IsLessThan_For_Not_Nullable_Value_And_Nullable_Value_Throws_W ((IValitRule)null) .IsLessThan((ushort?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -35,7 +35,7 @@ public void UInt16_IsLessThan_For_Nullable_Value_And_Not_Nullable_Value_Throws_W ((IValitRule)null) .IsLessThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -46,7 +46,7 @@ public void UInt16_IsLessThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Given ((IValitRule)null) .IsLessThan((ushort?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -54,9 +54,9 @@ public void UInt16_IsLessThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Given [Theory] [InlineData(11, true)] [InlineData(10, false)] - [InlineData(9, false)] + [InlineData(9, false)] public void UInt16_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Values(ushort value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -70,10 +70,10 @@ public void UInt16_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Values(ush [Theory] [InlineData((ushort) 11, true)] [InlineData((ushort) 10, false)] - [InlineData((ushort) 9, false)] - [InlineData(null, false)] + [InlineData((ushort) 9, false)] + [InlineData(null, false)] public void UInt16_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(ushort? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -86,11 +86,11 @@ public void UInt16_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Value_And_ [Theory] [InlineData(false, 11, true)] - [InlineData(false, 10, false)] - [InlineData(false, 9, false)] - [InlineData(true, 11, false)] + [InlineData(false, 10, false)] + [InlineData(false, 9, false)] + [InlineData(true, 11, false)] public void UInt16_IsLessThan_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, ushort value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -102,14 +102,14 @@ public void UInt16_IsLessThan_Returns_Proper_Results_For_Nullable_Value_And_Not_ } [Theory] - [InlineData(false, (ushort) 11, true)] - [InlineData(false, (ushort) 10, false)] + [InlineData(false, (ushort) 11, true)] + [InlineData(false, (ushort) 10, false)] [InlineData(false, (ushort) 9, false)] - [InlineData(false, null, false)] - [InlineData(true, (ushort) 11, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (ushort) 11, false)] + [InlineData(true, null, false)] public void UInt16_IsLessThan_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, ushort? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -136,5 +136,5 @@ class Model } #endregion } - -} \ No newline at end of file + +} diff --git a/tests/Valit.Tests/UInt16/UInt16_IsNonZero_Tests.cs b/tests/Valit.Tests/UInt16/UInt16_IsNonZero_Tests.cs index e85fdc3..9598ca5 100644 --- a/tests/Valit.Tests/UInt16/UInt16_IsNonZero_Tests.cs +++ b/tests/Valit.Tests/UInt16/UInt16_IsNonZero_Tests.cs @@ -5,14 +5,14 @@ namespace Valit.Tests.UInt16 { public class UInt16_IsNonZero_Tests { - [Fact] + [Fact] public void UInt16_IsNonZero_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsNonZero(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,16 +23,16 @@ public void UInt16_IsNonZero_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsNonZero(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void UInt16_IsNonZero_Returns_Proper_Results_For_Not_Nullable_Value(bool useZeroValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useZeroValue? m.ZeroValue : m.Value, _=>_ @@ -45,9 +45,9 @@ public void UInt16_IsNonZero_Returns_Proper_Results_For_Not_Nullable_Value(bool [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void UInt16_IsNonZero_Returns_Proper_Results_For_Nullable_Value(bool useZeroValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useZeroValue? m.NullableZeroValue : m.NullableValue, _=>_ @@ -60,7 +60,7 @@ public void UInt16_IsNonZero_Returns_Proper_Results_For_Nullable_Value(bool useZ [Fact] public void UInt16_IsNonZero_Fails_For_Null_Value() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullValue, _=>_ @@ -89,4 +89,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/UInt16/UInt16_Required_Tests.cs b/tests/Valit.Tests/UInt16/UInt16_Required_Tests.cs index 7a3a192..a4bc2ca 100644 --- a/tests/Valit.Tests/UInt16/UInt16_Required_Tests.cs +++ b/tests/Valit.Tests/UInt16/UInt16_Required_Tests.cs @@ -13,16 +13,16 @@ public void UInt16_Required_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .Required(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void UInt16_Required_Returns_Proper_Results_For_Nullable_Value(bool useNullValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -51,4 +51,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/UInt32/UInt32_IsEqual_To_Tests.cs b/tests/Valit.Tests/UInt32/UInt32_IsEqual_To_Tests.cs index 88caf10..6d8aa6f 100644 --- a/tests/Valit.Tests/UInt32/UInt32_IsEqual_To_Tests.cs +++ b/tests/Valit.Tests/UInt32/UInt32_IsEqual_To_Tests.cs @@ -12,7 +12,7 @@ public void UInt32_IsEqualTo_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Gi ((IValitRule)null) .IsEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void UInt32_IsEqualTo_For_Not_Nullable_Value_And_Nullable_Value_Throws_Wh ((IValitRule)null) .IsEqualTo((uint?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void UInt32_IsEqualTo_For_Nullable_Value_And_Not_Nullable_Value_Throws_Wh ((IValitRule)null) .IsEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void UInt32_IsEqualTo_For_Nullable_Values_Throws_When_Null_Rule_Is_Given( ((IValitRule)null) .IsEqualTo((uint?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void UInt32_IsEqualTo_For_Nullable_Values_Throws_When_Null_Rule_Is_Given( [Theory] [InlineData(10, true)] [InlineData(9, false)] - [InlineData(11, false)] + [InlineData(11, false)] public void UInt32_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(uint value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void UInt32_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(uint [Theory] [InlineData((uint) 10, true)] [InlineData((uint) 9, false)] - [InlineData((uint) 11, false)] - [InlineData(null, false)] + [InlineData((uint) 11, false)] + [InlineData(null, false)] public void UInt32_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(uint? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void UInt32_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_N [Theory] [InlineData(false, 10, true)] - [InlineData(false, 9, false)] - [InlineData(false, 11, false)] - [InlineData(true, 10, false)] + [InlineData(false, 9, false)] + [InlineData(false, 11, false)] + [InlineData(true, 10, false)] public void UInt32_IsEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, uint value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void UInt32_IsEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_N } [Theory] - [InlineData(false, (uint) 10, true)] - [InlineData(false, (uint) 9, false)] + [InlineData(false, (uint) 10, true)] + [InlineData(false, (uint) 9, false)] [InlineData(false, (uint) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (uint) 10, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (uint) 10, false)] + [InlineData(true, null, false)] public void UInt32_IsEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, uint? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -133,6 +133,6 @@ class Model public uint? NullableValue => 10; public uint? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/UInt32/UInt32_IsGreaterThanOrEqualTo_Tests.cs b/tests/Valit.Tests/UInt32/UInt32_IsGreaterThanOrEqualTo_Tests.cs index c0d7de5..d3450f5 100644 --- a/tests/Valit.Tests/UInt32/UInt32_IsGreaterThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/UInt32/UInt32_IsGreaterThanOrEqualTo_Tests.cs @@ -12,7 +12,7 @@ public void UInt32_IsGreaterThanOrEqualTo_For_Not_Nullable_Values_Throws_When_Nu ((IValitRule)null) .IsGreaterThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void UInt32_IsGreaterThanOrEqualTo_For_Not_Nullable_Value_And_Nullable_Va ((IValitRule)null) .IsGreaterThanOrEqualTo((uint?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void UInt32_IsGreaterThanOrEqualTo_For_Nullable_Value_And_Not_Nullable_Va ((IValitRule)null) .IsGreaterThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void UInt32_IsGreaterThanOrEqualTo_For_Nullable_Values_Throws_When_Null_R ((IValitRule)null) .IsGreaterThanOrEqualTo((uint?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void UInt32_IsGreaterThanOrEqualTo_For_Nullable_Values_Throws_When_Null_R [Theory] [InlineData(9, true)] [InlineData(10, true)] - [InlineData(11, false)] + [InlineData(11, false)] public void UInt32_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(uint value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void UInt32_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullabl [Theory] [InlineData((uint) 9, true)] [InlineData((uint) 10, true)] - [InlineData((uint) 11, false)] - [InlineData(null, false)] + [InlineData((uint) 11, false)] + [InlineData(null, false)] public void UInt32_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(uint? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void UInt32_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullabl [Theory] [InlineData(false, 9, true)] - [InlineData(false, 10, true)] - [InlineData(false, 11, false)] - [InlineData(true, 9, false)] + [InlineData(false, 10, true)] + [InlineData(false, 11, false)] + [InlineData(true, 9, false)] public void UInt32_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, uint value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void UInt32_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Va } [Theory] - [InlineData(false, (uint) 9, true)] - [InlineData(false, (uint) 10, true)] + [InlineData(false, (uint) 9, true)] + [InlineData(false, (uint) 10, true)] [InlineData(false, (uint) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (uint) 9, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (uint) 9, false)] + [InlineData(true, null, false)] public void UInt32_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, uint? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -135,4 +135,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/UInt32/UInt32_IsGreaterThan_Tests.cs b/tests/Valit.Tests/UInt32/UInt32_IsGreaterThan_Tests.cs index b608f0c..3da2238 100644 --- a/tests/Valit.Tests/UInt32/UInt32_IsGreaterThan_Tests.cs +++ b/tests/Valit.Tests/UInt32/UInt32_IsGreaterThan_Tests.cs @@ -13,7 +13,7 @@ public void UInt32_IsGreaterThan_For_Not_Nullable_Values_Throws_When_Null_Rule_I ((IValitRule)null) .IsGreaterThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -24,7 +24,7 @@ public void UInt32_IsGreaterThan_For_Not_Nullable_Value_And_Nullable_Value_Throw ((IValitRule)null) .IsGreaterThan((uint?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -35,7 +35,7 @@ public void UInt32_IsGreaterThan_For_Nullable_Value_And_Not_Nullable_Value_Throw ((IValitRule)null) .IsGreaterThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -46,7 +46,7 @@ public void UInt32_IsGreaterThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Gi ((IValitRule)null) .IsGreaterThan((uint?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -54,9 +54,9 @@ public void UInt32_IsGreaterThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Gi [Theory] [InlineData(9, true)] [InlineData(10, false)] - [InlineData(11, false)] + [InlineData(11, false)] public void UInt32_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Values(uint value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -70,10 +70,10 @@ public void UInt32_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Values( [Theory] [InlineData((uint) 9, true)] [InlineData((uint) 10, false)] - [InlineData((uint) 11, false)] - [InlineData(null, false)] + [InlineData((uint) 11, false)] + [InlineData(null, false)] public void UInt32_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(uint? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -86,11 +86,11 @@ public void UInt32_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Value_A [Theory] [InlineData(false, 9, true)] - [InlineData(false, 10, false)] - [InlineData(false, 11, false)] - [InlineData(true, 9, false)] + [InlineData(false, 10, false)] + [InlineData(false, 11, false)] + [InlineData(true, 9, false)] public void UInt32_IsGreaterThan_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, uint value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -102,14 +102,14 @@ public void UInt32_IsGreaterThan_Returns_Proper_Results_For_Nullable_Value_And_N } [Theory] - [InlineData(false, (uint) 9, true)] - [InlineData(false, (uint) 10, false)] + [InlineData(false, (uint) 9, true)] + [InlineData(false, (uint) 10, false)] [InlineData(false, (uint) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (uint) 9, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (uint) 9, false)] + [InlineData(true, null, false)] public void UInt32_IsGreaterThan_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, uint? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -136,4 +136,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/UInt32/UInt32_IsLessThanOrEqualTo_Tests.cs b/tests/Valit.Tests/UInt32/UInt32_IsLessThanOrEqualTo_Tests.cs index af4ee85..9972e50 100644 --- a/tests/Valit.Tests/UInt32/UInt32_IsLessThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/UInt32/UInt32_IsLessThanOrEqualTo_Tests.cs @@ -12,7 +12,7 @@ public void UInt32_IsLessThanOrEqualTo_For_Not_Nullable_Values_Throws_When_Null_ ((IValitRule)null) .IsLessThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void UInt32_IsLessThanOrEqualTo_For_Not_Nullable_Value_And_Nullable_Value ((IValitRule)null) .IsLessThanOrEqualTo((uint?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void UInt32_IsLessThanOrEqualTo_For_Nullable_Value_And_Not_Nullable_Value ((IValitRule)null) .IsLessThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void UInt32_IsLessThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Rule ((IValitRule)null) .IsLessThanOrEqualTo((uint?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void UInt32_IsLessThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Rule [Theory] [InlineData(11, true)] [InlineData(10, true)] - [InlineData(9, false)] + [InlineData(9, false)] public void UInt32_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(uint value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void UInt32_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_V [Theory] [InlineData((uint) 11, true)] [InlineData((uint) 10, true)] - [InlineData((uint) 9, false)] - [InlineData(null, false)] + [InlineData((uint) 9, false)] + [InlineData(null, false)] public void UInt32_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(uint? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void UInt32_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_V [Theory] [InlineData(false, 11, true)] - [InlineData(false, 10, true)] - [InlineData(false, 9, false)] - [InlineData(true, 11, false)] + [InlineData(false, 10, true)] + [InlineData(false, 9, false)] + [InlineData(true, 11, false)] public void UInt32_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, uint value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void UInt32_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value } [Theory] - [InlineData(false, (uint) 11, true)] - [InlineData(false, (uint) 10, true)] + [InlineData(false, (uint) 11, true)] + [InlineData(false, (uint) 10, true)] [InlineData(false, (uint) 9, false)] - [InlineData(false, null, false)] - [InlineData(true, (uint) 11, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (uint) 11, false)] + [InlineData(true, null, false)] public void UInt32_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, uint? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -133,6 +133,6 @@ class Model public uint? NullableValue => 10; public uint? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/UInt32/UInt32_IsLessThan_Tests.cs b/tests/Valit.Tests/UInt32/UInt32_IsLessThan_Tests.cs index 9254207..0b755f3 100644 --- a/tests/Valit.Tests/UInt32/UInt32_IsLessThan_Tests.cs +++ b/tests/Valit.Tests/UInt32/UInt32_IsLessThan_Tests.cs @@ -5,7 +5,7 @@ namespace Valit.Tests.UInt32 { public class UInt32_IsLessThan_Tests { - + [Fact] public void UInt32_IsLessThan_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Given() { @@ -13,7 +13,7 @@ public void UInt32_IsLessThan_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_G ((IValitRule)null) .IsLessThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -24,7 +24,7 @@ public void UInt32_IsLessThan_For_Not_Nullable_Value_And_Nullable_Value_Throws_W ((IValitRule)null) .IsLessThan((uint?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -35,7 +35,7 @@ public void UInt32_IsLessThan_For_Nullable_Value_And_Not_Nullable_Value_Throws_W ((IValitRule)null) .IsLessThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -46,7 +46,7 @@ public void UInt32_IsLessThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Given ((IValitRule)null) .IsLessThan((uint?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -54,9 +54,9 @@ public void UInt32_IsLessThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Given [Theory] [InlineData(11, true)] [InlineData(10, false)] - [InlineData(9, false)] + [InlineData(9, false)] public void UInt32_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Values(uint value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -70,10 +70,10 @@ public void UInt32_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Values(uin [Theory] [InlineData((uint) 11, true)] [InlineData((uint) 10, false)] - [InlineData((uint) 9, false)] - [InlineData(null, false)] + [InlineData((uint) 9, false)] + [InlineData(null, false)] public void UInt32_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(uint? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -86,11 +86,11 @@ public void UInt32_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Value_And_ [Theory] [InlineData(false, 11, true)] - [InlineData(false, 10, false)] - [InlineData(false, 9, false)] - [InlineData(true, 11, false)] + [InlineData(false, 10, false)] + [InlineData(false, 9, false)] + [InlineData(true, 11, false)] public void UInt32_IsLessThan_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, uint value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -102,14 +102,14 @@ public void UInt32_IsLessThan_Returns_Proper_Results_For_Nullable_Value_And_Not_ } [Theory] - [InlineData(false, (uint) 11, true)] - [InlineData(false, (uint) 10, false)] + [InlineData(false, (uint) 11, true)] + [InlineData(false, (uint) 10, false)] [InlineData(false, (uint) 9, false)] - [InlineData(false, null, false)] - [InlineData(true, (uint) 11, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (uint) 11, false)] + [InlineData(true, null, false)] public void UInt32_IsLessThan_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, uint? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -136,5 +136,5 @@ class Model } #endregion } - -} \ No newline at end of file + +} diff --git a/tests/Valit.Tests/UInt32/UInt32_IsNonZero_Tests.cs b/tests/Valit.Tests/UInt32/UInt32_IsNonZero_Tests.cs index 6e78cec..f6c8a92 100644 --- a/tests/Valit.Tests/UInt32/UInt32_IsNonZero_Tests.cs +++ b/tests/Valit.Tests/UInt32/UInt32_IsNonZero_Tests.cs @@ -5,14 +5,14 @@ namespace Valit.Tests.UInt32 { public class UInt32_IsNonZero_Tests { - [Fact] + [Fact] public void UInt32_IsNonZero_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsNonZero(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,16 +23,16 @@ public void UInt32_IsNonZero_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsNonZero(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void UInt32_IsNonZero_Returns_Proper_Results_For_Not_Nullable_Value(bool useZeroValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useZeroValue? m.ZeroValue : m.Value, _=>_ @@ -45,9 +45,9 @@ public void UInt32_IsNonZero_Returns_Proper_Results_For_Not_Nullable_Value(bool [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void UInt32_IsNonZero_Returns_Proper_Results_For_Nullable_Value(bool useZeroValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useZeroValue? m.NullableZeroValue : m.NullableValue, _=>_ @@ -60,7 +60,7 @@ public void UInt32_IsNonZero_Returns_Proper_Results_For_Nullable_Value(bool useZ [Fact] public void UInt32_IsNonZero_Fails_For_Null_Value() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullValue, _=>_ @@ -89,4 +89,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/UInt32/UInt32_Required_Tests.cs b/tests/Valit.Tests/UInt32/UInt32_Required_Tests.cs index f57db42..c8c3240 100644 --- a/tests/Valit.Tests/UInt32/UInt32_Required_Tests.cs +++ b/tests/Valit.Tests/UInt32/UInt32_Required_Tests.cs @@ -13,16 +13,16 @@ public void UInt32_Required_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .Required(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void UInt32_Required_Returns_Proper_Results_For_Nullable_Value(bool useNullValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -51,4 +51,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/UInt64/UInt64_IsEqual_To_Tests.cs b/tests/Valit.Tests/UInt64/UInt64_IsEqual_To_Tests.cs index 319efd5..e65e110 100644 --- a/tests/Valit.Tests/UInt64/UInt64_IsEqual_To_Tests.cs +++ b/tests/Valit.Tests/UInt64/UInt64_IsEqual_To_Tests.cs @@ -12,7 +12,7 @@ public void UInt64_IsEqualTo_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Gi ((IValitRule)null) .IsEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void UInt64_IsEqualTo_For_Not_Nullable_Value_And_Nullable_Value_Throws_Wh ((IValitRule)null) .IsEqualTo((ulong?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void UInt64_IsEqualTo_For_Nullable_Value_And_Not_Nullable_Value_Throws_Wh ((IValitRule)null) .IsEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void UInt64_IsEqualTo_For_Nullable_Values_Throws_When_Null_Rule_Is_Given( ((IValitRule)null) .IsEqualTo((ulong?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void UInt64_IsEqualTo_For_Nullable_Values_Throws_When_Null_Rule_Is_Given( [Theory] [InlineData(10, true)] [InlineData(9, false)] - [InlineData(11, false)] + [InlineData(11, false)] public void UInt64_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(ulong value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void UInt64_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(ulon [Theory] [InlineData((ulong) 10, true)] [InlineData((ulong) 9, false)] - [InlineData((ulong) 11, false)] - [InlineData(null, false)] + [InlineData((ulong) 11, false)] + [InlineData(null, false)] public void UInt64_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(ulong? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void UInt64_IsEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_N [Theory] [InlineData(false, 10, true)] - [InlineData(false, 9, false)] - [InlineData(false, 11, false)] - [InlineData(true, 10, false)] + [InlineData(false, 9, false)] + [InlineData(false, 11, false)] + [InlineData(true, 10, false)] public void UInt64_IsEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, ulong value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void UInt64_IsEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_N } [Theory] - [InlineData(false, (ulong) 10, true)] - [InlineData(false, (ulong) 9, false)] + [InlineData(false, (ulong) 10, true)] + [InlineData(false, (ulong) 9, false)] [InlineData(false, (ulong) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (ulong) 10, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (ulong) 10, false)] + [InlineData(true, null, false)] public void UInt64_IsEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, ulong? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -133,6 +133,6 @@ class Model public ulong? NullableValue => 10; public ulong? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/UInt64/UInt64_IsGreaterThanOrEqualTo_Tests.cs b/tests/Valit.Tests/UInt64/UInt64_IsGreaterThanOrEqualTo_Tests.cs index c1bce3b..8361f98 100644 --- a/tests/Valit.Tests/UInt64/UInt64_IsGreaterThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/UInt64/UInt64_IsGreaterThanOrEqualTo_Tests.cs @@ -12,7 +12,7 @@ public void UInt64_IsGreaterThanOrEqualTo_For_Not_Nullable_Values_Throws_When_Nu ((IValitRule)null) .IsGreaterThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void UInt64_IsGreaterThanOrEqualTo_For_Not_Nullable_Value_And_Nullable_Va ((IValitRule)null) .IsGreaterThanOrEqualTo((ulong?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void UInt64_IsGreaterThanOrEqualTo_For_Nullable_Value_And_Not_Nullable_Va ((IValitRule)null) .IsGreaterThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void UInt64_IsGreaterThanOrEqualTo_For_Nullable_Values_Throws_When_Null_R ((IValitRule)null) .IsGreaterThanOrEqualTo((ulong?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void UInt64_IsGreaterThanOrEqualTo_For_Nullable_Values_Throws_When_Null_R [Theory] [InlineData(9, true)] [InlineData(10, true)] - [InlineData(11, false)] + [InlineData(11, false)] public void UInt64_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(ulong value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void UInt64_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullabl [Theory] [InlineData((ulong) 9, true)] [InlineData((ulong) 10, true)] - [InlineData((ulong) 11, false)] - [InlineData(null, false)] + [InlineData((ulong) 11, false)] + [InlineData(null, false)] public void UInt64_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(ulong? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void UInt64_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Not_Nullabl [Theory] [InlineData(false, 9, true)] - [InlineData(false, 10, true)] - [InlineData(false, 11, false)] - [InlineData(true, 9, false)] + [InlineData(false, 10, true)] + [InlineData(false, 11, false)] + [InlineData(true, 9, false)] public void UInt64_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, ulong value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void UInt64_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Va } [Theory] - [InlineData(false, (ulong) 9, true)] - [InlineData(false, (ulong) 10, true)] + [InlineData(false, (ulong) 9, true)] + [InlineData(false, (ulong) 10, true)] [InlineData(false, (ulong) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (ulong) 9, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (ulong) 9, false)] + [InlineData(true, null, false)] public void UInt64_IsGreaterThanOrEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, ulong? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -135,4 +135,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/UInt64/UInt64_IsGreaterThan_Tests.cs b/tests/Valit.Tests/UInt64/UInt64_IsGreaterThan_Tests.cs index 290e65c..f22dbfc 100644 --- a/tests/Valit.Tests/UInt64/UInt64_IsGreaterThan_Tests.cs +++ b/tests/Valit.Tests/UInt64/UInt64_IsGreaterThan_Tests.cs @@ -13,7 +13,7 @@ public void UInt64_IsGreaterThan_For_Not_Nullable_Values_Throws_When_Null_Rule_I ((IValitRule)null) .IsGreaterThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -24,7 +24,7 @@ public void UInt64_IsGreaterThan_For_Not_Nullable_Value_And_Nullable_Value_Throw ((IValitRule)null) .IsGreaterThan((ulong?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -35,7 +35,7 @@ public void UInt64_IsGreaterThan_For_Nullable_Value_And_Not_Nullable_Value_Throw ((IValitRule)null) .IsGreaterThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -46,7 +46,7 @@ public void UInt64_IsGreaterThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Gi ((IValitRule)null) .IsGreaterThan((ulong?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -54,9 +54,9 @@ public void UInt64_IsGreaterThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Gi [Theory] [InlineData(9, true)] [InlineData(10, false)] - [InlineData(11, false)] + [InlineData(11, false)] public void UInt64_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Values(ulong value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -70,10 +70,10 @@ public void UInt64_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Values( [Theory] [InlineData((ulong) 9, true)] [InlineData((ulong) 10, false)] - [InlineData((ulong) 11, false)] - [InlineData(null, false)] + [InlineData((ulong) 11, false)] + [InlineData(null, false)] public void UInt64_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(ulong? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -86,11 +86,11 @@ public void UInt64_IsGreaterThan_Returns_Proper_Results_For_Not_Nullable_Value_A [Theory] [InlineData(false, 9, true)] - [InlineData(false, 10, false)] - [InlineData(false, 11, false)] - [InlineData(true, 9, false)] + [InlineData(false, 10, false)] + [InlineData(false, 11, false)] + [InlineData(true, 9, false)] public void UInt64_IsGreaterThan_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, ulong value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -102,14 +102,14 @@ public void UInt64_IsGreaterThan_Returns_Proper_Results_For_Nullable_Value_And_N } [Theory] - [InlineData(false, (ulong) 9, true)] - [InlineData(false, (ulong) 10, false)] + [InlineData(false, (ulong) 9, true)] + [InlineData(false, (ulong) 10, false)] [InlineData(false, (ulong) 11, false)] - [InlineData(false, null, false)] - [InlineData(true, (ulong) 9, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (ulong) 9, false)] + [InlineData(true, null, false)] public void UInt64_IsGreaterThan_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, ulong? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -136,4 +136,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/UInt64/UInt64_IsLessThanOrEqualTo_Tests.cs b/tests/Valit.Tests/UInt64/UInt64_IsLessThanOrEqualTo_Tests.cs index ec27e83..eb9683c 100644 --- a/tests/Valit.Tests/UInt64/UInt64_IsLessThanOrEqualTo_Tests.cs +++ b/tests/Valit.Tests/UInt64/UInt64_IsLessThanOrEqualTo_Tests.cs @@ -12,7 +12,7 @@ public void UInt64_IsLessThanOrEqualTo_For_Not_Nullable_Values_Throws_When_Null_ ((IValitRule)null) .IsLessThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,7 +23,7 @@ public void UInt64_IsLessThanOrEqualTo_For_Not_Nullable_Value_And_Nullable_Value ((IValitRule)null) .IsLessThanOrEqualTo((ulong?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -34,7 +34,7 @@ public void UInt64_IsLessThanOrEqualTo_For_Nullable_Value_And_Not_Nullable_Value ((IValitRule)null) .IsLessThanOrEqualTo(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -45,7 +45,7 @@ public void UInt64_IsLessThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Rule ((IValitRule)null) .IsLessThanOrEqualTo((ulong?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -53,9 +53,9 @@ public void UInt64_IsLessThanOrEqualTo_For_Nullable_Values_Throws_When_Null_Rule [Theory] [InlineData(11, true)] [InlineData(10, true)] - [InlineData(9, false)] + [InlineData(9, false)] public void UInt64_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Values(ulong value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -69,10 +69,10 @@ public void UInt64_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_V [Theory] [InlineData((ulong) 11, true)] [InlineData((ulong) 10, true)] - [InlineData((ulong) 9, false)] - [InlineData(null, false)] + [InlineData((ulong) 9, false)] + [InlineData(null, false)] public void UInt64_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(ulong? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -85,11 +85,11 @@ public void UInt64_IsLessThanOrEqualTo_Returns_Proper_Results_For_Not_Nullable_V [Theory] [InlineData(false, 11, true)] - [InlineData(false, 10, true)] - [InlineData(false, 9, false)] - [InlineData(true, 11, false)] + [InlineData(false, 10, true)] + [InlineData(false, 9, false)] + [InlineData(true, 11, false)] public void UInt64_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, ulong value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -101,14 +101,14 @@ public void UInt64_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Value } [Theory] - [InlineData(false, (ulong) 11, true)] - [InlineData(false, (ulong) 10, true)] + [InlineData(false, (ulong) 11, true)] + [InlineData(false, (ulong) 10, true)] [InlineData(false, (ulong) 9, false)] - [InlineData(false, null, false)] - [InlineData(true, (ulong) 11, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (ulong) 11, false)] + [InlineData(true, null, false)] public void UInt64_IsLessThanOrEqualTo_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, ulong? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -133,6 +133,6 @@ class Model public ulong? NullableValue => 10; public ulong? NullValue => null; } -#endregion +#endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/UInt64/UInt64_IsLessThan_Tests.cs b/tests/Valit.Tests/UInt64/UInt64_IsLessThan_Tests.cs index c0cb90c..f005dfa 100644 --- a/tests/Valit.Tests/UInt64/UInt64_IsLessThan_Tests.cs +++ b/tests/Valit.Tests/UInt64/UInt64_IsLessThan_Tests.cs @@ -5,7 +5,7 @@ namespace Valit.Tests.UInt64 { public class UInt64_IsLessThan_Tests { - + [Fact] public void UInt64_IsLessThan_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_Given() { @@ -13,7 +13,7 @@ public void UInt64_IsLessThan_For_Not_Nullable_Values_Throws_When_Null_Rule_Is_G ((IValitRule)null) .IsLessThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -24,7 +24,7 @@ public void UInt64_IsLessThan_For_Not_Nullable_Value_And_Nullable_Value_Throws_W ((IValitRule)null) .IsLessThan((ulong?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -35,7 +35,7 @@ public void UInt64_IsLessThan_For_Nullable_Value_And_Not_Nullable_Value_Throws_W ((IValitRule)null) .IsLessThan(1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -46,7 +46,7 @@ public void UInt64_IsLessThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Given ((IValitRule)null) .IsLessThan((ulong?)1); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -54,9 +54,9 @@ public void UInt64_IsLessThan_For_Nullable_Values_Throws_When_Null_Rule_Is_Given [Theory] [InlineData(11, true)] [InlineData(10, false)] - [InlineData(9, false)] + [InlineData(9, false)] public void UInt64_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Values(ulong value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -70,10 +70,10 @@ public void UInt64_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Values(ulo [Theory] [InlineData((ulong) 11, true)] [InlineData((ulong) 10, false)] - [InlineData((ulong) 9, false)] - [InlineData(null, false)] + [InlineData((ulong) 9, false)] + [InlineData(null, false)] public void UInt64_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Value_And_Nullable_Value(ulong? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.Value, _=>_ @@ -86,11 +86,11 @@ public void UInt64_IsLessThan_Returns_Proper_Results_For_Not_Nullable_Value_And_ [Theory] [InlineData(false, 11, true)] - [InlineData(false, 10, false)] - [InlineData(false, 9, false)] - [InlineData(true, 11, false)] + [InlineData(false, 10, false)] + [InlineData(false, 9, false)] + [InlineData(true, 11, false)] public void UInt64_IsLessThan_Returns_Proper_Results_For_Nullable_Value_And_Not_Nullable_Value(bool useNullValue, ulong value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -102,14 +102,14 @@ public void UInt64_IsLessThan_Returns_Proper_Results_For_Nullable_Value_And_Not_ } [Theory] - [InlineData(false, (ulong) 11, true)] - [InlineData(false, (ulong) 10, false)] + [InlineData(false, (ulong) 11, true)] + [InlineData(false, (ulong) 10, false)] [InlineData(false, (ulong) 9, false)] - [InlineData(false, null, false)] - [InlineData(true, (ulong) 11, false)] - [InlineData(true, null, false)] + [InlineData(false, null, false)] + [InlineData(true, (ulong) 11, false)] + [InlineData(true, null, false)] public void UInt64_IsLessThan_Returns_Proper_Results_For_Nullable_Values(bool useNullValue, ulong? value, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -136,5 +136,5 @@ class Model } #endregion } - -} \ No newline at end of file + +} diff --git a/tests/Valit.Tests/UInt64/UInt64_IsNonZero_Tests.cs b/tests/Valit.Tests/UInt64/UInt64_IsNonZero_Tests.cs index 9fbdb68..8933d4d 100644 --- a/tests/Valit.Tests/UInt64/UInt64_IsNonZero_Tests.cs +++ b/tests/Valit.Tests/UInt64/UInt64_IsNonZero_Tests.cs @@ -5,14 +5,14 @@ namespace Valit.Tests.UInt64 { public class UInt64_IsNonZero_Tests { - [Fact] + [Fact] public void UInt64_IsNonZero_For_Not_Nullable_Value_Throws_When_Null_Rule_Is_Given() { var exception = Record.Exception(() => { ((IValitRule)null) .IsNonZero(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } @@ -23,16 +23,16 @@ public void UInt64_IsNonZero_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .IsNonZero(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void UInt64_IsNonZero_Returns_Proper_Results_For_Not_Nullable_Value(bool useZeroValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useZeroValue? m.ZeroValue : m.Value, _=>_ @@ -45,9 +45,9 @@ public void UInt64_IsNonZero_Returns_Proper_Results_For_Not_Nullable_Value(bool [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void UInt64_IsNonZero_Returns_Proper_Results_For_Nullable_Value(bool useZeroValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useZeroValue? m.NullableZeroValue : m.NullableValue, _=>_ @@ -60,7 +60,7 @@ public void UInt64_IsNonZero_Returns_Proper_Results_For_Nullable_Value(bool useZ [Fact] public void UInt64_IsNonZero_Fails_For_Null_Value() - { + { IValitResult result = ValitRules .Create() .Ensure(m => m.NullValue, _=>_ @@ -89,4 +89,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/UInt64/UInt64_Required_Tests.cs b/tests/Valit.Tests/UInt64/UInt64_Required_Tests.cs index 5b93098..d20daf6 100644 --- a/tests/Valit.Tests/UInt64/UInt64_Required_Tests.cs +++ b/tests/Valit.Tests/UInt64/UInt64_Required_Tests.cs @@ -13,16 +13,16 @@ public void UInt64_Required_For_Nullable_Value_Throws_When_Null_Rule_Is_Given() ((IValitRule)null) .Required(); }); - + exception.ShouldBeOfType(typeof(ValitException)); } [Theory] [InlineData(false, true)] - [InlineData(true, false)] + [InlineData(true, false)] public void UInt64_Required_Returns_Proper_Results_For_Nullable_Value(bool useNullValue, bool expected) - { + { IValitResult result = ValitRules .Create() .Ensure(m => useNullValue? m.NullValue : m.NullableValue, _=>_ @@ -51,4 +51,4 @@ class Model } #endregion } -} \ No newline at end of file +} diff --git a/tests/Valit.Tests/Valit.Tests.csproj b/tests/Valit.Tests/Valit.Tests.csproj index 3783015..be18f4c 100644 --- a/tests/Valit.Tests/Valit.Tests.csproj +++ b/tests/Valit.Tests/Valit.Tests.csproj @@ -1,6 +1,6 @@ - + netcoreapp2.0 @@ -15,4 +15,7 @@ + + + diff --git a/tests/Valit.Tests/Valitator/Valitator_Tests.cs b/tests/Valit.Tests/Valitator/Valitator_Tests.cs new file mode 100644 index 0000000..e1e4ca5 --- /dev/null +++ b/tests/Valit.Tests/Valitator/Valitator_Tests.cs @@ -0,0 +1,81 @@ +using System.Collections.Generic; +using Shouldly; +using Xunit; + +namespace Valit.Tests.Valitator +{ + public class Valitator_Tests + { + [Fact] + public void CreateValitator_Throws_When_Null_ValitRulesProvider_Is_Given() + { + var exception = Record.Exception(() => { + var valitator = ((IValitRulesProvider)null).CreateValitator(); + }); + + exception.ShouldBeOfType(typeof(ValitException)); + } + + [Fact] + public void Created_Valitator_Properly_Handles_Complete_Strategy() + { + var valitator = new ModelRulesProvider().CreateValitator(); + var result = valitator.Validate(_model); + + Assert.False(result.Succeeded); + result.ErrorMessages.ShouldContain("One"); + result.ErrorMessages.ShouldNotContain("Two"); + result.ErrorMessages.ShouldContain("Three"); + } + + [Fact] + public void Created_Valitator_Properly_Handles_FailFast_Strategy() + { + var valitator = new ModelRulesProvider().CreateValitator(); + var result = valitator.Validate(_model, new FailFastValitStrategy()); + + Assert.False(result.Succeeded); + result.ErrorMessages.ShouldContain("One"); + result.ErrorMessages.ShouldNotContain("Two"); + result.ErrorMessages.ShouldNotContain("Three"); + } + + +#region ARRANGE + + class Model + { + public ushort NumericValue { get; set; } + public string StringValue { get; set; } + } + + class ModelRulesProvider : IValitRulesProvider + { + public IEnumerable> GetRules() + => ValitRules + .Create() + .Ensure(m => m.NumericValue, _=>_ + .IsGreaterThan(10) + .WithMessage("One")) + .Ensure(m => m.StringValue, _=>_ + .Required() + .WithMessage("Two") + .Email() + .WithMessage("Three")) + .GetAllRules(); + } + + private readonly Model _model; + + public Valitator_Tests() + { + _model = new Model + { + NumericValue = 3, + StringValue = "Text" + }; + } + } +#endregion + +} diff --git a/tools/packages.config b/tools/packages.config new file mode 100644 index 0000000..747e13e --- /dev/null +++ b/tools/packages.config @@ -0,0 +1,4 @@ + + + +