Exemplo n.º 1
0
        private void testAddNEventInfo(IErrorIndex index, int numEventInfos)
        {
            index.Activate();
            StackHashProduct product =
                new StackHashProduct(DateTime.Now, DateTime.Now, "http://www.cucku.com", 1, "TestProduct1", 20, 30, "2.10.02123.1293");
            StackHashFile file = new StackHashFile(new DateTime(100), new DateTime(101), 39, new DateTime(102), "filename.dll", "1.2.3.4");
            StackHashParameterCollection parameters = new StackHashParameterCollection();

            parameters.Add(new StackHashParameter("param1", "param1value"));
            parameters.Add(new StackHashParameter("param2", "param2value"));
            StackHashEventSignature signature = new StackHashEventSignature(parameters);

            StackHashEvent theEvent = new StackHashEvent(new DateTime(102), new DateTime(103), "EventType1", 20000, signature, -1, 2);

            index.AddProduct(product);
            index.AddFile(product, file);
            index.AddEvent(product, file, theEvent);

            StackHashEventInfoCollection eventInfoCollection = new StackHashEventInfoCollection();
            int totalHits = 0;

            for (int i = 0; i < numEventInfos; i++)
            {
                int hitsForThisEvent = (i + 1);
                totalHits += hitsForThisEvent;

                StackHashEventInfo eventInfo = new StackHashEventInfo(DateTime.Now.AddDays(i).ToUniversalTime(),
                                                                      DateTime.Now.AddDays(i + 1).ToUniversalTime(), DateTime.Now.AddDays(i + 2).ToUniversalTime(), "English" + i.ToString(),
                                                                      i, "locale" + i.ToString(), "OS" + i.ToString(), "OSVersion" + i.ToString(), hitsForThisEvent);
                eventInfoCollection.Add(eventInfo);
            }

            index.AddEventInfoCollection(product, file, theEvent, eventInfoCollection);


            // Now get all the event info and make sure it all matches.
            StackHashEventInfoCollection eventInfoCollection2 = index.LoadEventInfoList(product, file, theEvent);

            Assert.AreEqual(0, eventInfoCollection.CompareTo(eventInfoCollection2));

            StackHashEventPackageCollection eventPackages = index.GetProductEvents(product);

            Assert.AreEqual(1, eventPackages.Count);
            Assert.AreEqual(totalHits, eventPackages[0].EventData.TotalHits);
        }
Exemplo n.º 2
0
        private void testAddNEventInfoReloadCache(IErrorIndex realIndex, int numEventInfos)
        {
            ErrorIndexCache index = new ErrorIndexCache(realIndex);

            index.Activate();

            StackHashProduct product =
                new StackHashProduct(DateTime.Now, DateTime.Now, "http://www.cucku.com", 1, "TestProduct1", 20, 30, "2.10.02123.1293");
            StackHashFile file = new StackHashFile(new DateTime(100), new DateTime(101), 39, new DateTime(102), "filename.dll", "1.2.3.4");
            StackHashParameterCollection parameters = new StackHashParameterCollection();

            parameters.Add(new StackHashParameter("param1", "param1value"));
            parameters.Add(new StackHashParameter("param2", "param2value"));
            StackHashEventSignature signature = new StackHashEventSignature(parameters);

            StackHashEvent theEvent = new StackHashEvent(new DateTime(102), new DateTime(103), "EventType1", 20000, signature, 99, 2);

            index.AddProduct(product);
            index.AddFile(product, file);
            index.AddEvent(product, file, theEvent);

            StackHashEventInfoCollection eventInfoCollection = new StackHashEventInfoCollection();

            for (int i = 0; i < numEventInfos; i++)
            {
                StackHashEventInfo eventInfo = new StackHashEventInfo(DateTime.Now.AddDays(i),
                                                                      DateTime.Now.AddDays(i + 1), DateTime.Now.AddDays(i + 2), "English" + i.ToString(),
                                                                      i, "locale" + i.ToString(), "OS" + i.ToString(), "OSVersion" + i.ToString(), i * 10);
                eventInfoCollection.Add(eventInfo);
            }

            index.AddEventInfoCollection(product, file, theEvent, eventInfoCollection);

            // Now reconnect a cache to make sure that the data has been stored ok.
            index = new ErrorIndexCache(realIndex);
            index.Activate();

            // Now get all the event info and make sure it all matches.
            StackHashEventInfoCollection eventInfoCollection2 = index.LoadEventInfoList(product, file, theEvent);

            Assert.AreEqual(0, eventInfoCollection.CompareTo(eventInfoCollection2));
        }
