Example #1
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


        public void testDefaults(IErrorIndex index)
        {
            StackHashProduct product = new StackHashProduct(DateTime.Now, DateTime.Now, "files", 100, "Cucku Backup", 20, 1, "1.2.3.4");

            index.Activate();
            index.AddProduct(product);

            DateTime lastSyncDate          = index.GetLastSyncTimeLocal(product.Id);
            DateTime lastHitDate           = index.GetLastHitTimeLocal(product.Id);
            DateTime lastSyncCompletedDate = index.GetLastSyncCompletedTimeLocal(product.Id);
            DateTime lastSyncStartedDate   = index.GetLastSyncStartedTimeLocal(product.Id);


            Assert.AreEqual(new DateTime(0), lastSyncDate);
            Assert.AreEqual(new DateTime(0), lastHitDate);
            Assert.AreEqual(new DateTime(0), lastSyncCompletedDate);
            Assert.AreEqual(new DateTime(0), lastSyncStartedDate);
        }
Example #2
0
        public void ConflictProductAndFull()
        {
            StackHashBugReportData           data1    = new StackHashBugReportData(null, null, null, null, null, StackHashReportOptions.IncludeAllObjects);
            StackHashBugReportDataCollection allData1 = new StackHashBugReportDataCollection()
            {
                data1
            };

            StackHashProduct       product2 = new StackHashProduct(DateTime.Now, DateTime.Now, null, 1, "StackHash", 0, 0, "1.2.3.4");
            StackHashBugReportData data2    = new StackHashBugReportData(product2, null, null, null, null, StackHashReportOptions.IncludeAllObjects);

            StackHashBugReportDataCollection allData2 = new StackHashBugReportDataCollection()
            {
                data2
            };

            Assert.AreEqual(true, allData2.IsConflicting(allData1));
        }
Example #3
0
        private bool runAutoScripts(StackHashProduct product, StackHashFile file, StackHashEvent theEvent, StackHashCab cab, StackHashScriptDumpType dumpType)
        {
            Collection <AutoScriptBase> autoScripts  = m_TaskParameters.TheScriptManager.AutoScripts;
            ScriptResultsManager        scriptRunner = m_TaskParameters.TheScriptResultsManager;

            bool dumpAnalysisProduced = false;

            // Analyse the Unmanaged mode autoscripts first - as these determine if the dump is managed or not and hence whether
            // the managed scripts will be run. The AutoScripts property above returns the autoscripts in the correct order.
            foreach (AutoScriptBase autoScript in autoScripts)
            {
                bool dumpIsManaged = ((cab.DumpAnalysis != null) && (!String.IsNullOrEmpty(cab.DumpAnalysis.DotNetVersion)));

                if (autoScript.ScriptSettings.DumpType != dumpType)
                {
                    continue;
                }

                if ((autoScript.ScriptSettings.DumpType == StackHashScriptDumpType.ManagedOnly) && (!dumpIsManaged))
                {
                    continue;
                }

                bool forceAutoScript = false;
                if ((cab.DumpAnalysis == null) || (cab.DumpAnalysis.MachineArchitecture == null) || (cab.DumpAnalysis.OSVersion == null))
                {
                    forceAutoScript = true;
                }

                // Run the auto script on the cab if it hasn't already been run.
                StackHashScriptResult scriptResult =
                    scriptRunner.RunScript(product, file, theEvent, cab, null, autoScript.ScriptName, false, null, forceAutoScript);

                // Analyze the results.
                if (scriptResult != null)
                {
                    cab.DumpAnalysis     = autoScript.AnalyzeScriptResults(cab.DumpAnalysis, scriptResult);
                    dumpAnalysisProduced = true;
                    m_ConsecutiveErrors  = 0;
                }
            }

            return(dumpAnalysisProduced);
        }
