CM-Exception/Tests/UnitTest1.cs
2023-10-12 09:54:49 +02:00

21 lines
603 B
C#

namespace Tests;
public class UnitTest1
{
[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));
}
}