List() public method

public List ( int pageNo, int pageSize, bool>.Func filter = null ) : PageModel,
pageNo int
pageSize int
filter bool>.Func
return PageModel,
Example #1
0
    public void List_Should_Use_Paging_Filter()
    {
        var list = new List <ExpandoObject>();

        for (int i = 0; i < 50; i++)
        {
            dynamic item = new ExpandoObject();
            item.Title = i.ToString();
            list.Add(item);
        }

        var repository = new Mock();

        repository.Setup("List", null, list);

        var model = new PageModel();

        model.Repository = repository;
        model.List(1, 20, (p) => ((dynamic)p).Title.StartsWith("2"));

        Assert.AreEqual(1, model.Value.PageNo);
        Assert.AreEqual(20, model.Value.PageSize);

        IEnumerable <ExpandoObject> ret = model.Value.List;

        Assert.AreEqual(20, ret.Count()); //should be 11, if model handles the filter

        repository.Verify();
    }
Example #2
0
    public void List_Should_Use_Paging()
    {
        var repository = new Mock();
        repository.Setup("List", null);

        var model = new PageModel();
        model.Repository = repository;
        model.List(2, 20);

        Assert.AreEqual(2, model.Value.PageNo);
        Assert.AreEqual(20,model.Value.PageSize);

        repository.Verify();
    }
Example #3
0
    public void List_Should_Use_Paging()
    {
        var repository = new Mock();

        repository.Setup("List", null);

        var model = new PageModel();

        model.Repository = repository;
        model.List(2, 20);

        Assert.AreEqual(2, model.Value.PageNo);
        Assert.AreEqual(20, model.Value.PageSize);

        repository.Verify();
    }
Example #4
0
File: Tags.cs Project: yysun/Rabbit
    public static dynamic get_pages_by_tag(dynamic data)
    {
        var tag = data as string;
        dynamic list = new List<dynamic>();

        if (tag != null)
        {
            var model = new PageModel();
            list = model.List(1, 20, (p) =>
            {
                if (!p.HasProperty("Tags")) return false;
                object[] tags = ((dynamic)p).Tags;
                return tags == null ? false : tags.Any(t => t.Equals(tag));
            }).Value.List;
        }

        return list;
    }
Example #5
0
    public static dynamic get_pages_by_tag(dynamic data)
    {
        var     tag  = data as string;
        dynamic list = new List <dynamic>();

        if (tag != null)
        {
            var model = new PageModel();
            list = model.List(1, 20, (p) =>
            {
                if (!p.HasProperty("Tags"))
                {
                    return(false);
                }
                object[] tags = ((dynamic)p).Tags;
                return(tags == null ? false : tags.Any(t => t.Equals(tag)));
            }).Value.List;
        }

        return(list);
    }
Example #6
0
    public void List_Should_Use_Paging_Filter()
    {
        var list = new List<ExpandoObject>();
        for (int i = 0; i < 50; i++)
        {
            dynamic item = new ExpandoObject();
            item.Title = i.ToString();
            list.Add(item);
        }

        var repository = new Mock();
        repository.Setup("List", null, list);

        var model = new PageModel();
        model.Repository = repository;
        model.List(1, 20, (p)=>((dynamic)p).Title.StartsWith("2"));

        Assert.AreEqual(1, model.Value.PageNo);
        Assert.AreEqual(20, model.Value.PageSize);

        IEnumerable<ExpandoObject> ret = model.Value.List;
        Assert.AreEqual(20, ret.Count()); //should be 11, if model handles the filter

        repository.Verify();
    }