32 lines
930 B
C#
32 lines
930 B
C#
using MathInterpreter.Core;
|
|
|
|
namespace MathInterpreter.Test;
|
|
|
|
public sealed class ScanResultTests
|
|
{
|
|
[Fact]
|
|
public void ScanResult_Construction_Valid()
|
|
{
|
|
const int ExpectedValue = -123;
|
|
const int ExpectedLength = 3;
|
|
const string ExpectedRemainingExpression = "abc";
|
|
|
|
var result = new ScanResult<int>(ExpectedValue, ExpectedLength, ExpectedRemainingExpression);
|
|
|
|
result.Value.Should().Be(ExpectedValue);
|
|
result.Length.Should().Be(ExpectedLength);
|
|
result.RemainingExpression.ToString().Should().Be(ExpectedRemainingExpression);
|
|
}
|
|
|
|
[Fact]
|
|
public void ScanResult_Construction_Invalid()
|
|
{
|
|
var action = () =>
|
|
{
|
|
var _ = new ScanResult<int>(1, -2, string.Empty);
|
|
};
|
|
|
|
action.Should().Throw<ArgumentOutOfRangeException>()
|
|
.WithMessage("Length must be non-negative (Parameter 'length')");
|
|
}
|
|
}
|