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); }
public void FilterById_NoIdProperty_Throws() { TestLookup <NoIdModel> lookup = new TestLookup <NoIdModel>(); LookupException exception = Assert.Throws <LookupException>(() => lookup.FilterById(null)); String expected = $"'{typeof (NoIdModel).Name}' type does not have property named 'Id', required for automatic id filtering."; String actual = exception.Message; 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_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_NoIdProperty_Throws() { TestLookup<NoIdModel> lookup = new TestLookup<NoIdModel>(); LookupException exception = Assert.Throws<LookupException>(() => lookup.FilterById(null)); String expected = $"'{typeof (NoIdModel).Name}' type does not have property named 'Id', required for automatic id filtering."; String actual = exception.Message; Assert.Equal(expected, actual); }