Example #4
0
        // Add N files to a single product.
        public void testAddNFiles(IErrorIndex index, int numFiles)
        {
            index.Activate();
            StackHashProduct product =
                new StackHashProduct(DateTime.Now, DateTime.Now, "http://www.cucku.com", 1, "TestProduct1", 20, 30, "2.10.02123.1293");
            List <StackHashFile> allFiles = new List <StackHashFile>();

            index.AddProduct(product);

            for (int i = 0; i < numFiles; i++)
            {
                StackHashFile file = new StackHashFile(new DateTime(100 + i), new DateTime(101 + i), 1 + i,
                                                       new DateTime(102 + i), "filename.dll" + i.ToString(), "1.2.3.4");
                allFiles.Add(file);
                index.AddFile(product, file);
            }

            // Now make sure all files appear in the database list.
            StackHashFileCollection files = index.LoadFileList(product);

            Assert.AreEqual(numFiles, files.Count);

            // Note this only works because the files are in alphabetical order.
            for (int i = 0; i < numFiles; i++)
            {
                StackHashFile thisFile = index.GetFile(product, 1 + i);
                Assert.AreEqual(allFiles[i].DateCreatedLocal, thisFile.DateCreatedLocal);
                Assert.AreEqual(allFiles[i].DateModifiedLocal, thisFile.DateModifiedLocal);
                Assert.AreEqual(allFiles[i].Id, thisFile.Id);
                Assert.AreEqual(allFiles[i].LinkDateLocal, thisFile.LinkDateLocal);
                Assert.AreEqual(allFiles[i].Name, thisFile.Name);
                Assert.AreEqual(allFiles[i].Version, thisFile.Version);

                thisFile = files.FindFile(allFiles[i].Id);
                Assert.AreNotEqual(null, thisFile);

                Assert.AreEqual(allFiles[i].DateCreatedLocal, thisFile.DateCreatedLocal);
                Assert.AreEqual(allFiles[i].DateModifiedLocal, thisFile.DateModifiedLocal);
                Assert.AreEqual(allFiles[i].Id, thisFile.Id);
                Assert.AreEqual(allFiles[i].LinkDateLocal, thisFile.LinkDateLocal);
                Assert.AreEqual(allFiles[i].Name, thisFile.Name);
                Assert.AreEqual(allFiles[i].Version, thisFile.Version);
            }
        }
Example #5
0
        private void testFileListExists(IErrorIndex index, bool expectedResult)
        {
            index.Activate();
            StackHashProduct product =
                new StackHashProduct(DateTime.Now, DateTime.Now, "http://www.cucku.com", 1, "TestProduct1", 20, 30, "2.10.02123.1293");

            index.AddProduct(product);

            StackHashFile file = new StackHashFile(DateTime.Now, DateTime.Now, 1, DateTime.Now, "FileName", "1.2.3.4");

            file.Id = 1;

            if (expectedResult)
            {
                index.AddFile(product, file);
            }

            Assert.AreEqual(expectedResult, index.FileExists(product, file));
        }
Example #6
0
        public void testAddSameFileTwiceWithReset(bool useCache)
        {
            IErrorIndex index = new XmlErrorIndex(m_TempPath, "Cucku");

            if (useCache)
            {
                index = new ErrorIndexCache(index);
            }


            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), 1, new DateTime(102), "filename.dll", "1.2.3.4");

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

            // Reload.
            index = new XmlErrorIndex(m_TempPath, "Cucku");
            if (useCache)
            {
                index = new ErrorIndexCache(index);
            }

            index.Activate();

            // Use same ID - should replace existing file data.
            file = new StackHashFile(new DateTime(200), new DateTime(201), 1, new DateTime(101), "filename.dll", "1.2.3.4");
            index.AddFile(product, file);

            StackHashFileCollection files = index.LoadFileList(product);

            Assert.AreEqual(1, files.Count);

            Assert.AreEqual(file.DateCreatedLocal, files[0].DateCreatedLocal);
            Assert.AreEqual(file.DateModifiedLocal, files[0].DateModifiedLocal);
            Assert.AreEqual(file.Id, files[0].Id);
            Assert.AreEqual(file.LinkDateLocal, files[0].LinkDateLocal);
            Assert.AreEqual(file.Name, files[0].Name);
            Assert.AreEqual(file.Version, files[0].Version);
        }
