mirror of
https://github.com/ppy/osu
synced 2024-12-27 09:23:15 +00:00
Improve test coverage
This commit is contained in:
parent
414066fd34
commit
f7bea00564
@ -508,8 +508,11 @@ namespace osu.Game.Tests.NonVisual.Filtering
|
||||
const string query = "played>50";
|
||||
var filterCriteria = new FilterCriteria();
|
||||
FilterQueryParser.ApplyQueries(filterCriteria, query);
|
||||
Assert.AreEqual(false, filterCriteria.LastPlayed.Max == null);
|
||||
Assert.AreEqual(true, filterCriteria.LastPlayed.Min == null);
|
||||
Assert.That(filterCriteria.LastPlayed.Max, Is.Not.Null);
|
||||
Assert.That(filterCriteria.LastPlayed.Min, Is.Null);
|
||||
// the parser internally references `DateTimeOffset.Now`, so to not make things too annoying for tests, just assume some tolerance
|
||||
// (irrelevant in proportion to the actual filter proscribed).
|
||||
Assert.That(filterCriteria.LastPlayed.Max, Is.EqualTo(DateTimeOffset.Now.AddDays(-50)).Within(TimeSpan.FromSeconds(5)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -518,8 +521,25 @@ namespace osu.Game.Tests.NonVisual.Filtering
|
||||
const string query = "played<50";
|
||||
var filterCriteria = new FilterCriteria();
|
||||
FilterQueryParser.ApplyQueries(filterCriteria, query);
|
||||
Assert.AreEqual(true, filterCriteria.LastPlayed.Max == null);
|
||||
Assert.AreEqual(false, filterCriteria.LastPlayed.Min == null);
|
||||
Assert.That(filterCriteria.LastPlayed.Max, Is.Null);
|
||||
Assert.That(filterCriteria.LastPlayed.Min, Is.Not.Null);
|
||||
// the parser internally references `DateTimeOffset.Now`, so to not make things too annoying for tests, just assume some tolerance
|
||||
// (irrelevant in proportion to the actual filter proscribed).
|
||||
Assert.That(filterCriteria.LastPlayed.Min, Is.EqualTo(DateTimeOffset.Now.AddDays(-50)).Within(TimeSpan.FromSeconds(5)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBothSidesDateQuery()
|
||||
{
|
||||
const string query = "played>3M played<1y6M";
|
||||
var filterCriteria = new FilterCriteria();
|
||||
FilterQueryParser.ApplyQueries(filterCriteria, query);
|
||||
Assert.That(filterCriteria.LastPlayed.Min, Is.Not.Null);
|
||||
Assert.That(filterCriteria.LastPlayed.Max, Is.Not.Null);
|
||||
// the parser internally references `DateTimeOffset.Now`, so to not make things too annoying for tests, just assume some tolerance
|
||||
// (irrelevant in proportion to the actual filter proscribed).
|
||||
Assert.That(filterCriteria.LastPlayed.Min, Is.EqualTo(DateTimeOffset.Now.AddYears(-1).AddMonths(-6)).Within(TimeSpan.FromSeconds(5)));
|
||||
Assert.That(filterCriteria.LastPlayed.Max, Is.EqualTo(DateTimeOffset.Now.AddMonths(-3)).Within(TimeSpan.FromSeconds(5)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
Loading…
Reference in New Issue
Block a user