Exemplo n.º 3
0
        public void NormalizeListNoDuplicates()
        {
            DateTime           testTime1     = new DateTime(2010, 10, 24, 16, 0, 0, DateTimeKind.Utc);
            DateTime           expectedTime1 = new DateTime(2010, 10, 25, 0, 0, 0, DateTimeKind.Utc);
            StackHashEventInfo eventInfo1    = new StackHashEventInfo(testTime1, testTime1, testTime1, "English", 123, "EN-US", "Vista", "6.0.0.0", 10);

            DateTime           testTime2     = new DateTime(2010, 10, 25, 16, 0, 0, DateTimeKind.Utc);
            DateTime           expectedTime2 = new DateTime(2010, 10, 26, 0, 0, 0, DateTimeKind.Utc);
            StackHashEventInfo eventInfo2    = new StackHashEventInfo(testTime2, testTime2, testTime2, "English", 123, "EN-US", "Vista", "6.0.0.0", 10);

            StackHashEventInfoCollection eventInfos = new StackHashEventInfoCollection();

            eventInfos.Add(eventInfo1);
            eventInfos.Add(eventInfo2);

            StackHashEventInfoCollection normalizedEventInfos = eventInfos.Normalize();

            eventInfo1.HitDateLocal = expectedTime1;
            eventInfo2.HitDateLocal = expectedTime2;

            Assert.AreEqual(0, eventInfos.CompareTo(normalizedEventInfos));
        }
Exemplo n.º 4
0
        private void testMergeOneNewEventInfoWithOverlap(IErrorIndex index, int numEventInfos, int overlap)
        {
            // Add event info - then add another new one.
            index.Activate();
            StackHashProduct product =
                new StackHashProduct(DateTime.Now, DateTime.Now, "http://www.cucku.com", 1, "TestProduct1", 20, 30, "2.10.02123.1293");
            StackHashFile file = new StackHashFile(new DateTime(100), new DateTime(101), 39, new DateTime(102), "filename.dll", "1.2.3.4");
            StackHashParameterCollection parameters = new StackHashParameterCollection();

            parameters.Add(new StackHashParameter("param1", "param1value"));
            parameters.Add(new StackHashParameter("param2", "param2value"));
            StackHashEventSignature signature = new StackHashEventSignature(parameters);

            StackHashEvent theEvent = new StackHashEvent(new DateTime(102), new DateTime(103), "EventType1", 20000, signature, -1, 2);

            index.AddProduct(product);
            index.AddFile(product, file);
            index.AddEvent(product, file, theEvent);

            StackHashEventInfoCollection eventInfoCollection = new StackHashEventInfoCollection();
            int totalHits = 0;

            for (int i = 0; i < numEventInfos; i++)
            {
                if (i < numEventInfos - overlap)
                {
                    totalHits += i + 1;
                }

                StackHashEventInfo eventInfo = new StackHashEventInfo(DateTime.Now.AddDays(-3 * i).Date,
                                                                      DateTime.Now.AddDays(-2 * i).Date, DateTime.Now.AddDays(-1 * i).Date, "English" + i.ToString(),
                                                                      i, "locale" + i.ToString(), "OS" + i.ToString(), "OSVersion" + i.ToString(), i + 1);
                eventInfoCollection.Add(eventInfo);
            }

            index.MergeEventInfoCollection(product, file, theEvent, eventInfoCollection);


            StackHashEventInfoCollection eventInfoCollectionNew = new StackHashEventInfoCollection();

            for (int i = numEventInfos - overlap; i < numEventInfos * 2 - overlap; i++)
            {
                StackHashEventInfo eventInfo = new StackHashEventInfo(DateTime.Now.AddDays(-3 * i).Date,
                                                                      DateTime.Now.AddDays(-2 * i).Date, DateTime.Now.AddDays(-1 * i).Date, "English" + i.ToString(),
                                                                      i, "locale" + i.ToString(), "OS" + i.ToString(), "OSVersion" + i.ToString(), overlap + i + 1);

                if (i >= numEventInfos - overlap)
                {
                    totalHits += overlap + i + 1;
                }

                StackHashEventInfo foundEventInfo = eventInfoCollection.FindEventInfoByHitDate(eventInfo);

                if (foundEventInfo != null)
                {
                    foundEventInfo.SetWinQualFields(eventInfo);
                }
                else
                {
                    eventInfoCollection.Add(eventInfo);
                }

                eventInfoCollectionNew.Add(eventInfo);
            }

            index.MergeEventInfoCollection(product, file, theEvent, eventInfoCollectionNew);


            // Now get all the event info and make sure it all matches.
            StackHashEventInfoCollection eventInfoCollection2 = index.LoadEventInfoList(product, file, theEvent);

            Assert.AreEqual(0, eventInfoCollection.CompareTo(eventInfoCollection2));

            StackHashEventPackageCollection eventPackages = index.GetProductEvents(product);

            Assert.AreEqual(1, eventPackages.Count);
            Assert.AreEqual(totalHits, eventPackages[0].EventData.TotalHits);
        }