Example #1
0
        private void testAddEventInfoNullEventInfo(IErrorIndex index)
        {
            try
            {
                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);

                index.AddEventInfoCollection(product, file, theEvent, null);
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("eventInfoCollection", ex.ParamName);
                throw;
            }
        }
Example #2
0
        private void checkIndexData(IErrorIndex index)
        {
            int numProducts = 100;
            int cabId       = 12345678;
            int fileId      = 2000;
            int eventId     = 1000;


            for (int productCount = 0; productCount < numProducts; productCount++)
            {
                StackHashProduct retrievedProduct = index.GetProduct(productCount + 10);

                DateTime         creationDateTime = new DateTime(2010, 04, 04, 22, 9, 0, DateTimeKind.Utc);
                DateTime         modifiedDateTime = new DateTime(2010, 05, 05, 23, 10, 0, DateTimeKind.Utc);
                StackHashProduct product1         =
                    new StackHashProduct(creationDateTime, modifiedDateTime, null, (productCount + 10), "TestProduct1", 20, 30, "2.10.02123.1293");

                Assert.AreEqual(0, product1.CompareTo(retrievedProduct));


                StackHashFile file1 = new StackHashFile(creationDateTime, modifiedDateTime, fileId++, creationDateTime, "FileName", "1.2.3.4");

                StackHashFile retrievedFile = index.GetFile(product1, file1.Id);
                Assert.AreEqual(0, file1.CompareTo(retrievedFile));

                StackHashEventSignature eventSignature = new StackHashEventSignature();
                eventSignature.Parameters = new StackHashParameterCollection();
                eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationName, "AppName"));
                eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationVersion, "1.2.3.4"));
                eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationTimeStamp, creationDateTime.ToString()));
                eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleName, "ModuleName"));
                eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleVersion, "2.3.4.5"));
                eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleTimeStamp, creationDateTime.ToString()));
                eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamExceptionCode, "1234"));
                eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamOffset, "0x1234"));
                eventSignature.InterpretParameters();

                StackHashEvent thisEvent = new StackHashEvent(creationDateTime, modifiedDateTime, "CLR20", eventId++, eventSignature, 1, file1.Id);

                StackHashEvent retrievedEvent = index.GetEvent(product1, file1, thisEvent);
                Assert.AreEqual(0, thisEvent.CompareTo(retrievedEvent));

                StackHashCab cab = new StackHashCab(creationDateTime, modifiedDateTime, thisEvent.Id, thisEvent.EventTypeName, "cab12345_23232.cab", cabId++, 12000);
                cab.DumpAnalysis = new StackHashDumpAnalysis("2 days, 5 hours, 2 mins", "1 hour, 2 mins", "2.120.222.1121212", "Microsoft Windows Vista X64 6.0.212121212 (Build 2500)", "64 bit windows");

                cab.CabDownloaded = true;

                StackHashCab retrievedCab = index.GetCab(product1, file1, thisEvent, cab.Id);
                Assert.AreEqual(0, cab.CompareTo(retrievedCab));

                String cabFolder   = index.GetCabFolder(product1, file1, thisEvent, cab);
                String cabFileName = index.GetCabFileName(product1, file1, thisEvent, cab);

                Assert.AreEqual(true, Directory.Exists(cabFolder));
                Assert.AreEqual(true, File.Exists(cabFileName));
            }
        }
