示例#1
0
        public void FilterById_Number()
        {
            List<NumericIdModel> models = new List<NumericIdModel>();
            for (Int32 i = 0; i < 100; i++) models.Add(new NumericIdModel { Id = i });
            MvcLookupProxy<NumericIdModel> lookup = new MvcLookupProxy<NumericIdModel>();

            lookup.CurrentFilter.Id = "9.0";

            IEnumerable<NumericIdModel> actual = lookup.BaseFilterById(models.AsQueryable());
            IEnumerable<NumericIdModel> expected = models.Where(model => model.Id == 9);

            Assert.Equal(expected, actual);
        }
示例#2
0
        public void FilterById_NotNumericId_Throws()
        {
            MvcLookupProxy<NonNumericIdModel> lookup = new MvcLookupProxy<NonNumericIdModel>();

            lookup.CurrentFilter.Id = "9";

            LookupException exception = Assert.Throws<LookupException>(() => lookup.BaseFilterById(lookup.BaseGetModels()));

            String expected = String.Format("'{0}.Id' can not be filtered by using '9' value, because it's not a string nor a number.", typeof(NonNumericIdModel).Name);
            String actual = exception.Message;

            Assert.Equal(expected, actual);
        }
示例#3
0
        public void FilterById_NoIdProperty_Throws()
        {
            MvcLookupProxy<NoIdModel> lookup = new MvcLookupProxy<NoIdModel>();

            LookupException exception = Assert.Throws<LookupException>(() => lookup.BaseFilterById(lookup.BaseGetModels()));

            String expected = String.Format("'{0}' type does not have property named 'Id'.", typeof(NoIdModel).Name);
            String actual = exception.Message;

            Assert.Equal(expected, actual);
        }