public void Multiple_Order_By_Should_Convert_Successfully()
        {
            // Arrange
            var orderBy = "FirstName[asc],LastName[desc]";

            // Act
            var stringResults = new OrderByParser().Parse(orderBy);
            var typeResults   = new OrderByParser().ParseAs(orderBy, new TypeSearchConverter <object>());

            // Assert
            Assert.NotNull(stringResults);
            Assert.NotNull(typeResults);

            Assert.NotEmpty(stringResults);
            Assert.NotEmpty(typeResults.Criteria);

            Assert.Equal("FirstName", stringResults.ElementAt(0).Name);
            Assert.Equal(OrderByDirection.Ascending, stringResults.ElementAt(0).Direction);
            Assert.Equal("LastName", stringResults.ElementAt(1).Name);
            Assert.Equal(OrderByDirection.Descending, stringResults.ElementAt(1).Direction);

            Assert.Equal("FirstName", typeResults.Criteria.ElementAt(0).Name);
            Assert.Equal(SortDirection.Ascending, typeResults.Criteria.ElementAt(0).SortDirection);
            Assert.Equal("LastName", typeResults.Criteria.ElementAt(1).Name);
            Assert.Equal(SortDirection.Descending, typeResults.Criteria.ElementAt(1).SortDirection);
        }
        public void Single_Order_By_Should_Parse_Global_And_Local_Custom_Direction_Successfully()
        {
            // Arrange
            var orderBy        = "FirstName[up],LastName[down]";
            var globalOverride = new Dictionary <OrderByDirection, string>()
            {
                { OrderByDirection.Ascending, "up" }
            };
            var localOverride = new Dictionary <OrderByDirection, string>()
            {
                { OrderByDirection.Descending, "down" }
            };

            // Act
            var parseResults = new OrderByParser(globalOverride).Parse(orderBy, localOverride);

            // Assert
            Assert.NotNull(parseResults);
            Assert.NotEmpty(parseResults);

            Assert.Equal("FirstName", parseResults.ElementAt(0).Name);
            Assert.Equal(OrderByDirection.Ascending, parseResults.ElementAt(0).Direction);

            Assert.Equal("LastName", parseResults.ElementAt(1).Name);
            Assert.Equal(OrderByDirection.Descending, parseResults.ElementAt(1).Direction);
        }
        public void Single_Order_By_Parses_Successfully()
        {
            // Arrange
            var orderBy = "FirstName[asc]";

            // Act
            var parseResults = new OrderByParser().Parse(orderBy);

            // Assert
            Assert.NotNull(parseResults);
            Assert.NotEmpty(parseResults);
            Assert.Single(parseResults);
            Assert.Equal("FirstName", parseResults.ElementAt(0).Name);
            Assert.Equal(OrderByDirection.Ascending, parseResults.ElementAt(0).Direction);
        }
        public void Multiple_Order_By_Parses_Successfully()
        {
            // Arrange
            var orderBy = "FirstName[asc],LastName[desc],DateOfBirth[desc],Age[asc]";

            // Act
            var parseResults = new OrderByParser().Parse(orderBy);

            // Assert
            Assert.NotNull(parseResults);
            Assert.NotEmpty(parseResults);

            Assert.Equal("FirstName", parseResults.ElementAt(0).Name);
            Assert.Equal(OrderByDirection.Ascending, parseResults.ElementAt(0).Direction);

            Assert.Equal("LastName", parseResults.ElementAt(1).Name);
            Assert.Equal(OrderByDirection.Descending, parseResults.ElementAt(1).Direction);

            Assert.Equal("DateOfBirth", parseResults.ElementAt(2).Name);
            Assert.Equal(OrderByDirection.Descending, parseResults.ElementAt(2).Direction);

            Assert.Equal("Age", parseResults.ElementAt(3).Name);
            Assert.Equal(OrderByDirection.Ascending, parseResults.ElementAt(3).Direction);
        }