public void RemoveExpressionTest()
        {
            var eCollector = new ExpressionCollector <User>();

            eCollector.AddExpression(new ExpressionAdderModel <User>
            {
                Expression = c => c.Name == "123",
                CurrentTypeOfExpression = ExpressionType.AndAlso
            });
            eCollector.AddExpression(new ExpressionAdderModel <User>
            {
                Expression = c => c.Login.Contains("P"),
                CurrentTypeOfExpression = ExpressionType.AndAlso
            });
            eCollector.AddExpression(new ExpressionAdderModel <User>
            {
                Expression = c => !c.ForTest,
                CurrentTypeOfExpression = ExpressionType.OrElse
            });
            eCollector.RemoveExpression(new ExpressionAdderModel <User>
            {
                Expression = c => c.Name == "123",
                CurrentTypeOfExpression = ExpressionType.AndAlso
            });
            Assert.AreEqual(true, eCollector.CurrentListOfExpression.Count == 2);
        }
        public void CollectTest()
        {
            var eCollector = new ExpressionCollector <UserDto>();

            eCollector.AddExpression(new ExpressionAdderModel <UserDto>
            {
                Expression = c => c.FirstName == "123",
                CurrentTypeOfExpression = ExpressionType.AndAlso
            });
            eCollector.AddExpression(new ExpressionAdderModel <UserDto>
            {
                Expression = c => c.FirstLogin.Contains("P"),
                CurrentTypeOfExpression = ExpressionType.AndAlso
            });
            eCollector.AddExpression(new ExpressionAdderModel <UserDto>
            {
                Expression = c => !c.ForTest,
                CurrentTypeOfExpression = ExpressionType.Or
            });
            var resuylt = eCollector.Collect();

            Assert.AreEqual(typeof(bool), resuylt.Body.MaybeAs <BinaryExpression>().Bind(c => c.Left.Type).GetOrDefault(null));

            var lstOfUser = new List <User>
            {
                new User
                {
                    Login        = "******",
                    Name         = "123",
                    RegisterDate = DateTime.Now,
                    ForTest      = false
                },
                new User
                {
                    Login        = "******",
                    Name         = "Name",
                    RegisterDate = DateTime.Today,
                    ForTest      = true
                }
            };

            var result = GetCurrentUser(resuylt, lstOfUser).ToList();

            Assert.IsNotNull(result);
            Assert.AreEqual(true, result.Any());
            Assert.AreEqual("Petia", result[0].Login);
        }
        public void SimpleCollectTest()
        {
            var eCollector = new ExpressionCollector <UserDto>();

            eCollector.AddExpression(new ExpressionAdderModel <UserDto>
            {
                Expression = c => c.FirstName == "123",
                CurrentTypeOfExpression = ExpressionType.AndAlso
            });
            var resuylt = eCollector.Collect();

            Assert.AreEqual(typeof(string), resuylt.Body.MaybeAs <BinaryExpression>().Bind(c => c.Left.Type).GetOrDefault(null));
        }