public void SupportedOperationsForDates()
        {
            OperationHelper.LoadDefaultOperations();
            var definitions    = new OperationHelper();
            var dateOperations = new List <string> {
                "Between", "EqualTo", "NotEqualTo", "GreaterThan", "GreaterThanOrEqualTo",
                "LessThan", "LessThanOrEqualTo"
            };
            var operations = definitions.SupportedOperations(typeof(DateTime));

            Assert.That(operations.Select(o => o.Name), Is.EquivalentTo(dateOperations));
        }
        public void LoadCustomOperation()
        {
            var helper          = new OperationHelper();
            var operationsCount = helper.Operations.Count();
            var operations      = new List <IOperation> {
                new ThisDay()
            };

            helper.LoadOperations(operations);

            Assert.That(helper.Operations.Select(o => o.Name), Does.Contain(operations.Single().Name));
            Assert.That(helper.Operations.Count, Is.EqualTo(operationsCount + 1));

            OperationHelper.LoadDefaultOperations();
        }
        public void OverwritingOperations()
        {
            var helper          = new OperationHelper();
            var operationsCount = helper.Operations.Count();
            var operations      = new List <IOperation> {
                new EqualTo()
            };

            helper.LoadOperations(operations, true);

            Assert.That(helper.Operations.Where(o => o.Name == "EqualTo").Count, Is.EqualTo(2));
            Assert.That(helper.Operations.First(o => o.Name == "EqualTo" && o.Active).GetType().Namespace, Is.EqualTo("ExpressionBuilder.Test.CustomOperations"));
            Assert.That(helper.Operations.Count, Is.EqualTo(operationsCount + 1));

            OperationHelper.LoadDefaultOperations();
        }
        public void LoadingSameCustomOperationTwice_Failure()
        {
            var helper          = new OperationHelper();
            var operationsCount = helper.Operations.Count();
            var operations      = new List <IOperation> {
                new ThisDay(), new ThisDay(), new EqualTo()
            };

            helper.LoadOperations(operations);

            Assert.That(helper.Operations.Where(o => o.Name == operations.First().Name).Count, Is.EqualTo(1));
            Assert.That(helper.Operations.Single(o => o.Name == "EqualTo").GetType().Namespace, Is.EqualTo("ExpressionBuilder.Operations"));
            Assert.That(helper.Operations.Count, Is.EqualTo(operationsCount + 1));

            OperationHelper.LoadDefaultOperations();
        }
        public void GetOverwrittenOperationByName()
        {
            var helper     = new OperationHelper();
            var operations = new List <IOperation> {
                new EqualTo()
            };

            helper.LoadOperations(operations, true);

            var operation = helper.GetOperationByName("EqualTo");

            Assert.That(operation.Name, Is.EqualTo("EqualTo"));
            Assert.That(operation.Active, Is.True);
            Assert.That(operation.GetType().Namespace, Is.EqualTo("ExpressionBuilder.Test.CustomOperations"));

            OperationHelper.LoadDefaultOperations();
        }