Exemple #1
0
        public void ToSqlStringTwoCriteriaAndTwoOptions()
        {
            int    productId   = 20;
            String productName = "MyProduct";

            StackHashSearchOptionCollection options1 = new StackHashSearchOptionCollection()
            {
                new IntSearchOption(StackHashObjectType.Product, "Id", StackHashSearchOptionType.GreaterThan, productId, 0),
                new StringSearchOption(StackHashObjectType.Product, "Name", StackHashSearchOptionType.StringContains, productName, null, false)
            };

            StackHashSearchOptionCollection options2 = new StackHashSearchOptionCollection()
            {
                new IntSearchOption(StackHashObjectType.Product, "Id", StackHashSearchOptionType.RangeInclusive, productId, productId + 5),
                new StringSearchOption(StackHashObjectType.Product, "Name", StackHashSearchOptionType.StringStartsWith, productName, null, false)
            };

            StackHashSearchCriteriaCollection allCriteria = new StackHashSearchCriteriaCollection()
            {
                new StackHashSearchCriteria(options1),
                new StackHashSearchCriteria(options2),
            };

            String result   = allCriteria.ToSqlString(StackHashObjectType.Product, "P");
            String expected = String.Format("(((P.ProductId>{0}) AND (P.ProductName LIKE N'%{1}%')) OR ((P.ProductId BETWEEN {0} AND {2}) AND (P.ProductName LIKE N'{1}%')))", productId, productName, productId + 5);

            Assert.AreEqual(expected, result);
        }
Exemple #2
0
        public void ToSqlStringProduct_ProductId()
        {
            int productId = 20;
            StackHashSearchOptionCollection options = new StackHashSearchOptionCollection()
            {
                new IntSearchOption(StackHashObjectType.Product, "Id", StackHashSearchOptionType.Equal, productId, 0)
            };

            StackHashSearchCriteriaCollection allCriteria = new StackHashSearchCriteriaCollection()
            {
                new StackHashSearchCriteria(options)
            };

            String result   = allCriteria.ToSqlString(StackHashObjectType.Product, "P");
            String expected = String.Format("(P.ProductId={0})", productId);

            Assert.AreEqual(expected, result);
        }
Exemple #3
0
        public void ToSqlStringNoMatches()
        {
            int productId = 20;
            StackHashSearchOptionCollection options = new StackHashSearchOptionCollection()
            {
                new IntSearchOption(StackHashObjectType.Product, "ProductId", StackHashSearchOptionType.Equal, productId, 0)
            };

            StackHashSearchCriteriaCollection allCriteria = new StackHashSearchCriteriaCollection()
            {
                new StackHashSearchCriteria(options)
            };

            String result   = allCriteria.ToSqlString(StackHashObjectType.File, "F");
            String expected = String.Empty;

            Assert.AreEqual(expected, result);
        }
Exemple #4
0
        public void ToSqlStringDateTimeWildcardOnProduct()
        {
            DateTime searchDateTime = new DateTime(2010, 11, 12);

            StackHashSearchOptionCollection options1 = new StackHashSearchOptionCollection()
            {
                new DateTimeSearchOption(StackHashObjectType.Product, "*", StackHashSearchOptionType.RangeExclusive, searchDateTime, searchDateTime),
            };

            StackHashSearchCriteriaCollection allCriteria = new StackHashSearchCriteriaCollection()
            {
                new StackHashSearchCriteria(options1),
            };

            String result   = allCriteria.ToSqlString(StackHashObjectType.Product, "P");
            String expected = String.Format("((P.DateCreatedLocal>'2010-11-12T00:00:00' AND P.DateCreatedLocal<'2010-11-12T00:00:00') OR (P.DateModifiedLocal>'2010-11-12T00:00:00' AND P.DateModifiedLocal<'2010-11-12T00:00:00'))");

            Assert.AreEqual(expected, result);
        }
Exemple #5
0
        public void ToSqlStringStringWildcardOnProduct()
        {
            String searchString = "MyProduct";

            StackHashSearchOptionCollection options1 = new StackHashSearchOptionCollection()
            {
                new StringSearchOption(StackHashObjectType.Product, "*", StackHashSearchOptionType.StringStartsWith, searchString, searchString, false),
            };

            StackHashSearchCriteriaCollection allCriteria = new StackHashSearchCriteriaCollection()
            {
                new StackHashSearchCriteria(options1),
            };

            String result   = allCriteria.ToSqlString(StackHashObjectType.Product, "P");
            String expected = String.Format("((P.ProductName LIKE N'{0}%') OR (P.Version LIKE N'{0}%'))", searchString);

            Assert.AreEqual(expected, result);
        }
