Exemplo n.º 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;
            }
        }
Exemplo n.º 2
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.º 3
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);
        }
Exemplo n.º 4
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.º 5
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);
        }