Example #3
0
        private void addDataToIndex(IErrorIndex index)
        {
            int numProducts = 100;

            int cabId   = 12345678;
            int fileId  = 2000;
            int eventId = 1000;

            for (int productCount = 0; productCount < numProducts; productCount++)
            {
                DateTime         creationDateTime = new DateTime(2010, 04, 04, 22, 9, 0, DateTimeKind.Utc);
                DateTime         modifiedDateTime = new DateTime(2010, 05, 05, 23, 10, 0, DateTimeKind.Utc);
                StackHashProduct product1         =
                    new StackHashProduct(creationDateTime, modifiedDateTime, null, (productCount + 10), "TestProduct1", 20, 30, "2.10.02123.1293");

                index.AddProduct(product1);

                StackHashFile file1 = new StackHashFile(creationDateTime, modifiedDateTime, fileId++, creationDateTime, "FileName", "1.2.3.4");
                index.AddFile(product1, file1);

                StackHashEventSignature eventSignature = new StackHashEventSignature();
                eventSignature.Parameters = new StackHashParameterCollection();
                eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationName, "AppName"));
                eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationVersion, "1.2.3.4"));
                eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationTimeStamp, creationDateTime.ToString()));
                eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleName, "ModuleName"));
                eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleVersion, "2.3.4.5"));
                eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleTimeStamp, creationDateTime.ToString()));
                eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamExceptionCode, "1234"));
                eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamOffset, "0x1234"));
                eventSignature.InterpretParameters();

                StackHashEvent thisEvent = new StackHashEvent(creationDateTime, modifiedDateTime, "CLR20", eventId++, eventSignature, 1, file1.Id);
                index.AddEvent(product1, file1, thisEvent);


                StackHashCab cab = new StackHashCab(creationDateTime, modifiedDateTime, thisEvent.Id, thisEvent.EventTypeName, "cab12345_23232.cab", cabId++, 12000);
                cab.DumpAnalysis = new StackHashDumpAnalysis("2 days, 5 hours, 2 mins", "1 hour, 2 mins", "2.120.222.1121212", "Microsoft Windows Vista X64 6.0.212121212 (Build 2500)", "64 bit windows");

                cab.CabDownloaded = true;
                index.AddCab(product1, file1, thisEvent, cab, true);

                String cabFolder   = index.GetCabFolder(product1, file1, thisEvent, cab);
                String cabFileName = index.GetCabFileName(product1, file1, thisEvent, cab);

                if (!Directory.Exists(cabFolder))
                {
                    Directory.CreateDirectory(cabFolder);
                }

                File.Copy(TestSettings.TestDataFolder + @"Cabs\1641909485-Crash32bit-0773522646.cab", cabFileName);

                FileAttributes originalAttributes = File.GetAttributes(cabFileName);
                File.SetAttributes(cabFileName, originalAttributes & ~FileAttributes.ReadOnly);
            }
        }
Example #4
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);
        }
Example #5
0
        /// <summary>
        /// Converts a WinQual EventSignature into a StackHashEventSignature.
        /// </summary>
        /// <param name="eventSignature">WinQual Event signature to convert.</param>
        /// <returns>Converted event signature.</returns>
        public static StackHashEventSignature ConvertEventSignature(EventSignature eventSignature)
        {
            if (eventSignature == null)
            {
                throw new ArgumentNullException("eventSignature");
            }

            StackHashParameterCollection paramCollection = new StackHashParameterCollection();

            foreach (Parameter param in eventSignature.Parameters)
            {
                StackHashParameter stackHashParam = new StackHashParameter(param.Name, param.Value);
                paramCollection.Add(stackHashParam);
            }

            StackHashEventSignature stackHashEventSignature = new StackHashEventSignature(paramCollection);

            return(stackHashEventSignature);
        }
Example #6
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));
        }
Example #7
0
        /// <summary>
        /// Converts a WinQual Event into a StackHashEvent.
        /// </summary>
        /// <param name="thisEvent">WinQual event to convert.</param>
        /// <param name="fileId">Id of the owning file.</param>
        /// <returns>Converted event.</returns>
        public static StackHashEvent ConvertEvent(Event thisEvent, int fileId)
        {
            if (thisEvent == null)
            {
                throw new ArgumentNullException("thisEvent");
            }

            StackHashEventSignature eventSignature = ConvertEventSignature(thisEvent.Signature);

            StackHashEvent newEvent = new StackHashEvent(
                thisEvent.DateCreatedLocal.ToUniversalTime(),
                thisEvent.DateModifiedLocal.ToUniversalTime(),
                thisEvent.EventTypeName,
                thisEvent.ID,
                eventSignature,
                thisEvent.TotalHits,
                fileId);

            return(newEvent);
        }
Example #8
0
        private void readEventSignature(XmlTextReader xmlReader, TestDatabaseProduct product, TestDatabaseFile file, TestDatabaseEvent theEvent)
        {
            StackHashEventSignature signature = new StackHashEventSignature();

            signature.Parameters = new StackHashParameterCollection();

            while (xmlReader.Read())
            {
                if ((xmlReader.NodeType == XmlNodeType.EndElement) &&
                    (xmlReader.Name.ToUpperInvariant() == "SIGNATURE"))
                {
                    theEvent.TheEvent.Event.EventSignature = signature;
                    return;
                }

                if (xmlReader.NodeType == XmlNodeType.Element)
                {
                    String elementName = xmlReader.Name;
                    xmlReader.Read();
                    String elementText = xmlReader.Value;
                    signature.Parameters.Add(new StackHashParameter(elementName, elementText));
                }
            }
        }
