Exemplo n.º 1
0
        public void CompareDict()
        {
            TaskQueue.TQItemSelector sel = new TaskQueue.TQItemSelector("field1", TaskQueue.TQItemSelectorSet.Ascending)
                                           .Rule("field2", TaskQueue.TQItemSelectorSet.Descending);
            SomeExtMessage inst = new SomeExtMessage()
            {
                field1 = 5,
                field2 = 15
            };

            TaskQueue.Providers.TaskMessage.InternalComparableDictionary cmp = (TaskQueue.Providers.TaskMessage.InternalComparableDictionary)
                                                                               TaskQueue.Providers.TaskMessage.MakeComparatorDictionary(sel);
            SomeExtMessage inst_CE = new SomeExtMessage()
            {
                field1 = 5,
                field2 = 18
            };
            SomeExtMessage inst_CL = new SomeExtMessage()
            {
                field1 = 4,
                field2 = 18
            };

            Assert.AreEqual(cmp(inst.GetHolder(), inst_CE.GetHolder()), 1);
            Assert.AreEqual(cmp(inst.GetHolder(), inst_CL.GetHolder()), 1);
            Assert.AreEqual(cmp(inst_CL.GetHolder(), inst_CE.GetHolder()), -1);
        }
Exemplo n.º 2
0
        public void CheckDict()
        {
            TaskQueue.TQItemSelector sel = new
                                           TaskQueue.TQItemSelector("field1", TaskQueue.TQItemSelectorSet.Ascending)
                                           .Rule("field2", 15L, true);
            SomeExtMessage inst = new SomeExtMessage()
            {
                field1 = 5,
                field2 = 15
            };

            TaskQueue.Providers.TaskMessage.InternalCheckDictionary chk = (TaskQueue.Providers.TaskMessage.InternalCheckDictionary)
                                                                          TaskQueue.Providers.TaskMessage.MakeCheckerDictionary(sel);
            SomeExtMessage inst_CE = new SomeExtMessage()
            {
                field1 = 5,
                field2 = 18
            };

            Assert.AreEqual(chk(inst.GetHolder()), true);
            Assert.AreEqual(chk(inst_CE.GetHolder()), false);

            Assert.AreEqual(chk(new Dictionary <string, object>()
            {
                { "field1", 5 }, { "field2", 15 }
            }), true);
            Assert.AreEqual(chk(new Dictionary <string, object>()
            {
                { "field1", 5 }
            }), false);
        }
Exemplo n.º 3
0
        public void CompareVMap()
        {
            TaskQueue.TQItemSelector sel = new TaskQueue.TQItemSelector("field1", TaskQueue.TQItemSelectorSet.Descending)
                                           .Rule("field2", TaskQueue.TQItemSelectorSet.Ascending);
            SomeExtMessage inst = new SomeExtMessage()
            {
                field1 = 5,
                field2 = 15
            };

            TaskQueue.Providers.TaskMessage.InternalComparableValueMap cmp =
                TaskQueue.Providers.TaskMessage.MakeComparatorValueMap(sel);
            SomeExtMessage inst_CE = new SomeExtMessage()
            {
                field1 = 6,
                field2 = 15
            };
            SomeExtMessage inst_CL = new SomeExtMessage()
            {
                field1 = 4,
                field2 = 18
            };

            TaskQueue.Providers.TaskMessage defmsg = new TaskQueue.Providers.TaskMessage("X");
            Assert.AreEqual(cmp(inst.GetValueMap(sel), inst_CE.GetValueMap(sel)),
                            TaskQueue.Providers.TaskMessage.CompareWithSelector(inst.GetHolder(), inst_CE.GetHolder(), sel));

            Assert.AreEqual(cmp(inst.GetValueMap(sel), inst_CL.GetValueMap(sel)),
                            TaskQueue.Providers.TaskMessage.CompareWithSelector(inst.GetHolder(), inst_CL.GetHolder(), sel));

            Assert.AreEqual(cmp(inst_CL.GetValueMap(sel), inst_CE.GetValueMap(sel)),
                            TaskQueue.Providers.TaskMessage.CompareWithSelector(inst_CL.GetHolder(), inst_CE.GetHolder(), sel));

            Assert.AreEqual(cmp(defmsg.GetValueMap(sel), inst_CE.GetValueMap(sel)),
                            TaskQueue.Providers.TaskMessage.CompareWithSelector(defmsg.GetHolder(), inst_CE.GetHolder(), sel));
        }
Exemplo n.º 4
0
        public void CheckDict()
        {
            TaskQueue.TQItemSelector sel = new
                TaskQueue.TQItemSelector("field1", TaskQueue.TQItemSelectorSet.Ascending)
                .Rule("field2", 15L, true);
            SomeExtMessage inst = new SomeExtMessage()
            {
                field1 = 5,
                field2 = 15
            };
            TaskQueue.Providers.TaskMessage.InternalCheckDictionary chk = (TaskQueue.Providers.TaskMessage.InternalCheckDictionary)
                TaskQueue.Providers.TaskMessage.MakeCheckerDictionary(sel);
            SomeExtMessage inst_CE = new SomeExtMessage()
            {
                field1 = 5,
                field2 = 18
            };

            Assert.AreEqual(chk(inst.GetHolder()), true);
            Assert.AreEqual(chk(inst_CE.GetHolder()), false);

            Assert.AreEqual(chk(new Dictionary<string, object>() { { "field1", 5 }, { "field2", 15 } }), true);
            Assert.AreEqual(chk(new Dictionary<string, object>() { { "field1", 5 } }), false);
        }
Exemplo n.º 5
0
        public void CompareDict2()
        {
            TaskQueue.TQItemSelector sel = new TaskQueue.TQItemSelector("field1", TaskQueue.TQItemSelectorSet.Descending)
                .Rule("field2", TaskQueue.TQItemSelectorSet.Ascending);
            SomeExtMessage inst = new SomeExtMessage()
            {
                field1 = 5,
                field2 = 15
            };
            TaskQueue.Providers.TaskMessage.InternalComparableDictionary cmp = (TaskQueue.Providers.TaskMessage.InternalComparableDictionary)
                TaskQueue.Providers.TaskMessage.MakeComparatorDictionary(sel);
            SomeExtMessage inst_CE = new SomeExtMessage()
            {
                field1 = 6,
                field2 = 15
            };
            SomeExtMessage inst_CL = new SomeExtMessage()
            {
                field1 = 4,
                field2 = 18
            };

            Assert.AreEqual(cmp(inst.GetHolder(), inst_CE.GetHolder()),
                TaskQueue.Providers.TaskMessage.CompareWithSelector(inst.GetHolder(), inst_CE.GetHolder(), sel));

            Assert.AreEqual(cmp(inst.GetHolder(), inst_CL.GetHolder()),
                TaskQueue.Providers.TaskMessage.CompareWithSelector(inst.GetHolder(), inst_CL.GetHolder(), sel));

            Assert.AreEqual(cmp(inst_CL.GetHolder(), inst_CE.GetHolder()),
                TaskQueue.Providers.TaskMessage.CompareWithSelector(inst_CL.GetHolder(), inst_CE.GetHolder(), sel));
        }