Exemple #6
0
        public void ToSqlStringLongWildcardOnProduct()
        {
            long searchLong = 20;

            StackHashSearchOptionCollection options1 = new StackHashSearchOptionCollection()
            {
                new LongSearchOption(StackHashObjectType.Product, "*", StackHashSearchOptionType.GreaterThan, searchLong, searchLong),
            };

            StackHashSearchCriteriaCollection allCriteria = new StackHashSearchCriteriaCollection()
            {
                new StackHashSearchCriteria(options1),
            };

            String result   = allCriteria.ToSqlString(StackHashObjectType.Product, "P");
            String expected = "";  // No long fields.

            Assert.AreEqual(expected, result);
        }
Exemple #7
0
        public void ToSqlStringIntegerWildcardOnProduct()
        {
            int productId = 20;

            StackHashSearchOptionCollection options1 = new StackHashSearchOptionCollection()
            {
                new IntSearchOption(StackHashObjectType.Product, "*", StackHashSearchOptionType.GreaterThan, productId, 0),
            };

            StackHashSearchCriteriaCollection allCriteria = new StackHashSearchCriteriaCollection()
            {
                new StackHashSearchCriteria(options1),
            };

            String result   = allCriteria.ToSqlString(StackHashObjectType.Product, "P");
            String expected = String.Format("((P.ProductId>{0}) OR (P.TotalEvents>{0}) OR (P.TotalResponses>{0}) OR (P.TotalStoredEvents>{0}))", productId);

            Assert.AreEqual(expected, result);
        }
Exemple #8
0
        public void ToSqlStringLongWildcardOnEventSignature()
        {
            long searchLong = 20;

            StackHashSearchOptionCollection options1 = new StackHashSearchOptionCollection()
            {
                new LongSearchOption(StackHashObjectType.EventSignature, "*", StackHashSearchOptionType.RangeInclusive, searchLong, searchLong + 1),
            };

            StackHashSearchCriteriaCollection allCriteria = new StackHashSearchCriteriaCollection()
            {
                new StackHashSearchCriteria(options1),
            };

            String result   = allCriteria.ToSqlString(StackHashObjectType.EventSignature, "ES");
            String expected = "((ES.Offset BETWEEN 20 AND 21) OR (ES.ExceptionCode BETWEEN 20 AND 21))";  // No long fields.

            Assert.AreEqual(expected, result);
        }
Exemple #9
0
        public void ToSqlStringLongWildcardOnEventInfo()
        {
            long searchLong = 20;

            StackHashSearchOptionCollection options1 = new StackHashSearchOptionCollection()
            {
                new LongSearchOption(StackHashObjectType.EventInfo, "*", StackHashSearchOptionType.RangeInclusive, searchLong, searchLong + 1),
            };

            StackHashSearchCriteriaCollection allCriteria = new StackHashSearchCriteriaCollection()
            {
                new StackHashSearchCriteria(options1),
            };

            String result   = allCriteria.ToSqlString(StackHashObjectType.EventInfo, "EI");
            String expected = "";

            Assert.AreEqual(expected, result);
        }
Exemple #10
0
        public void ToSqlStringLongWildcardOnCabInfo()
        {
            long searchLong = 20;

            StackHashSearchOptionCollection options1 = new StackHashSearchOptionCollection()
            {
                new LongSearchOption(StackHashObjectType.CabInfo, "*", StackHashSearchOptionType.RangeInclusive, searchLong, searchLong + 1),
            };

            StackHashSearchCriteriaCollection allCriteria = new StackHashSearchCriteriaCollection()
            {
                new StackHashSearchCriteria(options1),
            };

            String result   = allCriteria.ToSqlString(StackHashObjectType.CabInfo, "C");
            String expected = "(C.SizeInBytes BETWEEN 20 AND 21)";

            Assert.AreEqual(expected, result);
        }