Example #9
0
        public void MergeWithDuplicatesInNewList()
        {
            m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder);
            m_Index.DeleteIndex();

            m_Index.Activate();

            DateTime         creationDateTime = new DateTime(2010, 04, 04, 22, 9, 0, DateTimeKind.Utc);
            DateTime         modifiedDateTime = new DateTime(2010, 05, 05, 23, 10, 0, DateTimeKind.Utc);
            StackHashProduct product1         =
                new StackHashProduct(creationDateTime, modifiedDateTime, null, 1, "TestProduct1", 20, 30, "2.10.02123.1293");

            StackHashFile file1 =
                new StackHashFile(creationDateTime, modifiedDateTime, 20, creationDateTime, "File1.dll", "2.3.4.5");

            StackHashEventSignature eventSignature = new StackHashEventSignature();

            eventSignature.Parameters = new StackHashParameterCollection();
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationName, "AppName"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationVersion, "1.2.3.4"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationTimeStamp, creationDateTime.ToString()));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleName, "ModuleName"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleVersion, "2.3.4.5"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleTimeStamp, creationDateTime.ToString()));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamExceptionCode, "1234"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamOffset, "0x1234"));
            eventSignature.InterpretParameters();

            StackHashEvent event1 =
                new StackHashEvent(creationDateTime, modifiedDateTime, "EventTypeName1", 100, eventSignature, 20, file1.Id, "bug");

            m_Index.AddProduct(product1);
            m_Index.AddFile(product1, file1);
            m_Index.AddEvent(product1, file1, event1);

            StackHashEventInfoCollection eventInfos1 = new StackHashEventInfoCollection();
            StackHashEventInfoCollection eventInfos2 = new StackHashEventInfoCollection();



            DateTime nowTime = DateTime.Now;
            DateTime date    = new DateTime(nowTime.Year, nowTime.Month, nowTime.Day, nowTime.Hour, nowTime.Minute, 0);

            int localeId = 123;

            // These events just different by num hits.
            StackHashEventInfo eventInfo1        = new StackHashEventInfo(date, date, date, "US", localeId, "English", "Windows Vista", "1.2.3.4 build 7", 100);
            StackHashEventInfo eventInfo2        = new StackHashEventInfo(date, date, date, "US", localeId, "English", "Windows Vista", "1.2.3.4 build 7", 101);
            StackHashEventInfo expectedEventInfo = (StackHashEventInfo)eventInfo1.Clone();

            expectedEventInfo.TotalHits = eventInfo1.TotalHits + eventInfo2.TotalHits;

            eventInfos1.Add(eventInfo1);
            eventInfos1.Add(eventInfo2);

            m_Index.AddEventInfoCollection(product1, file1, event1, eventInfos1);

            StackHashEventInfoCollection eventInfosRetrieved = m_Index.LoadEventInfoList(product1, file1, event1);

            Assert.AreEqual(1, eventInfosRetrieved.Count);


            Assert.AreEqual(0, expectedEventInfo.CompareTo(eventInfosRetrieved[0]));
        }
