Beispiel #1
0
        /// <summary>
        /// Checks for localeCode and localeName accepted ok.
        /// </summary>
        public void addMultipleLocales(StackHashProductLocaleSummaryCollection localesToAdd)
        {
            // Create a clean index.
            m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder);
            m_Index.DeleteIndex();
            m_Index.Activate();

            int productId = 1234;

            // Check a locale that doesn't exist.
            Assert.AreEqual(false, m_Index.LocaleSummaryExists(1245, 12121));

            StackHashProductLocaleSummaryCollection allLocaleSummaries = new StackHashProductLocaleSummaryCollection();

            foreach (StackHashProductLocaleSummary locale in localesToAdd)
            {
                m_Index.AddLocale(locale.Lcid, locale.Locale, locale.Language);
                m_Index.AddLocaleSummary(productId, locale.Lcid, locale.TotalHits, false);

                // Check the locale exists now.
                Assert.AreEqual(true, m_Index.LocaleSummaryExists(productId, locale.Lcid));

                // Get the specific locale and make sure it was stored properly.
                StackHashProductLocaleSummary summary = m_Index.GetLocaleSummaryForProduct(productId, locale.Lcid);
                Assert.AreEqual(locale.Lcid, summary.Lcid);
                Assert.AreEqual(locale.Locale, summary.Locale);
                Assert.AreEqual(locale.Language, summary.Language);
                Assert.AreEqual(locale.TotalHits, summary.TotalHits);
            }


            StackHashProductLocaleSummaryCollection localeSummaryCollection = m_Index.GetLocaleSummaries(productId);

            Assert.AreEqual(localesToAdd.Count, localeSummaryCollection.Count);

            foreach (StackHashProductLocaleSummary loadedLocale in localeSummaryCollection)
            {
                StackHashProductLocaleSummary expectedSummary = localesToAdd.FindLocale(loadedLocale.Lcid);
                Assert.AreEqual(0, expectedSummary.CompareTo(loadedLocale));
            }

            // Now update the statistics again using the same values.
            m_Index.UpdateLocaleStatistics(productId, localesToAdd, false);

            // Values should have doubled.
            localeSummaryCollection = m_Index.GetLocaleSummaries(productId);
            Assert.AreEqual(localesToAdd.Count, localeSummaryCollection.Count);

            foreach (StackHashProductLocaleSummary loadedLocale in localeSummaryCollection)
            {
                StackHashProductLocaleSummary expectedSummary = localesToAdd.FindLocale(loadedLocale.Lcid);
                expectedSummary.TotalHits *= 2;
                Assert.AreEqual(0, expectedSummary.CompareTo(loadedLocale));
            }
        }
Beispiel #2
0
        public void AddMultipleLocales()
        {
            StackHashProductLocaleSummaryCollection allLocales = new StackHashProductLocaleSummaryCollection()
            {
                new StackHashProductLocaleSummary(null, 100, null, 10),
                new StackHashProductLocaleSummary("English", 101, null, 10),
                new StackHashProductLocaleSummary(null, 102, "en-us", 10),
                new StackHashProductLocaleSummary("English", 103, "en-us", 10),
            };

            addMultipleLocales(allLocales);
        }
Beispiel #3
0
        /// <summary>
        /// Checks for localeCode and localeName accepted ok.
        /// </summary>
        public void addSingleLocale(int localeId, String localeCode, String localeName)
        {
            // Create a clean index.
            m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder);
            m_Index.DeleteIndex();
            m_Index.Activate();

            int productId = 1234;

            // Check a locale that doesn't exist.
            Assert.AreEqual(false, m_Index.LocaleSummaryExists(1245, 12121));

            StackHashProductLocaleSummaryCollection allLocaleSummaries = new StackHashProductLocaleSummaryCollection();

            int totalHits = 100;

            m_Index.AddLocale(localeId, localeCode, localeName);
            m_Index.AddLocaleSummary(productId, localeId, totalHits, false);

            // Check the locale exists now.
            Assert.AreEqual(true, m_Index.LocaleSummaryExists(productId, localeId));

            // Get the specific locale and make sure it was stored properly.
            StackHashProductLocaleSummary summary = m_Index.GetLocaleSummaryForProduct(productId, localeId);

            Assert.AreEqual(localeId, summary.Lcid);
            Assert.AreEqual(localeCode, summary.Locale);
            Assert.AreEqual(localeName, summary.Language);
            Assert.AreEqual(totalHits, summary.TotalHits);


            StackHashProductLocaleSummaryCollection localeSummaryCollection = m_Index.GetLocaleSummaries(productId);

            Assert.AreEqual(1, localeSummaryCollection.Count);

            StackHashProductLocaleSummary expectedSummary = new StackHashProductLocaleSummary(localeName, localeId, localeCode, totalHits);

            Assert.AreEqual(0, expectedSummary.CompareTo(localeSummaryCollection[0]));

            // Now update the statistics again using the same values.
            allLocaleSummaries.Add(expectedSummary);
            m_Index.UpdateLocaleStatistics(productId, allLocaleSummaries, false);

            // Values should have doubled.
            localeSummaryCollection = m_Index.GetLocaleSummaries(productId);
            Assert.AreEqual(1, localeSummaryCollection.Count);

            expectedSummary = new StackHashProductLocaleSummary(localeName, localeId, localeCode, totalHits * 2);
            Assert.AreEqual(0, expectedSummary.CompareTo(localeSummaryCollection[0]));
        }