Exemple #11
0
        public void ToSqlStringStringWildcardOnCabInfo()
        {
            String searchString = "MyProduct";

            StackHashSearchOptionCollection options1 = new StackHashSearchOptionCollection()
            {
                new StringSearchOption(StackHashObjectType.CabInfo, "*", StackHashSearchOptionType.RangeInclusive, searchString, searchString, false),
            };

            StackHashSearchCriteriaCollection allCriteria = new StackHashSearchCriteriaCollection()
            {
                new StackHashSearchCriteria(options1),
            };

            String result = allCriteria.ToSqlString(StackHashObjectType.CabInfo, "C");

            String expected = "((CET.EventTypeName BETWEEN N'MyProduct' AND N'MyProduct') OR (C.CabFileName BETWEEN N'MyProduct' AND N'MyProduct'))";

            Assert.AreEqual(expected, result);
        }
Exemple #12
0
        public void ToSqlStringIntegerWildcardOnCabInfo()
        {
            int searchInt = 20;

            StackHashSearchOptionCollection options1 = new StackHashSearchOptionCollection()
            {
                new IntSearchOption(StackHashObjectType.CabInfo, "*", StackHashSearchOptionType.GreaterThan, searchInt, 0),
            };

            StackHashSearchCriteriaCollection allCriteria = new StackHashSearchCriteriaCollection()
            {
                new StackHashSearchCriteria(options1),
            };

            String result = allCriteria.ToSqlString(StackHashObjectType.CabInfo, "C");

            String expected = "((C.EventId>20) OR (C.CabId>20))";

            Assert.AreEqual(expected, result);
        }
Exemple #13
0
        public void ToSqlStringStringWildcardOnEventInfo()
        {
            String searchString = "MyProduct";

            StackHashSearchOptionCollection options1 = new StackHashSearchOptionCollection()
            {
                new StringSearchOption(StackHashObjectType.EventInfo, "*", StackHashSearchOptionType.RangeInclusive, searchString, searchString, false),
            };

            StackHashSearchCriteriaCollection allCriteria = new StackHashSearchCriteriaCollection()
            {
                new StackHashSearchCriteria(options1),
            };

            String result = allCriteria.ToSqlString(StackHashObjectType.EventInfo, "EI");

            String expected = "((l.LocaleName BETWEEN N'MyProduct' AND N'MyProduct') OR (l.LocaleCode BETWEEN N'MyProduct' AND N'MyProduct') OR (O.OperatingSystemName BETWEEN N'MyProduct' AND N'MyProduct') OR (O.OperatingSystemVersion BETWEEN N'MyProduct' AND N'MyProduct'))";

            Assert.AreEqual(expected, result);
        }
Exemple #14
0
        public void ToSqlStringIntegerWildcardOnEvent()
        {
            int searchInt = 20;

            StackHashSearchOptionCollection options1 = new StackHashSearchOptionCollection()
            {
                new IntSearchOption(StackHashObjectType.Event, "*", StackHashSearchOptionType.GreaterThan, searchInt, 0),
            };

            StackHashSearchCriteriaCollection allCriteria = new StackHashSearchCriteriaCollection()
            {
                new StackHashSearchCriteria(options1),
            };

            String result = allCriteria.ToSqlString(StackHashObjectType.Event, "E");

            String expected = String.Format("((E.EventId>20) OR (E.TotalHits>20) OR (E.WorkFlowStatus>20) OR (CABCOUNTER.CabCount>20))");

            Assert.AreEqual(expected, result);
        }
Exemple #15
0
        public void ToSqlStringDateTimeWildcardOnEventSignature()
        {
            DateTime searchDateTime = new DateTime(2010, 11, 12);

            StackHashSearchOptionCollection options1 = new StackHashSearchOptionCollection()
            {
                new DateTimeSearchOption(StackHashObjectType.EventSignature, "*", StackHashSearchOptionType.RangeExclusive, searchDateTime, searchDateTime.AddDays(2)),
            };

            StackHashSearchCriteriaCollection allCriteria = new StackHashSearchCriteriaCollection()
            {
                new StackHashSearchCriteria(options1),
            };

            String result = allCriteria.ToSqlString(StackHashObjectType.EventSignature, "ES");

            String expected = "((ES.ApplicationTimeStamp>'2010-11-12T00:00:00' AND ES.ApplicationTimeStamp<'2010-11-14T00:00:00') OR (ES.ModuleTimeStamp>'2010-11-12T00:00:00' AND ES.ModuleTimeStamp<'2010-11-14T00:00:00'))";

            Assert.AreEqual(expected, result);
        }
