public void Parse_WhenOnePropertyLambdaIsPassed_ExactlyOneSortingNodeIsReturned()
		{
			var lambda = new OrderByAscExpression(Reflect<MyClass>.LambdaFrom(m => m.String1));

			var parsedLambda = new OrderByParser().Parse(new[] { lambda });

			Assert.AreEqual(1, parsedLambda.Nodes.Length);
			Assert.IsInstanceOf(typeof(SortingNode), parsedLambda.Nodes[0]);
		}
		public void Parse_WhenNonMemberExpression_ThrowsException()
		{
			var parser = new OrderByParser();
			var nonMemberExpression = new OrderByAscExpression(Reflect<MyClass>.BoolExpressionFrom(m => m.Int1 == 32));

			var ex = Assert.Throws<NCoreException>(() => parser.Parse(new[] { nonMemberExpression }));

			Assert.AreEqual("No MemberExpression found in expression: '(m.Int1 == 32)'.", ex.Message);
		}
		public void Parse_WhenTwoPropertyLambdasArePassed_ExactlyTwoSortingNodeIsReturned()
		{
			var lambda1 = new OrderByAscExpression(Reflect<MyClass>.LambdaFrom(m => m.String1));
			var lambda2 = new OrderByDescExpression(Reflect<MyClass>.LambdaFrom(m => m.Int1));

			var parsedLambda = new OrderByParser().Parse(new OrderByExpression[] { lambda1, lambda2 });

			Assert.AreEqual(2, parsedLambda.Nodes.Length);
			Assert.IsInstanceOf(typeof(SortingNode), parsedLambda.Nodes[0]);
			Assert.IsInstanceOf(typeof(SortingNode), parsedLambda.Nodes[1]);
		}
		public ExpressionParsers(IDataTypeConverter dataTypeConverter)
		{
			IncludeParser = new IncludeParser(dataTypeConverter);
			WhereParser = new WhereParser(dataTypeConverter);
			OrderByParser = new OrderByParser(dataTypeConverter);
		}
 public ExpressionParsers(IDataTypeConverter dataTypeConverter)
 {
     WhereParser   = new WhereParser(dataTypeConverter);
     OrderByParser = new OrderByParser(dataTypeConverter);
 }
		public void Parse_WhenNestedLambda_MemberPathReflectsHierarchy()
		{
			var lambda = new OrderByAscExpression(Reflect<MyClass>.LambdaFrom(m => m.Child.String1));

			var parsedLambda = new OrderByParser().Parse(new[] { lambda });

			var node = (SortingNode)parsedLambda.Nodes[0];
			Assert.AreEqual("Child.String1", node.MemberPath);
		}
		public void Parse_WhenFirstLevelLambda_MemberPathIsPropertyName()
		{
			var lambda = new OrderByAscExpression(Reflect<MyClass>.LambdaFrom(m => m.String1));

			var parsedLambda = new OrderByParser().Parse(new[] { lambda });

			var node = (SortingNode)parsedLambda.Nodes[0];
			Assert.AreEqual("String1", node.MemberPath);
		}
		public void Parse_WhenAscAndDescExpressionOnSameMember_SortingDirectionBecomesBothAscAndDescInCorrectOrder()
		{
			var lambda1 = new OrderByAscExpression(Reflect<MyClass>.LambdaFrom(m => m.String1));
			var lambda2 = new OrderByDescExpression(Reflect<MyClass>.LambdaFrom(m => m.String1));

			var parsedLambda = new OrderByParser()
				.Parse(new OrderByExpression [] { lambda1, lambda2 });

			Assert.AreEqual(2, parsedLambda.Nodes.Length);

			var node1 = (SortingNode)parsedLambda.Nodes[0];
			Assert.AreEqual(SortDirections.Asc, node1.Direction);

			var node2 = (SortingNode)parsedLambda.Nodes[1];
			Assert.AreEqual(SortDirections.Desc, node2.Direction);
		}
		public void Parse_WhenDescExpression_SortingDirectionBecomesDesc()
		{
			var lambda = new OrderByDescExpression(Reflect<MyClass>.LambdaFrom(m => m.String1));

			var parsedLambda = new OrderByParser().Parse(new[] { lambda });

			var node = (SortingNode)parsedLambda.Nodes[0];
			Assert.AreEqual(SortDirections.Desc, node.Direction);
		}