From db002ef1863ad42af4dc41ab3a908a2252de1fc5 Mon Sep 17 00:00:00 2001 From: Louis Date: Thu, 12 Oct 2023 09:54:49 +0200 Subject: [PATCH] feat: :sparkles: Finish lecture --- Tests/Tests.csproj | 4 ++++ Tests/UnitTest1.cs | 16 ++++++++++++++-- Tests/Usings.cs | 3 ++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index ba8cf18..e0824b8 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -22,4 +22,8 @@ + + + + diff --git a/Tests/UnitTest1.cs b/Tests/UnitTest1.cs index 279821b..b46d990 100644 --- a/Tests/UnitTest1.cs +++ b/Tests/UnitTest1.cs @@ -2,8 +2,20 @@ namespace Tests; public class UnitTest1 { - [Fact] - public void Test1() + [Theory] + [InlineData("123456", 123456)] + [InlineData("214213", 214213)] + [InlineData("987621", 987621)] + public void TestStringToInt(string a, int expected) { + Assert.Equal(Lecture.Exercises.Conversion.StringToInt(a), expected); + } + + [Theory] + [InlineData("12345", typeof(IndexOutOfRangeException))] + [InlineData("123A56", typeof(FormatException))] + public void TestStringToIntException(string value, Type expected) + { + Assert.Throws(expected, () => Lecture.Exercises.Conversion.StringToInt(value)); } } \ No newline at end of file diff --git a/Tests/Usings.cs b/Tests/Usings.cs index 8c927eb..670259f 100644 --- a/Tests/Usings.cs +++ b/Tests/Usings.cs @@ -1 +1,2 @@ -global using Xunit; \ No newline at end of file +global using Xunit; +global using Lecture;