Example #7
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 #8
0
        private void testCacheInitialiseNProducts(IErrorIndex realIndex, int numProducts)
        {
            realIndex.Activate();
            StackHashProductCollection allProducts = new StackHashProductCollection();

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

                realIndex.AddProduct(product1);
            }

            // Hook up the cache and call LoadProductList.
            ErrorIndexCache indexCache = new ErrorIndexCache(realIndex);

            indexCache.Activate();

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

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

            for (int i = 0; i < allProducts.Count; i++)
            {
                Assert.AreEqual(0, allProducts[0].CompareTo(products.FindProduct(allProducts[0].Id)));
            }

            // Hook up the cache afresh and call GetProduct.
            indexCache = new ErrorIndexCache(realIndex);
            indexCache.Activate();
            for (int i = 0; i < allProducts.Count; i++)
            {
                StackHashProduct thisProduct = indexCache.GetProduct(allProducts[i].Id);
                Assert.AreNotEqual(null, thisProduct);
                Assert.AreEqual(0, allProducts[i].CompareTo(thisProduct));
            }
        }
Example #9
0
        public void GetFilesForProductNoFiles()
        {
            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");

            StackHashFileCollection files = m_Index.LoadFileList(product1);

            Assert.AreNotEqual(null, files);
            Assert.AreEqual(0, files.Count);
        }
Example #10
0
        /// <summary>
        /// Converts a WinQual Product object to a StackHashProduct.
        /// </summary>
        /// <param name="product">WinQual product to convert.</param>
        /// <returns>StackHashProduct equivalent type.</returns>
        public static StackHashProduct ConvertProduct(Product product)
        {
            if (product == null)
            {
                throw new ArgumentNullException("product");
            }

            // Construct a WinQualProduct from a Product (returned from WinQual site).
            StackHashProduct newProduct = new StackHashProduct(
                product.DateCreatedLocal.ToUniversalTime(),
                product.DateModifiedLocal.ToUniversalTime(),
                product.FilesLink.ToString(),
                product.ID,
                product.Name,
                product.TotalEvents,
                product.TotalResponses,
                product.Version);

            return(newProduct);
        }
Example #11
0
        private void testAddEventInfoNullFile(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");

                index.AddProduct(product);
                StackHashEvent theEvent = new StackHashEvent();
                StackHashEventInfoCollection eventInfoCollection = new StackHashEventInfoCollection();

                index.AddEventInfoCollection(product, null, theEvent, eventInfoCollection);
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("file", ex.ParamName);
                throw;
            }
        }
Example #12
0
        /// <summary>
        /// Copies all files for the specified product from the source index to the destination index.
        /// </summary>
        /// <param name="product">The product whose files are to be copied.</param>
        private void copyFiles(StackHashProduct product)
        {
            StackHashFileCollection files = m_SourceIndex.LoadFileList(product);

            foreach (StackHashFile file in files)
            {
                if (this.CurrentTaskState.AbortRequested)
                {
                    throw new StackHashException("Index file copy aborted", StackHashServiceErrorCode.Aborted);
                }

                if (!m_DestinationIndex.FileExists(product, file))
                {
                    m_DestinationIndex.AddFile(product, file);
                }

                // Copy all events associated with the specified file.
                copyEvents(product, file);
            }
        }
Example #13
0
        private void testAddCabNoteProductDoesntExist(IErrorIndex index)
        {
            try
            {
                index.Activate();
                StackHashProduct product = new StackHashProduct(DateTime.Now, DateTime.Now, "fileslink", 1, "Name", 10, 11, "version");

                StackHashFile      file     = new StackHashFile();
                StackHashEvent     theEvent = new StackHashEvent();
                StackHashCab       cab      = new StackHashCab();
                StackHashNoteEntry note     = new StackHashNoteEntry();

                index.AddCabNote(product, file, theEvent, cab, note);
            }
            catch (ArgumentException ex)
            {
                Assert.AreEqual("product", ex.ParamName);
                throw;
            }
        }
Example #14
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);
        }
Example #15
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;
            }
        }
Example #16
0
        private void testAddEventInfoNullEvent(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");
                index.AddProduct(product);
                index.AddFile(product, file);

                StackHashEventInfoCollection eventInfoCollection = new StackHashEventInfoCollection();

                index.AddEventInfoCollection(product, file, null, eventInfoCollection);
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("theEvent", ex.ParamName);
                throw;
            }
        }
Example #17
0
        /// <summary>
        /// Determines if the specified cab should be processed.
        /// </summary>
        /// <param name="product">The product to check.</param>
        /// <param name="file">The file to check.</param>
        /// <param name="theEvent">The event to check.</param>
        /// <param name="cab">The product to check.</param>
        /// <returns>True - process the cab, false - don't process.</returns>
        private bool shouldProcessCab(StackHashProduct product, StackHashFile file, StackHashEvent theEvent, StackHashCab cab)
        {
            if (product == null)
            {
                return(false);
            }
            if (file == null)
            {
                return(false);
            }
            if (theEvent == null)
            {
                return(false);
            }
            if (cab == null)
            {
                return(false);
            }

            return(true);
        }