Exemple #16
0
        public void ToSqlStringStringDoesNotContain()
        {
            int    productId   = 20;
            String productName = "MyProduct";

            StackHashSearchOptionCollection options1 = new StackHashSearchOptionCollection()
            {
                new StringSearchOption(StackHashObjectType.Product, "Name", StackHashSearchOptionType.StringDoesNotContain, productName, null, false)
            };

            StackHashSearchCriteriaCollection allCriteria = new StackHashSearchCriteriaCollection()
            {
                new StackHashSearchCriteria(options1),
            };

            String result   = allCriteria.ToSqlString(StackHashObjectType.Product, "P");
            String expected = String.Format("(P.ProductName NOT LIKE N'%MyProduct%' OR P.ProductName IS NULL)", productId, productName);

            Assert.AreEqual(expected, result);
        }
Exemple #17
0
        public void ToSqlStringDateTimeWildcardOnCabInfo()
        {
            DateTime searchDateTime = new DateTime(2010, 11, 12);

            StackHashSearchOptionCollection options1 = new StackHashSearchOptionCollection()
            {
                new DateTimeSearchOption(StackHashObjectType.CabInfo, "*", StackHashSearchOptionType.RangeExclusive, searchDateTime, searchDateTime.AddDays(2)),
            };

            StackHashSearchCriteriaCollection allCriteria = new StackHashSearchCriteriaCollection()
            {
                new StackHashSearchCriteria(options1),
            };

            String result = allCriteria.ToSqlString(StackHashObjectType.CabInfo, "C");

            String expected = "((C.DateCreatedLocal>'2010-11-12T00:00:00' AND C.DateCreatedLocal<'2010-11-14T00:00:00') OR (C.DateModifiedLocal>'2010-11-12T00:00:00' AND C.DateModifiedLocal<'2010-11-14T00:00:00'))";

            Assert.AreEqual(expected, result);
        }
Exemple #18
0
        public void ToSqlStringIntegerWildcardOnEventSignature()
        {
            int searchInt = 20;

            StackHashSearchOptionCollection options1 = new StackHashSearchOptionCollection()
            {
                new IntSearchOption(StackHashObjectType.EventSignature, "*", StackHashSearchOptionType.GreaterThan, searchInt, 0),
            };

            StackHashSearchCriteriaCollection allCriteria = new StackHashSearchCriteriaCollection()
            {
                new StackHashSearchCriteria(options1),
            };

            String result = allCriteria.ToSqlString(StackHashObjectType.EventSignature, "ES");

            String expected = "";

            Assert.AreEqual(expected, result);
        }
Exemple #19
0
        public void ToSqlStringStringWildcardOnEventSignature()
        {
            String searchString = "MyProduct";

            StackHashSearchOptionCollection options1 = new StackHashSearchOptionCollection()
            {
                new StringSearchOption(StackHashObjectType.EventSignature, "*", StackHashSearchOptionType.RangeInclusive, searchString, searchString, false),
            };

            StackHashSearchCriteriaCollection allCriteria = new StackHashSearchCriteriaCollection()
            {
                new StackHashSearchCriteria(options1),
            };

            String result = allCriteria.ToSqlString(StackHashObjectType.EventSignature, "ES");

            String expected = "((ES.ApplicationName BETWEEN N'MyProduct' AND N'MyProduct') OR (ES.ApplicationVersion BETWEEN N'MyProduct' AND N'MyProduct') OR (ES.ModuleName BETWEEN N'MyProduct' AND N'MyProduct') OR (ES.ModuleVersion BETWEEN N'MyProduct' AND N'MyProduct'))";

            Assert.AreEqual(expected, result);
        }
Exemple #20
0
        public void ToSqlStringOneOfTwoOptionsBothMatch()
        {
            int    productId   = 20;
            String productName = "MyProduct";

            StackHashSearchOptionCollection options1 = new StackHashSearchOptionCollection()
            {
                new IntSearchOption(StackHashObjectType.Product, "Id", StackHashSearchOptionType.GreaterThan, productId, 0),
                new StringSearchOption(StackHashObjectType.Product, "Name", StackHashSearchOptionType.StringContains, productName, null, false)
            };

            StackHashSearchCriteriaCollection allCriteria = new StackHashSearchCriteriaCollection()
            {
                new StackHashSearchCriteria(options1),
            };

            String result   = allCriteria.ToSqlString(StackHashObjectType.Product, "P");
            String expected = String.Format("((P.ProductId>{0}) AND (P.ProductName LIKE N'%{1}%'))", productId, productName);

            Assert.AreEqual(expected, result);
        }