Example #10
0
        public void GetMostRecentHitDateDuplicateEventIds()
        {
            m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder);
            m_Index.DeleteIndex();

            m_Index.Activate();

            DateTime         creationDateTime = new DateTime(2010, 04, 04, 22, 9, 0, DateTimeKind.Utc);
            DateTime         modifiedDateTime = new DateTime(2010, 05, 05, 23, 10, 0, DateTimeKind.Utc);
            StackHashProduct product1         =
                new StackHashProduct(creationDateTime, modifiedDateTime, null, 1, "TestProduct1", 20, 30, "2.10.02123.1293");

            StackHashFile file1 =
                new StackHashFile(creationDateTime, modifiedDateTime, 20, creationDateTime, "File1.dll", "2.3.4.5");

            StackHashEventSignature eventSignature = new StackHashEventSignature();

            eventSignature.Parameters = new StackHashParameterCollection();
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationName, "AppName"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationVersion, "1.2.3.4"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationTimeStamp, creationDateTime.ToString()));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleName, "ModuleName"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleVersion, "2.3.4.5"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleTimeStamp, creationDateTime.ToString()));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamExceptionCode, "1234"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamOffset, "0x1234"));
            eventSignature.InterpretParameters();

            StackHashEvent event1 =
                new StackHashEvent(creationDateTime, modifiedDateTime, "EventTypeName1", 100, eventSignature, 20, file1.Id, "bug");

            StackHashEvent event2 =
                new StackHashEvent(creationDateTime, modifiedDateTime, "EventTypeName2", 100, eventSignature, 20, file1.Id, "bug");

            m_Index.AddProduct(product1);
            m_Index.AddFile(product1, file1);
            m_Index.AddEvent(product1, file1, event1);
            m_Index.AddEvent(product1, file1, event2);

            StackHashEventInfoCollection eventInfos1 = new StackHashEventInfoCollection();

            int numEventInfos = 3;

            for (int i = 0; i < numEventInfos; i++)
            {
                DateTime nowTime = DateTime.Now;
                DateTime date    = new DateTime(nowTime.Year, nowTime.Month, nowTime.Day, nowTime.Hour, nowTime.Minute, 0);

                int localeId = i;
                StackHashEventInfo eventInfo =
                    new StackHashEventInfo(date.AddDays(i + 2), date.AddDays(i + 1), date.AddDays(i), "US", localeId, "English", "Windows Vista" + i.ToString(), "1.2.3.4 build 7", event1.Id);

                eventInfos1.Add(eventInfo);
            }

            m_Index.AddEventInfoCollection(product1, file1, event1, eventInfos1);


            StackHashEventInfoCollection eventInfos2 = new StackHashEventInfoCollection();

            // Add some other event infos for a different event.
            for (int i = 0; i < numEventInfos; i++)
            {
                DateTime nowTime = DateTime.Now;
                DateTime date    = new DateTime(nowTime.Year, nowTime.Month, nowTime.Day, nowTime.Hour, nowTime.Minute, 0);

                int localeId = i;
                StackHashEventInfo eventInfo =
                    new StackHashEventInfo(date.AddDays(i + 2), date.AddDays(i + 1), date.AddDays(i * 2), "US", localeId, "English", "Windows Vista" + i.ToString(), "1.2.3.4 build 7", event2.Id);

                eventInfos2.Add(eventInfo);
            }


            m_Index.AddEventInfoCollection(product1, file1, event2, eventInfos2);

            StackHashEventInfoCollection eventInfosRetrieved = m_Index.LoadEventInfoList(product1, file1, event1);

            Assert.AreEqual(numEventInfos, eventInfosRetrieved.Count);

            for (int i = 0; i < numEventInfos; i++)
            {
                StackHashEventInfo eventInfo = eventInfosRetrieved.FindEventInfo(eventInfos1[i]);

                Assert.AreEqual(0, eventInfos1[i].CompareTo(eventInfo));
            }

            DateTime mostRecentHitDate = m_Index.GetMostRecentHitDate(product1, file1, event1);

            Assert.AreEqual(eventInfos1[numEventInfos - 1].HitDateLocal, mostRecentHitDate);
            Assert.AreNotEqual(eventInfos1[0].HitDateLocal, mostRecentHitDate);
            Assert.AreNotEqual(eventInfos1[1].HitDateLocal, mostRecentHitDate);

            DateTime mostRecentHitDate2 = m_Index.GetMostRecentHitDate(product1, file1, event2);

            Assert.AreEqual(eventInfos2[numEventInfos - 1].HitDateLocal, mostRecentHitDate2);
            Assert.AreNotEqual(eventInfos2[0].HitDateLocal, mostRecentHitDate2);
            Assert.AreNotEqual(eventInfos2[1].HitDateLocal, mostRecentHitDate2);
        }
Example #11
0
        public void MergeOneInCommon()
        {
            m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder);
            m_Index.DeleteIndex();

            m_Index.Activate();

            DateTime         creationDateTime = new DateTime(2010, 04, 04, 22, 9, 0, DateTimeKind.Utc);
            DateTime         modifiedDateTime = new DateTime(2010, 05, 05, 23, 10, 0, DateTimeKind.Utc);
            StackHashProduct product1         =
                new StackHashProduct(creationDateTime, modifiedDateTime, null, 1, "TestProduct1", 20, 30, "2.10.02123.1293");

            StackHashFile file1 =
                new StackHashFile(creationDateTime, modifiedDateTime, 20, creationDateTime, "File1.dll", "2.3.4.5");

            StackHashEventSignature eventSignature = new StackHashEventSignature();

            eventSignature.Parameters = new StackHashParameterCollection();
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationName, "AppName"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationVersion, "1.2.3.4"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationTimeStamp, creationDateTime.ToString()));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleName, "ModuleName"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleVersion, "2.3.4.5"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleTimeStamp, creationDateTime.ToString()));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamExceptionCode, "1234"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamOffset, "0x1234"));
            eventSignature.InterpretParameters();

            StackHashEvent event1 =
                new StackHashEvent(creationDateTime, modifiedDateTime, "EventTypeName1", 100, eventSignature, 20, file1.Id, "bug");

            m_Index.AddProduct(product1);
            m_Index.AddFile(product1, file1);
            m_Index.AddEvent(product1, file1, event1);

            StackHashEventInfoCollection eventInfos1 = new StackHashEventInfoCollection();
            StackHashEventInfoCollection eventInfos2 = new StackHashEventInfoCollection();



            for (int i = 0; i < 3; i++)
            {
                DateTime nowTime = DateTime.Now;
                DateTime date    = new DateTime(nowTime.Year, nowTime.Month, nowTime.Day, nowTime.Hour, nowTime.Minute, 0);

                int localeId = i;

                StackHashEventInfo eventInfo = new StackHashEventInfo(date.AddDays(i * 1), date.AddDays(i * 2), date.AddDays(i * 3), "US", localeId, "English", "Windows Vista" + i.ToString(), "1.2.3.4 build 7", 100);

                if (i < 2)
                {
                    eventInfos1.Add(eventInfo);
                }
                if (i > 0)
                {
                    eventInfos2.Add(eventInfo);
                }
            }

            m_Index.AddEventInfoCollection(product1, file1, event1, eventInfos1);
            m_Index.AddEventInfoCollection(product1, file1, event1, eventInfos2);

            StackHashEventInfoCollection eventInfosRetrieved = m_Index.LoadEventInfoList(product1, file1, event1);

            Assert.AreEqual(3, eventInfosRetrieved.Count);

            int realListIndex = 0;

            for (int i = 0; i < 2; i++)
            {
                Assert.AreEqual(0, eventInfos1[i].CompareTo(eventInfosRetrieved[realListIndex]));
                realListIndex++;
            }
            for (int i = 1; i < 3; i++)
            {
                Assert.AreEqual(0, eventInfos2[i - 1].CompareTo(eventInfosRetrieved[realListIndex - 1]));
                realListIndex++;
            }
        }