Beispiel #4
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 addLocaleSummaries(int numLocaleSummaries)
        {
            // Create a clean index.
            m_Index = new SqlErrorIndex(StackHashSqlConfiguration.Default, SqlUtils.UnitTestDatabase, m_RootCabFolder);
            m_Index.DeleteIndex();
            m_Index.Activate();

            String localeCodeBase = "US-";
            String localeNameBase = "ENGLISH";
            int    productId      = 1234;

            // Check a locale that doesn't exist.
            Assert.AreEqual(false, m_Index.LocaleSummaryExists(1245, 12121));

            StackHashProductLocaleSummaryCollection allLocaleSummaries = new StackHashProductLocaleSummaryCollection();

            for (int localeCount = 0; localeCount < numLocaleSummaries; localeCount++)
            {
                int localeId  = 1000 + localeCount;
                int totalHits = localeCount + 1;
                m_Index.AddLocale(localeId, localeCodeBase + localeId.ToString(), localeNameBase + localeId.ToString());

                m_Index.AddLocaleSummary(productId, localeId, totalHits, false);

                // Check the locale exists now.
                Assert.AreEqual(true, m_Index.LocaleSummaryExists(productId, localeId));

                // Get the specific locale and make sure it was stored properly.
                StackHashProductLocaleSummary summary = m_Index.GetLocaleSummaryForProduct(productId, localeId);
                Assert.AreEqual(localeId, summary.Lcid);
                Assert.AreEqual(localeCodeBase + localeId.ToString(), summary.Locale);
                Assert.AreEqual(localeNameBase + localeId.ToString(), summary.Language);
                Assert.AreEqual(totalHits, summary.TotalHits);

                allLocaleSummaries.Add(summary);
            }

            StackHashProductLocaleSummaryCollection localeSummaryCollection = m_Index.GetLocaleSummaries(productId);

            Assert.AreEqual(numLocaleSummaries, localeSummaryCollection.Count);

            foreach (StackHashProductLocaleSummary localeData in localeSummaryCollection)
            {
                // Find the matching locale in the expected list.
                StackHashProductLocaleSummary expectedSummary = allLocaleSummaries.FindLocale(localeData.Lcid);

                Assert.AreNotEqual(null, expectedSummary);
                Assert.AreEqual(0, expectedSummary.CompareTo(localeData));
            }
        }
Beispiel #5
0
        public void UpdateHitSummaries(StackHashProductHitDateSummaryCollection hitDateSummary,
                                       StackHashProductLocaleSummaryCollection localeSummary,
                                       StackHashProductOperatingSystemSummaryCollection osSummary)
        {
            if (hitDateSummary != _hitDateSummary)
            {
                _hitDateSummary = hitDateSummary;
                RaisePropertyChanged("HitDateSummary");
            }

            if (localeSummary != _localeSummary)
            {
                _localeSummary = localeSummary;
                RaisePropertyChanged("LocaleSummary");
            }

            if (osSummary != _osSummary)
            {
                _osSummary = osSummary;
                RaisePropertyChanged("OsSummary");
            }
        }
Beispiel #6
0
        public void UpdateMap(StackHashProductLocaleSummaryCollection localeSummary)
        {
            Debug.Assert(localeSummary != null);

            ResetMap();

            if (localeSummary != null)
            {
                ulong maxEvents     = 0;
                ulong currentEvents = 0;

                StringCollection localeMisses = null;

                foreach (StackHashProductLocaleSummary summary in localeSummary)
                {
                    if (!string.IsNullOrEmpty(summary.Locale))
                    {
                        string lowerLocale = summary.Locale.ToLower(CultureInfo.InvariantCulture);
                        if (_localeToCountry.ContainsKey(lowerLocale))
                        {
                            currentEvents = _localeToCountry[lowerLocale].EventCount += (ulong)summary.TotalHits;

                            if (currentEvents > maxEvents)
                            {
                                maxEvents = currentEvents;
                            }
                        }
                        else
                        {
                            if (localeMisses == null)
                            {
                                localeMisses = new StringCollection();
                            }

                            if ((!localeMisses.Contains(lowerLocale)) &&
                                (lowerLocale != "none"))
                            {
                                localeMisses.Add(lowerLocale);
                            }
                        }
                    }
                }

                // log any locales not on the map
                if (localeMisses != null)
                {
                    foreach (string missedLocale in localeMisses)
                    {
                        DiagnosticsHelper.LogMessage(DiagSeverity.Information,
                                                     string.Format(CultureInfo.InvariantCulture,
                                                                   "WorldMapControl: no country is associated with culture {0}",
                                                                   missedLocale));
                    }
                }

                // update the map by setting the highest event count
                foreach (CountryInfo countryInfo in _localeToCountry.Values)
                {
                    countryInfo.SetMaxEventsAndUpdate(maxEvents);
                }
            }
        }
Beispiel #7
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));
        }