-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into Andreybranch
- Loading branch information
Showing
2 changed files
with
93 additions
and
0 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,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.5.002.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Personnummer_validation", "Personnummer_validation.csproj", "{4D242514-563D-4627-BC8B-24B7192017A6}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{4D242514-563D-4627-BC8B-24B7192017A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4D242514-563D-4627-BC8B-24B7192017A6}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4D242514-563D-4627-BC8B-24B7192017A6}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4D242514-563D-4627-BC8B-24B7192017A6}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {FC4876B9-C746-4380-9CA7-717A2FB860C1} | ||
EndGlobalSection | ||
EndGlobal |
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,68 @@ | ||
namespace grupp_arbete.Tests | ||
{ | ||
public class SwedishPersonalNumberValidatorTests | ||
{ | ||
/* [Theory] | ||
[InlineData("011114-0414", true)] // Korrekt format och kontrollsiffra | ||
[InlineData("0111140414", true)] // Korrekt format | ||
[InlineData("850213456", false)] // För kort | ||
[InlineData("850213456789", false)] // För lång | ||
[InlineData("2504251234", false)] // Ogiltig ålder | ||
[InlineData("200111140414", true)] // Korrekt ålder | ||
public void IsValid_ShouldReturnExpectedResult(string input, bool expectedResult) | ||
{ | ||
bool result = SwedishPersonalNumberValidator.IsValid(input); | ||
Assert.Equal(expectedResult, result); | ||
} | ||
[Theory] | ||
[InlineData("850213-4587", "Female")] // Jämnt antal = kvinna | ||
[InlineData("8502134578", "Male")] // Udda antal = man | ||
public void GetGender_ShouldReturnExpectedGender(string input, string expectedGender) | ||
{ | ||
string result = SwedishPersonalNumberValidator.GetGender(input); | ||
Assert.Equal(expectedGender, result); | ||
} */ | ||
|
||
[Fact] | ||
public void IsValid_WithInvalidControlNumber_ShouldReturnFalse() | ||
{ | ||
bool result = SwedishPersonalNumberValidator.IsValid("8502134566"); // Ogiltig kontrollsiffra | ||
Assert.False(result); | ||
} | ||
|
||
[Fact] | ||
public void IsValid_WithInvalidAge_ShouldReturnFalse() | ||
{ | ||
bool result = SwedishPersonalNumberValidator.IsValid("000213456700"); // Ogiltig ålder | ||
Assert.False(result); | ||
} | ||
|
||
[Fact] | ||
public void IsValid_WithInvalidFormat_ShouldReturnFalse() | ||
{ | ||
bool result = SwedishPersonalNumberValidator.IsValid("85-0213-4567"); // Ogiltigt format med bindestreck | ||
Assert.False(result); | ||
} | ||
|
||
[Fact] | ||
public void GetGender_WithInvalidInput_ShouldThrowArgumentException() | ||
{ | ||
Assert.Throws<ArgumentException>(() => SwedishPersonalNumberValidator.GetGender("850213456")); // Felaktigt format | ||
} | ||
|
||
[Fact] | ||
public void IsValid_WithNullInput_ShouldReturnFalse() | ||
{ | ||
bool result = SwedishPersonalNumberValidator.IsValid(null); // Null input | ||
Assert.False(result); | ||
} | ||
|
||
[Fact] | ||
public void IsValid_WithEmptyStringInput_ShouldReturnFalse() | ||
{ | ||
bool result = SwedishPersonalNumberValidator.IsValid(""); // Tom sträng | ||
Assert.False(result); | ||
} | ||
} | ||
} |