Example #12
0
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        /// <summary>
        /// Add n event notes
        /// </summary>
        public void addGetNEventInfos(int numEventInfos, bool useSameLocale)
        {
            m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder);
            m_Index.DeleteIndex();

            m_Index.Activate();

            DateTime         creationDateTime = new DateTime(2010, 04, 04, 22, 9, 0, DateTimeKind.Utc);
            DateTime         modifiedDateTime = new DateTime(2010, 05, 05, 23, 10, 0, DateTimeKind.Utc);
            StackHashProduct product1         =
                new StackHashProduct(creationDateTime, modifiedDateTime, null, 1, "TestProduct1", 20, 30, "2.10.02123.1293");

            StackHashFile file1 =
                new StackHashFile(creationDateTime, modifiedDateTime, 20, creationDateTime, "File1.dll", "2.3.4.5");

            StackHashEventSignature eventSignature = new StackHashEventSignature();

            eventSignature.Parameters = new StackHashParameterCollection();
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationName, "AppName"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationVersion, "1.2.3.4"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationTimeStamp, creationDateTime.ToString()));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleName, "ModuleName"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleVersion, "2.3.4.5"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleTimeStamp, creationDateTime.ToString()));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamExceptionCode, "1234"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamOffset, "0x1234"));
            eventSignature.InterpretParameters();

            StackHashEvent event1 =
                new StackHashEvent(creationDateTime, modifiedDateTime, "EventTypeName1", 100, eventSignature, 20, file1.Id, "bug");

            m_Index.AddProduct(product1);
            m_Index.AddFile(product1, file1);
            m_Index.AddEvent(product1, file1, event1);

            StackHashEventInfoCollection eventInfos = new StackHashEventInfoCollection();

            int hitCount  = 1;
            int totalHits = 0;

            for (int i = 0; i < numEventInfos; i++)
            {
                DateTime nowTime = DateTime.Now;
                DateTime date    = new DateTime(nowTime.Year, nowTime.Month, nowTime.Day, nowTime.Hour, nowTime.Minute, 0);

                int localeId = 10;
                if (!useSameLocale)
                {
                    localeId += i;
                }

                totalHits += hitCount;
                StackHashEventInfo eventInfo = new StackHashEventInfo(date.AddDays(i * 1), date.AddDays(i * 2), date.AddDays(i * 3), "US", localeId, "English", "Windows Vista" + i.ToString(), "1.2.3.4 build 7", hitCount++);

                eventInfos.Add(eventInfo);
            }
            m_Index.AddEventInfoCollection(product1, file1, event1, eventInfos);

            StackHashEventInfoCollection eventInfosRetrieved = m_Index.LoadEventInfoList(product1, file1, event1);

            Assert.AreEqual(numEventInfos, eventInfos.Count);

            for (int i = 0; i < numEventInfos; i++)
            {
                Assert.AreEqual(0, eventInfos[i].CompareTo(eventInfosRetrieved[i]));
            }

            int totalHitsRetrieved = m_Index.GetHitCount(product1, file1, event1);

            Assert.AreEqual(totalHits, totalHitsRetrieved);
        }