Example #18
0
        private void testAddCabNoteNullEvent(IErrorIndex index)
        {
            try
            {
                index.Activate();
                StackHashProduct   product = new StackHashProduct(DateTime.Now, DateTime.Now, "fileslink", 1, "Name", 10, 11, "version");
                StackHashFile      file    = new StackHashFile(DateTime.Now, DateTime.Now, 6, DateTime.Now, "FileName", "FileVersion");
                StackHashCab       cab     = new StackHashCab();
                StackHashNoteEntry note    = new StackHashNoteEntry();

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

                index.AddCabNote(product, file, null, cab, note);
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("theEvent", ex.ParamName);
                throw;
            }
        }
Example #19
0
        /// <summary>
        /// Process an event note table update. This may indicate a new item or the change to an existing item.
        /// </summary>
        private bool processEventNoteUpdate(StackHashBugTrackerUpdate update)
        {
            // Get the associated product and file information.
            StackHashProduct   product  = m_Index.GetProduct((int)update.ProductId);
            StackHashFile      file     = m_Index.GetFile(product, (int)update.FileId);
            StackHashEvent     theEvent = m_Index.GetEvent(product, file, new StackHashEvent((int)update.EventId, update.EventTypeName));
            StackHashNoteEntry note     = m_Index.GetEventNote((int)update.ChangedObjectId);

            if ((product == null) || (file == null) || (theEvent == null) || (note == null))
            {
                DiagnosticsHelper.LogMessage(DiagSeverity.Warning, "Processing Event Note: Inconsistent Update Table Entry");
                return(false);
            }

            BugTrackerProduct   btProduct      = new BugTrackerProduct(product.Name, product.Version, product.Id);
            BugTrackerFile      btFile         = new BugTrackerFile(file.Name, file.Version, file.Id);
            NameValueCollection eventSignature = new NameValueCollection();

            foreach (StackHashParameter param in theEvent.EventSignature.Parameters)
            {
                eventSignature.Add(param.Name, param.Value);
            }

            BugTrackerEvent btEvent = new BugTrackerEvent(theEvent.BugId, theEvent.PlugInBugId, theEvent.Id, theEvent.EventTypeName,
                                                          theEvent.TotalHits, eventSignature);


            BugTrackerNote btEventNote = new BugTrackerNote(note.TimeOfEntry, note.Source, note.User, note.Note);

            String newBugId = null;

            if (update.TypeOfChange == StackHashChangeType.NewEntry)
            {
                newBugId = m_TaskParameters.PlugInContext.EventNoteAdded(null, BugTrackerReportType.Automatic, btProduct, btFile, btEvent, btEventNote);
            }

            setPlugInBugReference(product, file, theEvent, newBugId);

            return(true);
        }
Example #20
0
        public void AddOneFileGetFile()
        {
            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");

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

            StackHashFile dbFile1 = m_Index.GetFile(product1, file1.Id);

            Assert.AreEqual(0, file1.CompareTo(dbFile1));
        }
Example #21
0
        private void testAddCabNoteNullNote(IErrorIndex index)
        {
            try
            {
                index.Activate();
                StackHashProduct product  = new StackHashProduct(DateTime.Now, DateTime.Now, "fileslink", 1, "Name", 10, 11, "version");
                StackHashFile    file     = new StackHashFile(DateTime.Now, DateTime.Now, 6, DateTime.Now, "FileName", "FileVersion");
                StackHashEvent   theEvent = new StackHashEvent(DateTime.Now, DateTime.Now, "TypeName", 10, new StackHashEventSignature(), 10, 2);
                StackHashCab     cab      = new StackHashCab();

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

                index.AddCabNote(product, file, theEvent, cab, null);
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("note", ex.ParamName);
                throw;
            }
        }
