Skip to content

Commit

Permalink
Merge branch 'main' into Andreybranch
Browse files Browse the repository at this point in the history
  • Loading branch information
Acrozi committed Jan 14, 2024
2 parents c111e20 + a0b19b9 commit cfac60e
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Personnummer_validation.sln
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
68 changes: 68 additions & 0 deletions tests/SwedishPersonalNumberValidatoTests.cs
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);
}
}
}

0 comments on commit cfac60e

Please sign in to comment.