Example #13
0
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        /// <summary>
        /// Add n event notes
        /// </summary>
        public void getPackages(int numProducts, int numFiles, int numEvents, int numEventInfos, int numCabs, bool useSameLocale, bool incrementingEventId, bool randomEventIds)
        {
            int    cabId     = 1000;
            int    eventId   = 1320080390;
            int    fileId    = 0x12345678;
            int    productId = 122;
            Random rand      = new Random(100);


            m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder);
            m_Index.DeleteIndex();

            m_Index.Activate();

            Dictionary <int, StackHashEventPackageCollection> expectedProductEvents = new Dictionary <int, StackHashEventPackageCollection>();
            StackHashProductCollection allProducts = new StackHashProductCollection();

            for (int productCount = 0; productCount < numProducts; productCount++)
            {
                DateTime         creationDateTime = new DateTime(2010, 04, 04, 22, 9, 0, DateTimeKind.Utc);
                DateTime         modifiedDateTime = new DateTime(2010, 05, 05, 23, 10, 0, DateTimeKind.Utc);
                StackHashProduct product1         =
                    new StackHashProduct(creationDateTime, modifiedDateTime, null, productId++, "TestProduct1", 20, 30, "2.10.02123.1293");

                m_Index.AddProduct(product1);
                allProducts.Add(product1);
                StackHashEventPackageCollection allAddedEvents = new StackHashEventPackageCollection();

                for (int fileCount = 0; fileCount < numFiles; fileCount++)
                {
                    StackHashFile file1 =
                        new StackHashFile(creationDateTime, modifiedDateTime, fileId++, creationDateTime, "File1.dll", "2.3.4.5");

                    StackHashEventSignature eventSignature = new StackHashEventSignature();
                    eventSignature.Parameters = new StackHashParameterCollection();
                    eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationName, "AppName"));
                    eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationVersion, "1.2.3.4"));
                    eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationTimeStamp, creationDateTime.ToString()));
                    eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleName, "ModuleName"));
                    eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleVersion, "2.3.4.5"));
                    eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleTimeStamp, creationDateTime.ToString()));
                    eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamExceptionCode, "1234"));
                    eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamOffset, "0x1234"));
                    eventSignature.InterpretParameters();

                    m_Index.AddFile(product1, file1);

                    for (int eventCount = 0; eventCount < numEvents; eventCount++)
                    {
                        StackHashEvent event1 =
                            new StackHashEvent(creationDateTime, modifiedDateTime, "EventTypeName1", eventId, eventSignature, eventCount, file1.Id, "bug" + eventCount.ToString());


                        if (randomEventIds)
                        {
                            eventId = rand.Next(100, 1320080390);
                        }
                        else
                        {
                            if (incrementingEventId)
                            {
                                eventId++;
                            }
                            else
                            {
                                eventId--;
                            }
                        }
                        m_Index.AddEvent(product1, file1, event1);

                        StackHashEventInfoCollection eventInfos = new StackHashEventInfoCollection();

                        int hitCount  = 1;
                        int totalHits = 0;
                        for (int i = 0; i < numEventInfos; i++)
                        {
                            DateTime nowTime = DateTime.Now;
                            DateTime date    = new DateTime(nowTime.Year, nowTime.Month, nowTime.Day, nowTime.Hour, nowTime.Minute, 0);

                            int localeId = 10;
                            if (!useSameLocale)
                            {
                                localeId += i;
                            }

                            totalHits += hitCount;
                            StackHashEventInfo eventInfo = new StackHashEventInfo(date.AddDays(i * 1), date.AddDays(i * 2), date.AddDays(i * 3), "US", localeId, "English", "Windows Vista" + i.ToString(), "1.2.3.4 build 7", hitCount++);

                            eventInfos.Add(eventInfo);
                        }
                        event1.TotalHits = totalHits;
                        m_Index.AddEventInfoCollection(product1, file1, event1, eventInfos);

                        StackHashCabCollection cabs = new StackHashCabCollection();

                        for (int i = 0; i < numCabs; i++)
                        {
                            DateTime nowTime = DateTime.Now;
                            DateTime date    = new DateTime(nowTime.Year, nowTime.Month, nowTime.Day, nowTime.Hour, nowTime.Minute, 0);

                            StackHashCab cab = new StackHashCab(date.AddDays(i * 1), date.AddDays(i * 2), event1.Id, event1.EventTypeName, "cab12345_23232.cab", cabId++, i * 2000);
                            cab.DumpAnalysis = new StackHashDumpAnalysis("2 days, 5 hours, 2 mins", "1 hour, 2 mins", "2.120.222.1121212", "Microsoft Windows Vista X64 6.0.212121212 (Build 2500)", "64 bit windows");

                            cab.CabDownloaded = false;
                            cabs.Add(cab);
                            m_Index.AddCab(product1, file1, event1, cab, true);
                        }

                        allAddedEvents.Add(new StackHashEventPackage(eventInfos, new StackHashCabPackageCollection(cabs), event1, product1.Id));
                    }
                }

                expectedProductEvents[product1.Id] = allAddedEvents;
            }


            foreach (StackHashProduct product in allProducts)
            {
                StackHashEventPackageCollection allEvents = m_Index.GetProductEvents(product);

                StackHashEventPackageCollection expectedEvents = expectedProductEvents[product.Id];

                Assert.AreNotEqual(null, allEvents);
                Assert.AreEqual(expectedEvents.Count, allEvents.Count);

                foreach (StackHashEventPackage package in allEvents)
                {
                    StackHashEventPackage matchedEvent = expectedEvents.FindEventPackage(package.EventData.Id, package.EventData.EventTypeName);

                    Assert.AreNotEqual(null, matchedEvent);

                    Assert.AreEqual(0, package.EventInfoList.CompareTo(matchedEvent.EventInfoList));
                    Assert.AreEqual(0, package.Cabs.CompareTo(matchedEvent.Cabs));
                }
            }
        }
