public void FilterByCheckIds_String() { List <String> ids = new List <String> { "9I", "10I" }; IQueryable <TestModel> actual = lookup.FilterByCheckIds(lookup.GetModels(), ids); IQueryable <TestModel> expected = lookup.GetModels().Where(model => ids.Contains(model.Id !)); Assert.Equal(expected, actual); }
public void FilterByCheckIds_NoIdProperty_Throws() { TestLookup <NoIdModel> testLookup = new TestLookup <NoIdModel>(); LookupException exception = Assert.Throws <LookupException>(() => testLookup.FilterByCheckIds(Array.Empty <NoIdModel>().AsQueryable(), Array.Empty <String>())); String expected = $"'{typeof(NoIdModel).Name}' type does not have key or property named 'Id', required for automatic id filtering."; String actual = exception.Message; Assert.Equal(expected, actual); }
public void FilterByCheckIds_NumberKey() { TestLookup <Int32Model> testLookup = new TestLookup <Int32Model>(); for (Int32 i = 0; i < 20; i++) { testLookup.Models.Add(new Int32Model { Value = i }); } IQueryable <Int32Model> actual = testLookup.FilterByCheckIds(testLookup.GetModels(), new List <String> { "9", "10" }); IQueryable <Int32Model> expected = testLookup.GetModels().Where(model => new[] { 9, 10 }.Contains(model.Value)); Assert.Equal(expected, actual); }