Ejemplo n.º 1
0
        public void TestWhereIfNotEmpty()
        {
            var list = TestSampleCreate.GetList();

            Assert.Equal(2, list.WhereIfNotEmpty(t => t.TestValue.Contains("СÃ÷")).Count());
            Assert.Equal(5, list.WhereIfNotEmpty(t => t.TestValue.Contains("")).Count());
        }
Ejemplo n.º 2
0
        public void TestWhereIf()
        {
            var list = TestSampleCreate.GetList();

            Assert.Equal(2, list.WhereIf(t => t.TestValue.Contains("СÃ÷"), true).Count());
            Assert.Equal(5, list.WhereIf(t => t.TestValue.Contains("СÃ÷"), false).Count());
        }
Ejemplo n.º 3
0
        public void TestPage()
        {
            var list = TestSampleCreate.GetList();

            Assert.Equal(2, list.Page(new Pager(1, 2)).Count);
            Assert.True(list.Page(new Pager(3, 2)).Count == 1);
            Assert.True(list.Page(new Pager(10, 2)).Count == 0);
        }
Ejemplo n.º 4
0
        public void TestDistinct()
        {
            var list = TestSampleCreate.GetList();

            Assert.Equal(2, list.Distinct(t => t.GuidValue).Count());
            Assert.Equal(3, list.Distinct(t => t.TestValue).Count());
            Assert.Equal(5, list.Distinct(t => t.NullableIntValue).Count());
            Assert.True(list.Distinct(t => t.EnumValue).Count() == 1);
        }
Ejemplo n.º 5
0
        public void TestBetween()
        {
            var list = TestSampleCreate.GetList();

            Assert.Equal(3, list.Between(t => t.IntValue, 2, (int?)null).Count);
            Assert.Equal(4, list.Between(t => t.DoubleValue, (double)0, (double)3).Count);
            Assert.True(list.Between(t => t.DecimalValue, (decimal)6, (decimal?)null).Count == 0);
            var date = new DateTime(2002, 1, 1, 1, 1, 1);

            Assert.True(list.Between(t => t.DateValue, date, date).Count == 1);
        }
Ejemplo n.º 6
0
        public void TestToPagerList()
        {
            var list = TestSampleCreate.GetList();
            var pag1 = list.ToPagerList(new Pager(1, 2));

            Assert.Equal(5, pag1.TotalCount);
            Assert.Equal(3, pag1.PageCount);
            Assert.Equal(2, pag1.Data.Count);

            var pag2 = list.ToPagerList(new Pager(1, 10));

            Assert.Equal(5, pag2.TotalCount);
            Assert.Equal(1, pag2.PageCount);
            Assert.Equal(5, pag2.Data.Count);

            var pag3 = list.ToPagerList(new Pager(10, 10));

            Assert.Equal(5, pag3.TotalCount);
            Assert.Equal(1, pag3.PageCount);
            Assert.True(pag3.Data.Count == 0);
        }