Example #14
0
        /// <summary>
        /// Gets the rollup of hit dates.
        /// </summary>
        public void getHitDateRollup(int numEventInfos, int hitDateModulo)
        {
            m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder);
            m_Index.DeleteIndex();

            m_Index.Activate();

            DateTime         creationDateTime = new DateTime(2010, 04, 04, 22, 9, 0, DateTimeKind.Utc);
            DateTime         modifiedDateTime = new DateTime(2010, 05, 05, 23, 10, 0, DateTimeKind.Utc);
            StackHashProduct product1         =
                new StackHashProduct(creationDateTime, modifiedDateTime, null, 1, "TestProduct1", 20, 30, "2.10.02123.1293");

            StackHashFile file1 =
                new StackHashFile(creationDateTime, modifiedDateTime, 20, creationDateTime, "File1.dll", "2.3.4.5");

            StackHashEventSignature eventSignature = new StackHashEventSignature();

            eventSignature.Parameters = new StackHashParameterCollection();
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationName, "AppName"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationVersion, "1.2.3.4"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationTimeStamp, creationDateTime.ToString()));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleName, "ModuleName"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleVersion, "2.3.4.5"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleTimeStamp, creationDateTime.ToString()));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamExceptionCode, "1234"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamOffset, "0x1234"));
            eventSignature.InterpretParameters();

            StackHashEvent event1 =
                new StackHashEvent(creationDateTime, modifiedDateTime, "EventTypeName1", 100, eventSignature, 20, file1.Id, "bug");

            m_Index.AddProduct(product1);
            m_Index.AddFile(product1, file1);
            m_Index.AddEvent(product1, file1, event1);

            StackHashEventInfoCollection eventInfos = new StackHashEventInfoCollection();

            int    hitCount         = 1;
            int    totalHits        = 0;
            String localeCodeBase   = "US";
            String languageNameBase = "ENGLISH";
            String osBase           = "Vista";

            DateTime nowTime = DateTime.Now;
            DateTime date    = new DateTime(nowTime.Year, nowTime.Month, nowTime.Day, nowTime.Hour, nowTime.Minute, 0);

            for (int i = 0; i < numEventInfos; i++)
            {
                DateTime hitDate = date.AddDays(i % hitDateModulo);
                totalHits += hitCount;
                int localeId = i;
                int osId     = i;
                int hits     = (i % hitDateModulo);

                StackHashEventInfo eventInfo = new StackHashEventInfo(creationDateTime, modifiedDateTime, hitDate, languageNameBase + localeId.ToString(), localeId, localeCodeBase + localeId.ToString(), osBase + osId.ToString(), osId.ToString(), hits);

                eventInfos.Add(eventInfo);
            }

            m_Index.AddEventInfoCollection(product1, file1, event1, eventInfos);

            StackHashProductHitDateSummaryCollection hitDateSummary      = m_Index.GetHitDateSummary(product1.Id);
            StackHashProductHitDateSummaryCollection hitDateSummaryFresh = m_Index.GetHitDateSummaryFresh(product1.Id);

            Assert.AreEqual(0, hitDateSummary.CompareTo(hitDateSummaryFresh));

            Dictionary <DateTime, StackHashProductHitDateSummary> hitDateCheckList = new Dictionary <DateTime, StackHashProductHitDateSummary>();

            if (hitDateModulo < numEventInfos)
            {
                Assert.AreEqual(hitDateModulo, hitDateSummary.Count);
            }
            else
            {
                Assert.AreEqual(numEventInfos, hitDateSummary.Count);
            }

            int dateCount = 0;

            foreach (StackHashProductHitDateSummary hitData in hitDateSummary)
            {
                int expectedDateAdjust = dateCount % hitDateModulo;

                if (hitDateModulo >= numEventInfos)
                {
                    Assert.AreEqual(dateCount, hitData.TotalHits);
                }
                else
                {
                    Assert.AreEqual(expectedDateAdjust * ((numEventInfos / hitDateModulo)), hitData.TotalHits);
                }

                Assert.AreEqual(false, hitDateCheckList.ContainsKey(hitData.HitDate));
                hitDateCheckList.Add(hitData.HitDate, hitData);
                dateCount++;
            }

            // Update the stats fresh.
            m_Index.UpdateProductStatistics(product1.Id);
            StackHashProductHitDateSummaryCollection hitDateSummary2 = m_Index.GetHitDateSummary(product1.Id);

            Assert.AreEqual(0, hitDateSummary.CompareTo(hitDateSummary2));
        }
