public void FilterBySelected_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.FilterBySelected(testLookup.GetModels(), new List <String> { "9", "10" }); IQueryable <Int32Model> expected = testLookup.GetModels().Where(model => new[] { 9, 10 }.Contains(model.Value)); Assert.Equal(expected, actual); }
public void FilterById_Number() { TestLookup <NumericModel> lookup = new TestLookup <NumericModel>(); for (Int32 i = 0; i < 20; i++) { lookup.Models.Add(new NumericModel { Id = i }); } lookup.Filter.Id = "9.0"; IQueryable <NumericModel> expected = lookup.GetModels().Where(model => model.Id == 9); IQueryable <NumericModel> actual = lookup.FilterById(lookup.GetModels()); Assert.Equal(expected, actual); }
public void FilterByNotIds_Guids() { TestLookup <GuidModel> testLookup = new TestLookup <GuidModel>(); for (Int32 i = 0; i < 20; i++) { testLookup.Models.Add(new GuidModel { Id = Guid.NewGuid() }); } List <String> ids = new List <String> { testLookup.Models[4].Id.ToString(), testLookup.Models[9].Id.ToString() }; IQueryable <GuidModel> expected = testLookup.GetModels().Where(model => !ids.Contains(model.Id.ToString())); IQueryable <GuidModel> actual = testLookup.FilterByNotIds(testLookup.GetModels(), ids); Assert.Equal(expected, actual); }
public void FilterBySearch_SkipsEmpty(String search) { lookup.Filter.Search = search; IQueryable <TestModel> actual = lookup.FilterBySearch(lookup.GetModels()); IQueryable <TestModel> expected = lookup.GetModels(); Assert.Equal(expected, actual); }
public void FilterById_Number() { TestLookup<NumericModel> lookup = new TestLookup<NumericModel>(); for (Int32 i = 0; i < 20; i++) lookup.Models.Add(new NumericModel { Id = i }); lookup.Filter.Id = "9.0"; IQueryable<NumericModel> expected = lookup.GetModels().Where(model => model.Id == 9); IQueryable<NumericModel> actual = lookup.FilterById(lookup.GetModels()); Assert.Equal(expected, actual); }
public void FilterById_String() { lookup.Filter.Id = "9I"; IQueryable <TestModel> expected = lookup.GetModels().Where(model => model.Id == lookup.Filter.Id); IQueryable <TestModel> actual = lookup.FilterById(lookup.GetModels()); Assert.Equal(expected, actual); }