Example #22
0
        public void ConflictEventAndSameProduct()
        {
            StackHashProduct product1 = new StackHashProduct(DateTime.Now, DateTime.Now, null, 1, "StackHash", 0, 0, "1.2.3.4");

            StackHashBugReportData           data1    = new StackHashBugReportData(product1, null, null, null, null, StackHashReportOptions.IncludeAllObjects);
            StackHashBugReportDataCollection allData1 = new StackHashBugReportDataCollection()
            {
                data1
            };

            StackHashProduct product2 = new StackHashProduct(DateTime.Now, DateTime.Now, null, 1, "StackHash", 0, 0, "1.2.3.4");
            StackHashFile    file2    = new StackHashFile(DateTime.Now, DateTime.Now, 1, DateTime.Now, "File1", "1.2.3.4");
            StackHashEvent   event2   = new StackHashEvent(1, "EventTypeName1");

            StackHashBugReportData           data2    = new StackHashBugReportData(product2, file2, event2, null, null, StackHashReportOptions.IncludeAllObjects);
            StackHashBugReportDataCollection allData2 = new StackHashBugReportDataCollection()
            {
                data2
            };

            Assert.AreEqual(true, allData2.IsConflicting(allData1));
        }
Example #23
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

        public void moveIndex(IErrorIndex errorIndex, int numProducts, String newIndexPath, String newIndexName, bool activate)
        {
            String originalIndexPath = errorIndex.ErrorIndexPath;
            String originalIndexName = errorIndex.ErrorIndexName;

            if (activate)
            {
                errorIndex.Activate();

                for (int i = 0; i < numProducts; i++)
                {
                    StackHashProduct product = new StackHashProduct(DateTime.Now, DateTime.Now, "www.link.com", i, "p" + i.ToString(),
                                                                    i, i, "version");
                    errorIndex.AddProduct(product);
                }

                // Now move the index.
                errorIndex.Deactivate();
            }

            errorIndex.MoveIndex(newIndexPath, newIndexName, null, true);
            if (activate)
            {
                errorIndex.Activate();
            }

            // Check the results.
            if (activate)
            {
                Assert.AreEqual(false, Directory.Exists(originalIndexPath + "\\" + originalIndexName));
                Assert.AreEqual(true, Directory.Exists(newIndexPath + "\\" + newIndexName));
            }
            else
            {
                // Shouldn't have done anything - if never activated then even the source should not exist.
                Assert.AreEqual(false, Directory.Exists(originalIndexPath + "\\" + originalIndexName));
                Assert.AreEqual(false, Directory.Exists(newIndexPath + "\\" + newIndexName));
            }
        }
Example #24
0
        public void AddFileNullFile()
        {
            m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder);
            m_Index.DeleteIndex();
            try
            {
                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");

                m_Index.AddProduct(product1);

                m_Index.AddFile(product1, null);
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("file", ex.ParamName);
                throw;
            }
        }
Example #25
0
        public StackHashScriptResult GetResultFileData(StackHashProduct product,
                                                       StackHashFile file, StackHashEvent theEvent, StackHashCab cab, String scriptName)
        {
            if (scriptName == null)
            {
                throw new ArgumentNullException("scriptName");
            }
            if (cab == null)
            {
                throw new ArgumentNullException("cab");
            }

            String cabFileFolder = m_ErrorIndex.GetCabFolder(product, file, theEvent, cab);

            String resultsFileName = String.Format(CultureInfo.InvariantCulture,
                                                   "{0}\\Analysis\\{1}.log", cabFileFolder, scriptName);

            if (!File.Exists(resultsFileName))
            {
                return(null);
            }

            StackHashScriptResult result = null;

            try
            {
                result = new StackHashScriptResult(resultsFileName);
            }
            catch (System.Exception ex)
            {
                // Don't allow corrupt files to stop the search.
                DiagnosticsHelper.LogException(DiagSeverity.Warning, "Corrupt or missing results file: " + scriptName +
                                               " for cab " + cab.Id.ToString(CultureInfo.InvariantCulture), ex);
            }

            return(result);
        }
