public void CollectionAnyContainsSingleItem() { var item = "Bread - Dark Rye, Loaf"; DataAssert.SameSequence(DataAssert.Data.SearchQuery <Listing>().Where(w => AzureSearchMethods.ContainsAny(w.Tags, item)).ToList(), DataAssert.Data.Memory <Listing>().Where(w => w.Tags.Any(q => q.Contains(item))).ToList()); }
public async void ToListAsyncReturnsCorrectResults() { var memory = DataAssert.Data.Memory <Listing>().Where(w => w.Price > MiddlePrice).OrderBy(w => w.Price).ToList(); var search = await DataAssert.Data.SearchQuery <Listing>().Where(w => w.Price > MiddlePrice).OrderBy(w => w.Price).ToListAsync(); DataAssert.SameSequence(memory, search); }
public void CollectionAnyContainsManyItems() { var items = new[] { "Bread - Dark Rye, Loaf", "Beef - Striploin Aa" }; DataAssert.SameSequence(DataAssert.Data.SearchQuery <Listing>().Where(w => AzureSearchMethods.ContainsAny(w.Tags, items)).ToList(), DataAssert.Data.Memory <Listing>().Where(w => w.Tags.Any(q => items.Contains(q))).ToList()); }
public void CollectionNotAllContainsSingleItem() { var item = "Bread - Dark Rye, Loaf"; DataAssert.SameSequence( DataAssert.Data.SearchQuery <Listing>() .Where(w => !AzureSearchMethods.ContainsAll(w.Tags, item)).OrderBy(q => q.CreatedAt).ToList(), DataAssert.Data.Memory <Listing>().Where(w => w.Tags.All(q => !q.Contains(item))).OrderBy(q => q.CreatedAt).ToList()); }
public void CollectionNotAllContainsManyConstant() { DataAssert.SameSequence( DataAssert.Data.SearchQuery <Listing>().Where(w => !AzureSearchMethods .ContainsAll(w.Tags, new[] { "Bread - Dark Rye, Loaf", "Beef - Striploin Aa" })).OrderBy(q => q.CreatedAt).ToList(), DataAssert.Data.Memory <Listing>().Where(w => w.Tags .All(q => !new[] { "Bread - Dark Rye, Loaf", "Beef - Striploin Aa" }.Contains(q))).OrderBy(q => q.CreatedAt).ToList() ); }
public void SpatialFilterByDistance() { DataAssert.SameSequence( DataAssert.Data.SearchQuery <Listing>() .Where(w => AzureSearchMethods.Distance(w.Place, filterPoint) < 10000).OrderBy(q => q.CreatedAt).ToList(), DataAssert.Data.Memory <Listing>() .Where(w => w.Place != null && SpatialHelper.GetDistance(w.Place, filterPoint, DistanceUnit.Kilometers) < 10000) .OrderBy(q => q.CreatedAt) .ToList() ); }
public void SpatialOrderByDistance() { DataAssert.SameSequence( DataAssert.Data.SearchQuery <Listing>() .Where(q => q.Place != null) .OrderBy(w => AzureSearchMethods.Distance(w.Place, filterPoint)).Take(10).ToList(), DataAssert.Data.Memory <Listing>() .Where(q => q.Place != null) .OrderBy(w => SpatialHelper.GetDistance(w.Place, filterPoint, DistanceUnit.Kilometers)) .Take(10) .ToList() ); }
public void SpatialOrderByDescendingDistance() { var expect = DataAssert.Data.SearchQuery <Listing>() .Where(q => q.Place != null) .OrderByDescending(w => AzureSearchMethods.Distance(w.Place, filterPoint)).Take(10).ToList(); var actual = DataAssert.Data.Memory <Listing>() .Where(q => q.Place != null) .OrderByDescending(w => SpatialHelper.GetDistance(w.Place, filterPoint, double.MaxValue, DistanceUnit.Kilometers)) .Take(10) .ToList(); DataAssert.SameSequence( expect, actual ); }
public void CollectionAnySingleConstant() { DataAssert.SameSequence(DataAssert.Data.SearchQuery <Listing>().Where(w => AzureSearchMethods.ContainsAny(w.Tags, "Bread - Dark Rye, Loaf")).ToList(), DataAssert.Data.Memory <Listing>().Where(w => w.Tags.Any(q => q.Contains("Bread - Dark Rye, Loaf"))).ToList()); }