Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applikation test #1 #15

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/grupp7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Run unit test on merge publish Docker image


on:
pull_request:
push:
branches:
- '*'
- axelsbranch

jobs:
build:
Expand Down
11 changes: 9 additions & 2 deletions Personummer.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
using System;

namespace PersonligVerifiering
{
public static class PersonligInfoValidator
{
public static bool Validera(string personnummer)
public static bool Validera(string? personnummer)
{
// Kontrollerar så inte personnummret = null
if (personnummer == null)
{
return false;
}

// Kontrollera om personnumret har rätt längd.
if (personnummer.Length != 10 && personnummer.Length != 12)
{
Expand Down Expand Up @@ -33,7 +41,6 @@ public static bool Validera(string personnummer)
}
}


// Ytterligare kontroller för personnummer kan läggas till här.

return true;
Expand Down
24 changes: 24 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;

namespace PersonligVerifiering
{
class Program
{
static void Main()
{
Console.WriteLine("Vänligen ange ett svenskt personnummer:");
string input = Console.ReadLine() ?? string.Empty;

bool isValid = PersonligInfoValidator.Validera(input);

if (isValid)
{
Console.WriteLine("Personnumret är giltigt.");
}
else
{
Console.WriteLine("Personnumret är ogiltigt.");
}
}
}
}
1 change: 1 addition & 0 deletions gruppuppgiftCI_CD.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<StartupObject>PersonligVerifiering.Program</StartupObject>
</PropertyGroup>

<ItemGroup>
Expand Down