Example #15
0
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        /// <summary>
        /// Gets the rollup of locales.
        /// </summary>
        public void getLocaleRollup(int numEventInfos, int localeIdModulo)
        {
            m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder);
            m_Index.DeleteIndex();

            m_Index.Activate();

            DateTime         creationDateTime = new DateTime(2010, 04, 04, 22, 9, 0, DateTimeKind.Utc);
            DateTime         modifiedDateTime = new DateTime(2010, 05, 05, 23, 10, 0, DateTimeKind.Utc);
            StackHashProduct product1         =
                new StackHashProduct(creationDateTime, modifiedDateTime, null, 1, "TestProduct1", 20, 30, "2.10.02123.1293");

            StackHashFile file1 =
                new StackHashFile(creationDateTime, modifiedDateTime, 20, creationDateTime, "File1.dll", "2.3.4.5");

            StackHashEventSignature eventSignature = new StackHashEventSignature();

            eventSignature.Parameters = new StackHashParameterCollection();
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationName, "AppName"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationVersion, "1.2.3.4"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamApplicationTimeStamp, creationDateTime.ToString()));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleName, "ModuleName"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleVersion, "2.3.4.5"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamModuleTimeStamp, creationDateTime.ToString()));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamExceptionCode, "1234"));
            eventSignature.Parameters.Add(new StackHashParameter(StackHashEventSignature.ParamOffset, "0x1234"));
            eventSignature.InterpretParameters();

            StackHashEvent event1 =
                new StackHashEvent(creationDateTime, modifiedDateTime, "EventTypeName1", 100, eventSignature, 20, file1.Id, "bug");

            m_Index.AddProduct(product1);
            m_Index.AddFile(product1, file1);
            m_Index.AddEvent(product1, file1, event1);

            StackHashEventInfoCollection eventInfos = new StackHashEventInfoCollection();

            int    hitCount         = 1;
            int    totalHits        = 0;
            String localeCodeBase   = "US";
            String languageNameBase = "ENGLISH";

            for (int i = 1; i <= numEventInfos; i++)
            {
                DateTime nowTime = DateTime.Now;
                DateTime date    = new DateTime(nowTime.Year, nowTime.Month, nowTime.Day, nowTime.Hour, nowTime.Minute, 0);

                int localeId = (i % localeIdModulo) + 1;

                totalHits += hitCount;
                StackHashEventInfo eventInfo = new StackHashEventInfo(date.AddDays(i * 1), date.AddDays(i * 2), date.AddDays(i * 3), languageNameBase + localeId.ToString(), localeId, localeCodeBase + localeId.ToString(), "Windows Vista" + i.ToString(), "1.2.3.4 build 7", localeId);

                eventInfos.Add(eventInfo);
            }

            m_Index.AddEventInfoCollection(product1, file1, event1, eventInfos);

            StackHashProductLocaleSummaryCollection localeSummary      = m_Index.GetLocaleSummary(product1.Id);
            StackHashProductLocaleSummaryCollection localeSummaryFresh = m_Index.GetLocaleSummaryFresh(product1.Id);

            Assert.AreEqual(0, localeSummary.CompareTo(localeSummaryFresh));


            Dictionary <int, StackHashProductLocaleSummary> localeCheckList = new Dictionary <int, StackHashProductLocaleSummary>();

            if (localeIdModulo < numEventInfos)
            {
                Assert.AreEqual(localeIdModulo, localeSummary.Count);
            }
            else
            {
                Assert.AreEqual(numEventInfos, localeSummary.Count);
            }

            foreach (StackHashProductLocaleSummary localeData in localeSummary)
            {
                if (localeIdModulo >= numEventInfos)
                {
                    Assert.AreEqual(localeData.Lcid, localeData.TotalHits);
                }
                else
                {
                    Assert.AreEqual(localeData.Lcid * ((numEventInfos / localeIdModulo)), localeData.TotalHits);
                }

                Assert.AreEqual(localeCodeBase + localeData.Lcid.ToString(), localeData.Locale);
                Assert.AreEqual(languageNameBase + localeData.Lcid.ToString(), localeData.Language);
                Assert.AreEqual(false, localeCheckList.ContainsKey(localeData.Lcid));
                localeCheckList.Add(localeData.Lcid, localeData);
            }

            m_Index.UpdateProductStatistics(product1.Id);
            StackHashProductLocaleSummaryCollection localeSummary2 = m_Index.GetLocaleSummary(product1.Id);

            Assert.AreEqual(0, localeSummary.CompareTo(localeSummary2));
        }
Example #16
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);
        }