dotnet-dynamic-query/PoweredSoft.DynamicQuery.Test/CriteriaTests.cs

29 lines
924 B
C#
Raw Normal View History

2018-10-22 21:21:14 -04:00
using System;
2018-10-22 22:05:23 -04:00
using System.Collections.Generic;
2018-10-22 21:21:14 -04:00
using System.Linq;
using Microsoft.EntityFrameworkCore;
using PoweredSoft.DynamicQuery.Test.Mock;
using Xunit;
namespace PoweredSoft.DynamicQuery.Test
{
public class CriteriaTests
{
[Fact]
public void TestEmptyCriteria()
{
2018-10-22 22:05:23 -04:00
MockContextFactory.SeedAndTestContextFor("CriteriaTests_TestEmptyCriteria", TestSeeders.SimpleSeedScenario, ctx =>
2018-10-22 21:21:14 -04:00
{
var resultShouldMatch = ctx.Items.ToList();
var queryable = ctx.Items.AsQueryable();
2018-10-22 22:05:23 -04:00
2018-10-22 21:21:14 -04:00
// query handler that is empty should be the same as running to list.
var criteria = new QueryCriteria();
var queryHandler = new QueryHandler();
var result = queryHandler.Execute(queryable, criteria);
2018-10-22 22:05:23 -04:00
Assert.Equal(resultShouldMatch, result.Data);
});
2018-10-22 21:21:14 -04:00
}
}
}