Example #26
0
        private void testAddCabNNotes(IErrorIndex index, int numNotes)
        {
            index.Activate();
            StackHashProduct product  = new StackHashProduct(DateTime.Now, DateTime.Now, "fileslink", 1, "Name", 10, 11, "version");
            StackHashFile    file     = new StackHashFile(DateTime.Now, DateTime.Now, 6, DateTime.Now, "FileName", "FileVersion");
            StackHashEvent   theEvent = new StackHashEvent(DateTime.Now, DateTime.Now, "TypeName", 10, new StackHashEventSignature(), 10, 2);
            StackHashCab     cab      = new StackHashCab(DateTime.Now, DateTime.Now, 10, "Type", "EventFileName", 10, 100);

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

            StackHashNotes allNotes = new StackHashNotes();

            for (int i = 0; i < numNotes; i++)
            {
                StackHashNoteEntry note = new StackHashNoteEntry(new DateTime(i), "Source" + i.ToString(), "User" + i.ToString(), "Notes...." + i.ToString());
                allNotes.Add(note);
                index.AddCabNote(product, file, theEvent, cab, note);
            }


            // Get the list back.
            StackHashNotes notes = index.GetCabNotes(product, file, theEvent, cab);

            Assert.AreEqual(numNotes, notes.Count);

            for (int i = 0; i < numNotes; i++)
            {
                Assert.AreEqual(allNotes[i].TimeOfEntry, notes[i].TimeOfEntry);
                Assert.AreEqual(allNotes[i].Source, notes[i].Source);
                Assert.AreEqual(allNotes[i].User, notes[i].User);
                Assert.AreEqual(allNotes[i].Note, notes[i].Note);
            }
        }
Example #27
0
        public void Add100Files()
        {
            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");

            int numFiles = 100;

            m_Index.AddProduct(product1);

            List <StackHashFile> addedFiles = new List <StackHashFile>();

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

                m_Index.AddFile(product1, file1);
                addedFiles.Add(file1);

                StackHashFileCollection files = m_Index.LoadFileList(product1);
                Assert.AreNotEqual(null, files);
                Assert.AreEqual(i + 1, files.Count);

                for (int j = 0; j < i; j++)
                {
                    Assert.AreEqual(0, addedFiles[j].CompareTo(files[j]));
                }
            }
        }
Example #28
0
        /// <summary>
        /// Process a product table update. This may indicate a new item or the change to an existing item.
        /// </summary>
        private bool processProductUpdate(StackHashBugTrackerUpdate update)
        {
            // Get the associated product information.
            StackHashProduct product = m_Index.GetProduct((int)update.ProductId);

            if (product == null)
            {
                DiagnosticsHelper.LogMessage(DiagSeverity.Warning, "Processing Product: Inconsistent Update Table Entry");
                return(false);
            }

            BugTrackerProduct btProduct = new BugTrackerProduct(product.Name, product.Version, product.Id);

            if (update.TypeOfChange == StackHashChangeType.NewEntry)
            {
                m_TaskParameters.PlugInContext.ProductAdded(null, BugTrackerReportType.Automatic, btProduct);
            }
            else
            {
                m_TaskParameters.PlugInContext.ProductUpdated(null, BugTrackerReportType.Automatic, btProduct);
            }

            return(true);
        }
Example #29
0
        private void testGetProductUnknownId(IErrorIndex index)
        {
            index.Activate();
            int              i                = 0;
            int              productId        = 200;
            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 + i, 30 + i, "2.10.02123.1293");

            index.AddProduct(product1);

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

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

            Assert.AreEqual(0, product1.CompareTo(products[0]));

            StackHashProduct thisProduct = index.GetProduct(product1.Id + 1);

            Assert.AreEqual(null, thisProduct);
        }
Example #30
0
        private void testAddSameProductTwice(IErrorIndex index)
        {
            index.Activate();
            int      i                = 0;
            int      productId        = 200;
            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 + i, 30 + i, "2.10.02123.1293", 20);

            index.AddProduct(product1);

            i = 1; // Causes the product fields to change (except the product id).
            StackHashProduct product2 =
                new StackHashProduct(creationDateTime.AddDays(1), modifiedDateTime.AddDays(1), null, productId, "TestProduct1", 20 + i + 1, 30 + i + 2, "2.10.02123.1293", 100);

            // Add the same product ID again - should replace.
            index.AddProduct(product2);

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

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

            Assert.AreEqual(0, product2.CompareTo(products[0]));

            // Should not have updated the non-WinQual fields.
            Assert.AreEqual(product1.TotalStoredEvents, products[0].TotalStoredEvents);

            StackHashProduct thisProduct = index.GetProduct(product2.Id);

            Assert.AreNotEqual(null, thisProduct);
            Assert.AreEqual(0, product2.CompareTo(thisProduct));
        }