Пример #1
0
        public void ParseTestsAncCheckCount(string command, int outputCount, int conditionCount, int orderByCount)
        {
            DefaultSelectParser parser = new DefaultSelectParser();
            SelectInfo          info   = parser.Parse(command);

            Assert.AreEqual(outputCount, info.Fields.Count, "count of output");
            Assert.AreEqual(conditionCount, info.Conditions.Count, "count of condition");
            Assert.AreEqual(orderByCount, info.Orders.Count, "count of orderby");
        }
Пример #2
0
        public void ParseCommand_NameByIdIsMyid()
        {
            DefaultSelectParser parser = new DefaultSelectParser();
            SelectInfo          info   = parser.Parse("NameByIdIsMyid");

            Assert.AreEqual("Name", info.Fields[0]);

            Assert.AreEqual("Id", info.Conditions[0].Field);
            Assert.AreEqual("Is", info.Conditions[0].Operators);
            Assert.AreEqual(ConditionJoiners.Null, info.Conditions[0].JoinerToNext);
            Assert.AreEqual("Myid", info.Conditions[0].Parameter);
        }
Пример #3
0
        public void ParseTest_NameById()
        {
            string command             = "NameById";
            DefaultSelectParser parser = new DefaultSelectParser();
            SelectInfo          info   = parser.Parse(command);

            Assert.AreEqual(1, info.Fields.Count, "count of field should be 1");
            Assert.AreEqual("Name", info.Fields[0]);
            Assert.AreEqual(1, info.Conditions.Count, "count of condition should be 1");
            Assert.AreEqual("Id", info.Conditions[0].Field);
            Assert.AreEqual("", info.Conditions[0].Operators);
            Assert.AreEqual(0, info.Orders.Count);
        }
Пример #4
0
        public void ParseCommand_NameByIdIsMyidAndAgeGtMyageOrderbyId()
        {
            DefaultSelectParser parser = new DefaultSelectParser();
            SelectInfo          info   = parser.Parse("NameByIdIsMyidAndAgeGtMyageOrderbyId");

            Assert.AreEqual("Name", info.Fields[0]);

            Assert.AreEqual("Id", info.Conditions[0].Field);
            Assert.AreEqual("Is", info.Conditions[0].Operators);
            Assert.AreEqual(ConditionJoiners.And, info.Conditions[0].JoinerToNext);
            Assert.AreEqual("Myid", info.Conditions[0].Parameter);

            Assert.AreEqual("Age", info.Conditions[1].Field);
            Assert.AreEqual("Gt", info.Conditions[1].Operators);
            Assert.AreEqual(ConditionJoiners.Null, info.Conditions[1].JoinerToNext);
            Assert.AreEqual("Myage", info.Conditions[1].Parameter);

            Assert.AreEqual("Id", info.Orders[0].Field);
            Assert.AreEqual(OrderTypes.Asc, info.Orders[0].Type);
        }
Пример #5
0
        public void ParseCommand_NameAndIconByRegstertimeAndStateOrderbyRegtertimeDescId()
        {
            DefaultSelectParser parser = new DefaultSelectParser();
            SelectInfo          info   = parser.Parse("NameAndIconByRegstertimeAndStateOrderbyRegtertimeDescId");

            Assert.AreEqual("Name", info.Fields[0]);
            Assert.AreEqual("Icon", info.Fields[1]);

            Assert.AreEqual("Regstertime", info.Conditions[0].Field);
            Assert.AreEqual("", info.Conditions[0].Operators);
            Assert.AreEqual(ConditionJoiners.And, info.Conditions[0].JoinerToNext);

            Assert.AreEqual("State", info.Conditions[1].Field);
            Assert.AreEqual("", info.Conditions[1].Operators);
            Assert.AreEqual(ConditionJoiners.Null, info.Conditions[1].JoinerToNext);

            Assert.AreEqual("Regtertime", info.Orders[0].Field);
            Assert.AreEqual(OrderTypes.Desc, info.Orders[0].Type);

            Assert.AreEqual("Id", info.Orders[1].Field);
            Assert.AreEqual(OrderTypes.Asc, info.Orders[1].Type);
        }
Пример #6
0
        private SelectInfo GetInfoByCommand(string command)
        {
            DefaultSelectParser parser = new DefaultSelectParser();

            return(parser.Parse(command));
        }