Exemple #1
0
        public static StackHashProductCollection GetProductsApi(ref Login login)
        {
            ProductCollection apiProducts = Product.GetProducts(ref login);

            StackHashProductCollection apiStackHashProducts = new StackHashProductCollection();

            // Add the products first.
            foreach (Product product in apiProducts)
            {
                StackHashProduct stackHashProduct = ObjectConversion.ConvertProduct(product);
                apiStackHashProducts.Add(stackHashProduct);
            }
            return(apiStackHashProducts);
        }
Exemple #2
0
        public static StackHashProductCollection GetProductsAtom(AtomFeed feed)
        {
            // Get the list of products.
            AtomProductCollection atomProducts = feed.GetProducts();

            // Convert to a StackHashProductCollection.
            StackHashProductCollection atomStackHashProducts = new StackHashProductCollection();

            foreach (AtomProduct atomProduct in atomProducts)
            {
                atomStackHashProducts.Add(atomProduct.Product);
            }

            return(atomStackHashProducts);
        }
Exemple #3
0
        public static StackHashProductCollection ConvertProductCollection(AtomProductCollection products)
        {
            if (products == null)
            {
                return(null);
            }

            StackHashProductCollection winQualProductCollection = new StackHashProductCollection();

            foreach (AtomProduct thisProduct in products)
            {
                winQualProductCollection.Add(thisProduct.Product);
            }

            return(winQualProductCollection);
        }
Exemple #4
0
        private void testSaveNProducts(IErrorIndex index, int numProducts)
        {
            index.Activate();
            StackHashProductCollection allProducts = new StackHashProductCollection();

            for (int i = 0; i < numProducts; i++)
            {
                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 + i, "TestProduct1" + i.ToString(), 20 + i, 30 + i, "2.10.02123.1293" + i.ToString());

                index.AddProduct(product1);
                allProducts.Add(product1);
            }

            // Get the product list.
            StackHashProductCollection products = index.LoadProductList();

            Assert.AreNotEqual(null, products);
            Assert.AreEqual(numProducts, products.Count);

            for (int i = 0; i < allProducts.Count; i++)
            {
                StackHashProduct thisProduct = products.FindProduct(allProducts[i].Id);
                Assert.AreNotEqual(null, thisProduct);

                Assert.AreEqual(0, allProducts[i].CompareTo(thisProduct));

                thisProduct = index.GetProduct(allProducts[i].Id);
                Assert.AreNotEqual(null, thisProduct);
                Assert.AreEqual(0, allProducts[i].CompareTo(thisProduct));


                // Check that the dates are stored in UTC.
                Assert.AreEqual(true, thisProduct.DateCreatedLocal.Kind == DateTimeKind.Utc);
                Assert.AreEqual(true, thisProduct.DateModifiedLocal.Kind == DateTimeKind.Utc);
            }

            Assert.AreEqual(numProducts, index.TotalProducts);
        }
Exemple #5
0
        public void getProductEvents(IErrorIndex index, int numProducts, int numFiles, int numEvents)
        {
            StackHashProductCollection products = new StackHashProductCollection();
            int productId            = 0x1234567;
            int eventsForThisProduct = numEvents;
            int eventId = 10000;
            int fileId  = 20;

            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 product          = new StackHashProduct(creationDateTime, modifiedDateTime, "www.files.com", productId + productCount, @"P""r:o?d:u@(XP_2k)", productCount, productCount + 1, "1:2:3:4");

                index.AddProduct(product);
                products.Add(product);

                for (int i = 0; i < numFiles; i++)
                {
                    StackHashFile file = new StackHashFile(DateTime.Now, DateTime.Now, fileId++, DateTime.Now, "FileName", "1.2.3.4");
                    index.AddFile(product, file);

                    for (int j = 0; j < eventsForThisProduct; j++)
                    {
                        StackHashEvent theEvent = new StackHashEvent(DateTime.Now, DateTime.Now, "Event type", eventId++, new StackHashEventSignature(), j, i + 1000);
                        theEvent.EventSignature.Parameters = new StackHashParameterCollection();
                        index.AddEvent(product, file, theEvent);
                    }
                }
                eventsForThisProduct += 10;
            }

            eventsForThisProduct = numEvents;
            for (int productCount = 0; productCount < numProducts; productCount++)
            {
                StackHashEventPackageCollection events = index.GetProductEvents(products[productCount]);

                Assert.AreEqual(numFiles * eventsForThisProduct, events.Count);
                eventsForThisProduct += 10;
            }
        }
Exemple #6
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));
                }
            }
        }