Esempio n. 1
0
            public static void TestDataSourceDttm()
            {
                TestAzLogFilterValueMock mock = new TestAzLogFilterValueMock();

                mock.m_dttmStart = DateTime.Parse("5/5/1995");
                mock.m_dttmEnd   = DateTime.Parse("5/5/1995 3:00");
                mock.m_dttmRow   = DateTime.Parse("5/5/1995 1:30");

                AzLogFilterValue azlfvLHS = new AzLogFilterValue(ValueType.DateTime, DataSource.DttmStart, AzLogEntry.LogColumn.Nil);

                Assert.AreEqual(true, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995")), mock));
                Assert.AreEqual(true, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/4/1995 19:00")), mock));
                Assert.AreEqual(false, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995 1:00")), mock));
                Assert.AreEqual(false, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995 3:00")), mock));
                Assert.AreEqual(false, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995 4:00")), mock));

                azlfvLHS = new AzLogFilterValue(ValueType.DateTime, DataSource.DttmEnd, AzLogEntry.LogColumn.Nil);

                Assert.AreEqual(true, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995")), mock));
                Assert.AreEqual(true, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/4/1995 19:00")), mock));
                Assert.AreEqual(true, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995 1:00")), mock));
                Assert.AreEqual(true, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995 3:00")), mock));
                Assert.AreEqual(false, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995 4:00")), mock));

                azlfvLHS = new AzLogFilterValue(ValueType.DateTime, DataSource.DttmRow, AzLogEntry.LogColumn.Nil);

                Assert.AreEqual(true, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995")), mock));
                Assert.AreEqual(true, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/4/1995 19:00")), mock));
                Assert.AreEqual(true, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995 1:00")), mock));
                Assert.AreEqual(false, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995 3:00")), mock));
                Assert.AreEqual(false, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995 4:00")), mock));
            }
Esempio n. 2
0
            public static void TestStringTypes(string sLHS, string sRHS, AzLogFilterCondition.CmpOp cmpop, bool fExpected)
            {
                AzLogFilterValue azlfvLHS = new AzLogFilterValue(sLHS);
                AzLogFilterValue azlfvRHS = new AzLogFilterValue(sRHS);

                Assert.AreEqual(fExpected, azlfvLHS.FEvaluate(cmpop, azlfvRHS, null));
            }
Esempio n. 3
0
            public static void TestCmpOpGenericFromCmpOp(AzLogFilterCondition.CmpOp cmpopIn, AzLogFilterCondition.CmpOp cmpopExpected, bool fNoCaseExpected)
            {
                bool fNoCase;

                Assert.AreEqual(cmpopExpected, AzLogFilterValue.CmpOpGenericFromCmpOp(cmpopIn, out fNoCase));
                Assert.AreEqual(fNoCaseExpected, fNoCase);
            }
Esempio n. 4
0
            public static void TestDateTimeTypes(string sDttmLHS, string sDttmRHS, AzLogFilterCondition.CmpOp cmpop,
                                                 bool fExpected)
            {
                AzLogFilterValue azlfvLHS = new AzLogFilterValue(DateTime.Parse(sDttmLHS));
                AzLogFilterValue azlfvRHS = new AzLogFilterValue(DateTime.Parse(sDttmRHS));

                Assert.AreEqual(fExpected, azlfvLHS.FEvaluate(cmpop, azlfvRHS, null));
            }
Esempio n. 5
0
            public static void TestDataSourceColumn()
            {
                TestAzLogFilterValueMock mock = new TestAzLogFilterValueMock();

                mock.m_mpColumnValue = new Dictionary <AzLogEntry.LogColumn, string>();
                mock.m_mpColumnValue.Add(AzLogEntry.LogColumn.AppName, "TestValue");

                AzLogFilterValue azlfvLHS = new AzLogFilterValue(ValueType.String, DataSource.Column, AzLogEntry.LogColumn.AppName);

                Assert.AreEqual(true, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue("TestValue"), mock));
            }
Esempio n. 6
0
            /* F  E V A L U A T E */

            /*----------------------------------------------------------------------------
            *   %%Function: FEvaluate
            *   %%Qualified: AzLog.AzLogFilter.AzLogFilterValue.FEvaluate
            *   %%Contact: rlittle
            *
            *  ----------------------------------------------------------------------------*/
            public bool FEvaluate(AzLogFilterCondition.CmpOp cmpOp, AzLogFilterValue azlfvRHS, ILogFilterItem ilf)
            {
                int  nCmp;
                bool fNoCase;

                cmpOp = CmpOpGenericFromCmpOp(cmpOp, out fNoCase);

                if (m_vt != azlfvRHS.m_vt)
                {
                    throw new Exception("cannot evaluate dissimilar value types");
                }

                if (m_vt == ValueType.String)
                {
                    nCmp = System.String.Compare(this.String(ilf), azlfvRHS.String(ilf), fNoCase);
                }
                else if (m_vt == ValueType.DateTime)
                {
                    nCmp = DateTime.Compare(this.Dttm(ilf), azlfvRHS.Dttm(ilf));
                }
                else
                {
                    nCmp = 0;
                }

                switch (cmpOp)
                {
                case AzLogFilterCondition.CmpOp.Eq:
                    return(nCmp == 0);

                case AzLogFilterCondition.CmpOp.SEq:
                    return(nCmp == 0);

                case AzLogFilterCondition.CmpOp.Ne:
                    return(nCmp != 0);

                case AzLogFilterCondition.CmpOp.SNe:
                    return(nCmp == 0);

                case AzLogFilterCondition.CmpOp.Gt:
                    return(nCmp > 0);

                case AzLogFilterCondition.CmpOp.Gte:
                    return(nCmp >= 0);

                case AzLogFilterCondition.CmpOp.Lt:
                    return(nCmp < 0);

                case AzLogFilterCondition.CmpOp.Lte:
                    return(nCmp <= 0);
                }

                return(false);
            }
Esempio n. 7
0
            /* C L O N E */

            /*----------------------------------------------------------------------------
            *   %%Function: Clone
            *   %%Qualified: AzLog.AzLogFilter.AzLogFilterValue.Clone
            *   %%Contact: rlittle
            *
            *   Return a deep clone of this filter value
            *  ----------------------------------------------------------------------------*/
            public AzLogFilterValue Clone()
            {
                AzLogFilterValue azlfvNew = new AzLogFilterValue();

                if (m_ds == DataSource.Static)
                {
                    if (m_vt == ValueType.String)
                    {
                        azlfvNew.m_oValue = string.Copy((string)m_oValue);  // don't use Clone() -- that just returns a reference to the original string
                    }
                    else if (m_vt == ValueType.DateTime)
                    {
                        azlfvNew.m_oValue = ((DateTime)m_oValue);
                    }
                }

                azlfvNew.m_ds = m_ds;
                azlfvNew.m_lc = m_lc;
                azlfvNew.m_vt = m_vt;

                return(azlfvNew);
            }
Esempio n. 8
0
 public object OGetValue(AzLogFilterValue.ValueType vt, AzLogFilterValue.DataSource ds, AzLogEntry.LogColumn lc)
 {
     switch (ds)
         {
         case AzLogFilterValue.DataSource.Column:
             return m_mpColumnValue[lc];
         case AzLogFilterValue.DataSource.DttmStart:
             return m_dttmStart;
         case AzLogFilterValue.DataSource.DttmEnd:
             return m_dttmEnd;
         case AzLogFilterValue.DataSource.DttmRow:
             return m_dttmRow;
         }
     return null;
 }
Esempio n. 9
0
            /* F  E V A L U A T E */
            /*----------------------------------------------------------------------------
                %%Function: FEvaluate
                %%Qualified: AzLog.AzLogFilter.AzLogFilterValue.FEvaluate
                %%Contact: rlittle

            ----------------------------------------------------------------------------*/
            public bool FEvaluate(AzLogFilterCondition.CmpOp cmpOp, AzLogFilterValue azlfvRHS, ILogFilterItem ilf)
            {
                int nCmp;
                bool fNoCase;

                cmpOp = CmpOpGenericFromCmpOp(cmpOp, out fNoCase);

                if (m_vt != azlfvRHS.m_vt)
                    throw new Exception("cannot evaluate dissimilar value types");

                if (m_vt == ValueType.String)
                    nCmp = System.String.Compare(this.String(ilf), azlfvRHS.String(ilf), fNoCase);
                else if (m_vt == ValueType.DateTime)
                    nCmp = DateTime.Compare(this.Dttm(ilf), azlfvRHS.Dttm(ilf));
                else
                    nCmp = 0;

                switch (cmpOp)
                    {
                    case AzLogFilterCondition.CmpOp.Eq:
                        return nCmp == 0;
                    case AzLogFilterCondition.CmpOp.SEq:
                        return nCmp == 0;
                    case AzLogFilterCondition.CmpOp.Ne:
                        return nCmp != 0;
                    case AzLogFilterCondition.CmpOp.SNe:
                        return nCmp == 0;
                    case AzLogFilterCondition.CmpOp.Gt:
                        return nCmp > 0;
                    case AzLogFilterCondition.CmpOp.Gte:
                        return nCmp >= 0;
                    case AzLogFilterCondition.CmpOp.Lt:
                        return nCmp < 0;
                    case AzLogFilterCondition.CmpOp.Lte:
                        return nCmp <= 0;
                    }

                return false;
            }
Esempio n. 10
0
            public static void TestStringTypes(string sLHS, string sRHS, AzLogFilterCondition.CmpOp cmpop, bool fExpected)
            {
                AzLogFilterValue azlfvLHS = new AzLogFilterValue(sLHS);
                AzLogFilterValue azlfvRHS = new AzLogFilterValue(sRHS);

                Assert.AreEqual(fExpected, azlfvLHS.FEvaluate(cmpop, azlfvRHS, null));
            }
Esempio n. 11
0
            public static void TestDateTimeTypes(string sDttmLHS, string sDttmRHS, AzLogFilterCondition.CmpOp cmpop,
                bool fExpected)
            {
                AzLogFilterValue azlfvLHS = new AzLogFilterValue(DateTime.Parse(sDttmLHS));
                AzLogFilterValue azlfvRHS = new AzLogFilterValue(DateTime.Parse(sDttmRHS));

                Assert.AreEqual(fExpected, azlfvLHS.FEvaluate(cmpop, azlfvRHS, null));
            }
Esempio n. 12
0
            public static void TestDataSourceDttm()
            {
                TestAzLogFilterValueMock mock = new TestAzLogFilterValueMock();
                mock.m_dttmStart = DateTime.Parse("5/5/1995");
                mock.m_dttmEnd = DateTime.Parse("5/5/1995 3:00");
                mock.m_dttmRow = DateTime.Parse("5/5/1995 1:30");

                AzLogFilterValue azlfvLHS = new AzLogFilterValue(ValueType.DateTime, DataSource.DttmStart, AzLogEntry.LogColumn.Nil);

                Assert.AreEqual(true, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995")), mock));
                Assert.AreEqual(true, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/4/1995 19:00")), mock));
                Assert.AreEqual(false, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995 1:00")), mock));
                Assert.AreEqual(false, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995 3:00")), mock));
                Assert.AreEqual(false, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995 4:00")), mock));

                azlfvLHS = new AzLogFilterValue(ValueType.DateTime, DataSource.DttmEnd, AzLogEntry.LogColumn.Nil);

                Assert.AreEqual(true, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995")), mock));
                Assert.AreEqual(true, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/4/1995 19:00")), mock));
                Assert.AreEqual(true, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995 1:00")), mock));
                Assert.AreEqual(true, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995 3:00")), mock));
                Assert.AreEqual(false, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995 4:00")), mock));

                azlfvLHS = new AzLogFilterValue(ValueType.DateTime, DataSource.DttmRow, AzLogEntry.LogColumn.Nil);

                Assert.AreEqual(true, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995")), mock));
                Assert.AreEqual(true, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/4/1995 19:00")), mock));
                Assert.AreEqual(true, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995 1:00")), mock));
                Assert.AreEqual(false, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995 3:00")), mock));
                Assert.AreEqual(false, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue(DateTime.Parse("5/5/1995 4:00")), mock));
            }
Esempio n. 13
0
            public static void TestDataSourceColumn()
            {
                TestAzLogFilterValueMock mock = new TestAzLogFilterValueMock();
                mock.m_mpColumnValue = new Dictionary<AzLogEntry.LogColumn, string>();
                mock.m_mpColumnValue.Add(AzLogEntry.LogColumn.AppName, "TestValue");

                AzLogFilterValue azlfvLHS = new AzLogFilterValue(ValueType.String, DataSource.Column, AzLogEntry.LogColumn.AppName);

                Assert.AreEqual(true, azlfvLHS.FEvaluate(AzLogFilterCondition.CmpOp.Gte, new AzLogFilterValue("TestValue"), mock));
            }
Esempio n. 14
0
            /* _  I N I T */
            /*----------------------------------------------------------------------------
                %%Function: _Init
                %%Qualified: AzLog.AzLogFilter.AzLogFilterCondition._Init
                %%Contact: rlittle

            ----------------------------------------------------------------------------*/
            private void _Init(AzLogFilterValue.ValueType vt, AzLogFilterValue.DataSource dsLeft, AzLogEntry.LogColumn lc, CmpOp cmpop, DateTime dttmValueRight)
            {
                m_azlfvLHS = new AzLogFilterValue(vt, dsLeft, lc);
                m_azlfvRHS = new AzLogFilterValue(dttmValueRight);
                m_cmpop = cmpop;
            }
Esempio n. 15
0
            /* A Z  L O G  F I L T E R  C O N D I T I O N */
            /*----------------------------------------------------------------------------
                %%Function: AzLogFilterCondition
                %%Qualified: AzLog.AzLogFilter.AzLogFilterCondition.AzLogFilterCondition
                %%Contact: rlittle

            ----------------------------------------------------------------------------*/
            public AzLogFilterCondition(AzLogFilterValue.ValueType vt, AzLogFilterValue.DataSource dsLeft, AzLogEntry.LogColumn lc, CmpOp cmpop, DateTime dttmValueRight)
            {
                _Init(vt, dsLeft, lc, cmpop, dttmValueRight);
            }
Esempio n. 16
0
            /* _  I N I T */

            /*----------------------------------------------------------------------------
            *   %%Function: _Init
            *   %%Qualified: AzLog.AzLogFilter.AzLogFilterCondition._Init
            *   %%Contact: rlittle
            *
            *  ----------------------------------------------------------------------------*/
            private void _Init(AzLogFilterValue.ValueType vt, AzLogFilterValue.DataSource dsLeft, AzLogEntry.LogColumn lc, CmpOp cmpop, DateTime dttmValueRight)
            {
                m_azlfvLHS = new AzLogFilterValue(vt, dsLeft, lc);
                m_azlfvRHS = new AzLogFilterValue(dttmValueRight);
                m_cmpop    = cmpop;
            }