37 lines
926 B
C#
37 lines
926 B
C#
using Flypaper.Storage.Queries;
|
|
using Shouldly;
|
|
|
|
namespace Flypaper.Tests.Mcp;
|
|
|
|
public sealed class QueryPeriodTests
|
|
{
|
|
[Theory]
|
|
[InlineData("30m", 0.5)]
|
|
[InlineData("1h", 1)]
|
|
[InlineData("24H", 24)]
|
|
[InlineData("7d", 168)]
|
|
[InlineData("2w", 336)]
|
|
public void Parses_relative_periods(string value, double hours)
|
|
{
|
|
QueryPeriod.TryParse(value, out var span).ShouldBeTrue();
|
|
span.ShouldBe(TimeSpan.FromHours(hours));
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("all")]
|
|
[InlineData("")]
|
|
[InlineData(null)]
|
|
public void Treats_all_as_unbounded(string? value)
|
|
{
|
|
QueryPeriod.TryParse(value, out var span).ShouldBeTrue();
|
|
span.ShouldBeNull();
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("0d")]
|
|
[InlineData("1y")]
|
|
[InlineData("1.5h")]
|
|
[InlineData("h")]
|
|
public void Rejects_other_values(string value) => QueryPeriod.TryParse(value, out _).ShouldBeFalse();
|
|
}
|