Beispiel #1
0
        public static void WithSorting_By_Asc()
        {
            // arrange
            SearchOptions options = new SearchOptions(1, 10);

            options.SortField = "MyCustomField";
            options.SortMode  = SortMode.Asc;

            FakeFindFluent <SomeClass> findFluent = new FakeFindFluent <SomeClass>();

            // act
            var result           = findFluent.WithSorting(options);
            var resultAsFakeType = (FakeFindFluent <SomeClass>)result;

            // assert
            Assert.NotNull(result);
            Assert.Single(resultAsFakeType.SortValues);
            Assert.Equal("MyCustomField", resultAsFakeType.SortValues.First().Key);
            Assert.Equal(SortMode.Asc, resultAsFakeType.SortValues.First().Value);
        }
Beispiel #2
0
        public static void WithSorting_With_Empty_Field()
        {
            // arrange
            SearchOptions options = new SearchOptions
            {
                PageNumber = 1,
                PageSize   = 10,
                SortField  = "",
                SortMode   = SortMode.Asc
            };

            FakeFindFluent <SomeClass> findFluent = new FakeFindFluent <SomeClass>();

            // act
            var result           = findFluent.WithSorting(options);
            var resultAsFakeType = (FakeFindFluent <SomeClass>)result;

            // assert
            Assert.NotNull(result);
            Assert.Null(resultAsFakeType.SortValues);
        }
Beispiel #3
0
        public static void WithSorting_By_Desc()
        {
            // arrange
            SearchOptions options = new SearchOptions
            {
                PageNumber = 1,
                PageSize   = 10,
                SortField  = "MyCustomField2",
                SortMode   = SortMode.Desc
            };

            FakeFindFluent <SomeClass> findFluent = new FakeFindFluent <SomeClass>();

            // act
            var result           = findFluent.WithSorting(options);
            var resultAsFakeType = (FakeFindFluent <SomeClass>)result;

            // assert
            Assert.NotNull(result);
            Assert.Single(resultAsFakeType.SortValues);
            Assert.Equal("MyCustomField2", resultAsFakeType.SortValues.First().Key);
            Assert.Equal(SortMode.Desc, resultAsFakeType.SortValues.First().Value);
        }
Beispiel #4
0
        public static void WithPaging_Calculated()
        {
            // arrange
            SearchOptions options = new SearchOptions
            {
                PageNumber = 4,
                PageSize   = 6,
                SortField  = "MyCustomField2",
                SortMode   = SortMode.Desc
            };

            FakeFindFluent <SomeClass> findFluent = new FakeFindFluent <SomeClass>();

            // act
            var result           = findFluent.WithPaging(options);
            var resultAsFakeType = (FakeFindFluent <SomeClass>)result;

            // assert
            Assert.NotNull(result);
            Assert.NotNull(resultAsFakeType.LimitValue);
            Assert.NotNull(resultAsFakeType.SkipValue);
            Assert.Equal(18, resultAsFakeType.SkipValue);
            Assert.Equal(6, resultAsFakeType.LimitValue);
        }