21 lines
603 B
C#
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));
|
|
}
|
|
} |