-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #240 from qccoders/develop
Prod deploy MVP.08
- Loading branch information
Showing
16 changed files
with
659 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
namespace Server.Tests | ||
{ | ||
using Microsoft.AspNetCore.Mvc.ModelBinding; | ||
using QCVOC.Api.Common; | ||
using Xunit; | ||
|
||
public class GetReadableStringTests | ||
{ | ||
[Fact] | ||
public void NullDictionary() | ||
{ | ||
ModelStateDictionary modelState = null; | ||
string result = modelState.GetReadableString(); | ||
|
||
Assert.Equal(string.Empty, result); | ||
} | ||
|
||
[Fact] | ||
public void ValidDictionary() | ||
{ | ||
ModelStateDictionary modelState = new ModelStateDictionary(); | ||
string result = modelState.GetReadableString(); | ||
|
||
Assert.Equal(string.Empty, result); | ||
} | ||
|
||
[Fact] | ||
public void SingleError() | ||
{ | ||
ModelStateDictionary modelState = new ModelStateDictionary(); | ||
modelState.AddModelError("Name", "The name is too short"); | ||
string result = modelState.GetReadableString(); | ||
|
||
Assert.Equal("Name: The name is too short", result); | ||
} | ||
|
||
[Fact] | ||
public void OneKeyTwoErrors() | ||
{ | ||
ModelStateDictionary modelState = new ModelStateDictionary(); | ||
modelState.AddModelError("Name", "Not capitalized."); | ||
modelState.AddModelError("Name", "Too short."); | ||
string result = modelState.GetReadableString(); | ||
|
||
Assert.Equal("Name: Not capitalized, Too short", result); | ||
} | ||
|
||
[Fact] | ||
public void TwoKeysTwoErrors() | ||
{ | ||
ModelStateDictionary modelState = new ModelStateDictionary(); | ||
modelState.AddModelError("Name", "Too short."); | ||
modelState.AddModelError("Password", "Too long."); | ||
string result = modelState.GetReadableString(); | ||
|
||
Assert.Equal("Name: Too short; Password: Too long", result); | ||
} | ||
|
||
[Fact] | ||
public void ThreeKeysMultiErrors() | ||
{ | ||
ModelStateDictionary modelState = new ModelStateDictionary(); | ||
modelState.AddModelError("Name", "Too short."); | ||
modelState.AddModelError("Password", "Too long"); | ||
modelState.AddModelError("Password", "Not complex enough."); | ||
modelState.AddModelError("Password", "Already used"); | ||
modelState.AddModelError("PrimaryPhone", "Invalid."); | ||
string result = modelState.GetReadableString(); | ||
|
||
Assert.Equal( | ||
"Name: Too short; " | ||
+ "Password: Too long, Not complex enough, Already used; " | ||
+ "PrimaryPhone: Invalid", result); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.