mirror of https://github.com/ErsatzTV/ErsatzTV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
932 B
34 lines
932 B
using ErsatzTV.Core.Interfaces.Scheduling; |
|
using ErsatzTV.Core.Scheduling; |
|
using NSubstitute; |
|
using NUnit.Framework; |
|
using Shouldly; |
|
|
|
namespace ErsatzTV.Core.Tests.Scheduling; |
|
|
|
[TestFixture] |
|
public class CountExpressionTests |
|
{ |
|
[Test] |
|
[TestCase("2", 2)] |
|
[TestCase("count", 10)] |
|
[TestCase("count / 2", 5)] |
|
[TestCase("count * 2", 20)] |
|
[TestCase("count + 1", 11)] |
|
[TestCase("count - 1", 9)] |
|
[TestCase("random % 4 + 1", 3)] |
|
[TestCase("invalid", 0)] |
|
[TestCase("count / 0", 0)] |
|
public void Should_Evaluate_Expression(string expression, int expected) |
|
{ |
|
var enumerator = Substitute.For<IMediaCollectionEnumerator>(); |
|
enumerator.Count.Returns(10); |
|
|
|
var random = Substitute.For<Random>(); |
|
random.Next().Returns(2); |
|
|
|
int result = CountExpression.Evaluate(expression, enumerator, random, CancellationToken.None); |
|
|
|
result.ShouldBe(expected); |
|
} |
|
}
|
|
|