Esempio n. 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 GetWindowedEventPackageResponse windowSearch(ErrorIndexType errorIndexType, StackHashTestIndexData testIndexData, StackHashSearchCriteriaCollection allSearchCriteria,
                                                            long startRow, long numRows, StackHashSortOrderCollection sortOrder, StackHashSearchDirection direction, bool countAllMatches)
        {
            // Add a context.
            CreateNewStackHashContextResponse resp = m_Utils.CreateNewContext(errorIndexType);

            String testPath = "c:\\stackhashunittests\\testindex\\";

            resp.Settings.ErrorIndexSettings.Folder = testPath;
            resp.Settings.ErrorIndexSettings.Name   = "TestIndex";
            resp.Settings.ErrorIndexSettings.Type   = errorIndexType;
            m_Utils.SetContextSettings(resp.Settings);
            m_Utils.DeleteIndex(0);
            m_Utils.ActivateContext(0);

            m_Utils.CreateTestIndex(0, testIndexData);

            try
            {
                // Enable all products so that they appear in searchs.
                StackHashProductInfoCollection products = m_Utils.GetProducts(0).Products;
                foreach (StackHashProductInfo product in products)
                {
                    m_Utils.SetProductSynchronizationState(0, product.Product.Id, true);
                }

                GetWindowedEventPackageResponse eventPackages = m_Utils.GetWindowedEvents(0, allSearchCriteria, startRow, numRows, sortOrder, direction, countAllMatches);
                return(eventPackages);
            }
            finally
            {
                m_Utils.DeactivateContext(0);
                m_Utils.DeleteIndex(0);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Make sure notification only comes back to the one client.
        /// Username and password are incorrect so should just fail to login.
        /// </summary>
        public void adminReportShouldBeSentToIndividualClient(ErrorIndexType indexType)
        {
            m_Utils.RegisterForNotifications(true, Guid.NewGuid());
            m_Utils.RegisterForNotifications(true, m_Utils.ApplicationGuid);
            m_Utils.RegisterForNotifications(true, Guid.NewGuid());
            m_Utils.CreateAndSetNewContext(indexType);
            m_Utils.ActivateContext(0);

            StackHashTestIndexData indexData = new StackHashTestIndexData();

            indexData.NumberOfProducts   = 1;
            indexData.NumberOfFiles      = 1;
            indexData.NumberOfEvents     = 1;
            indexData.NumberOfCabs       = 1;
            indexData.NumberOfEventInfos = 1;

            m_Utils.CreateTestIndex(0, indexData);

            try
            {
                StackHashProductInfoCollection  products = m_Utils.GetProducts(0).Products;
                StackHashFileCollection         files    = m_Utils.GetFiles(0, products[0].Product).Files;
                StackHashEventPackageCollection events   = m_Utils.GetProductEventPackages(0, products[0].Product).EventPackages;
                StackHashCabPackageCollection   cabs     = events[0].Cabs;

                DownloadCabResponse resp = m_Utils.DownloadCab(0, products[0].Product, files[0], events[0].EventData, events[0].Cabs[0].Cab, 30000);

                StackHashAdminReport adminReport = m_Utils.DownloadCabAdminReport;
                Assert.AreNotEqual(null, adminReport);
                Assert.AreEqual(m_Utils.LastClientData.ApplicationGuid, adminReport.ClientData.ApplicationGuid);
                Assert.AreEqual(m_Utils.LastClientData.ClientId, adminReport.ClientData.ClientId);
                Assert.AreEqual(m_Utils.LastClientData.ClientName, adminReport.ClientData.ClientName);
                Assert.AreEqual(m_Utils.LastClientData.ClientRequestId, adminReport.ClientData.ClientRequestId);
                Assert.AreEqual(0, adminReport.ContextId);
                Assert.AreNotEqual(null, adminReport.LastException);
                Assert.AreEqual(true, adminReport.LastException.Contains("username and password"));
                Assert.AreEqual(StackHashAdminOperation.DownloadCabCompleted, adminReport.Operation);
                Assert.AreEqual(StackHashAsyncOperationResult.Failed, adminReport.ResultData);

                // Should receive 3 admin register + download started + download completed.
                Assert.AreEqual(5, m_Utils.AllReports.Count);
            }
            finally
            {
                m_Utils.DeactivateContext(0);
                m_Utils.DeleteIndex(0);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the product data associated with a particular context.
        /// </summary>
        /// <returns>Response result code.</returns>
        public GetProductsResponse GetProducts(GetProductsRequest requestData)
        {
            if (requestData == null)
            {
                throw new ArgumentNullException("requestData");
            }

            GetProductsResponse resp = new GetProductsResponse();

            StackHashProductInfoCollection products =
                StaticObjects.TheStaticObjects.TheController.GetProducts(requestData.ContextId);

            resp.Products   = products;
            resp.ResultData = new StackHashServiceResultData(
                StackHashServiceResult.Success, s_OperationSuccessful, null);

            return(resp);
        }
Esempio n. 4
0
        /// <summary>
        /// Product doesn't exist.
        /// </summary>
        public void downloadCabProductDoesntExist(ErrorIndexType indexType)
        {
            m_Utils.RegisterForNotifications(true, m_Utils.ApplicationGuid);
            m_Utils.CreateAndSetNewContext(indexType);
            m_Utils.ActivateContext(0);

            StackHashTestIndexData indexData = new StackHashTestIndexData();

            indexData.NumberOfProducts   = 1;
            indexData.NumberOfFiles      = 1;
            indexData.NumberOfEvents     = 1;
            indexData.NumberOfCabs       = 1;
            indexData.NumberOfEventInfos = 1;

            m_Utils.CreateTestIndex(0, indexData);

            try
            {
                try
                {
                    StackHashProductInfoCollection  products = m_Utils.GetProducts(0).Products;
                    StackHashFileCollection         files    = m_Utils.GetFiles(0, products[0].Product).Files;
                    StackHashEventPackageCollection events   = m_Utils.GetProductEventPackages(0, products[0].Product).EventPackages;
                    StackHashCabPackageCollection   cabs     = events[0].Cabs;

                    products[0].Product.Id++; // Wrong ID.
                    DownloadCabResponse resp = m_Utils.DownloadCab(0, products[0].Product, files[0], events[0].EventData, events[0].Cabs[0].Cab, 30000);
                }
                catch (FaultException <ReceiverFaultDetail> ex)
                {
                    Assert.AreEqual(true, ex.Message.Contains("Product does not exist"));
                }
            }
            finally
            {
                m_Utils.DeactivateContext(0);
                m_Utils.DeleteIndex(0);
            }
        }
Esempio n. 5
0
        public void runAnalyzeJustAutoScripts(ErrorIndexType indexType, int numberOfProducts, int numberOfFiles, int numberOfEvents, int numberOfCabs,
                                              int numberOfAutoUnmanagedAndManagedScripts, int numberOfManualUnmanagedAndManagedScripts,
                                              bool useUnmanagedCabs, int numberOfAutoManagedScripts, int numberOfManualManagedScripts,
                                              int numberOfAutoUnmanagedScripts, int numberOfManualUnmanagedScripts)
        {
            int numberOfEventInfos = 1;

            // Use the dummy winqual.

            StackHashTestData testData = new StackHashTestData();

            testData.DummyWinQualSettings = new StackHashTestDummyWinQualSettings();
            testData.DummyWinQualSettings.UseDummyWinQual                    = true;
            testData.DummyWinQualSettings.ObjectsToCreate                    = new StackHashTestIndexData();
            testData.DummyWinQualSettings.ObjectsToCreate.UseLargeCab        = false;
            testData.DummyWinQualSettings.ObjectsToCreate.NumberOfProducts   = numberOfProducts;
            testData.DummyWinQualSettings.ObjectsToCreate.NumberOfFiles      = numberOfFiles;
            testData.DummyWinQualSettings.ObjectsToCreate.NumberOfEvents     = numberOfEvents;
            testData.DummyWinQualSettings.ObjectsToCreate.NumberOfEventInfos = numberOfEventInfos;
            testData.DummyWinQualSettings.ObjectsToCreate.NumberOfCabs       = numberOfCabs;
            testData.DummyWinQualSettings.ObjectsToCreate.UseUnmanagedCab    = useUnmanagedCabs;

            m_Utils.SetTestData(testData);

            m_Utils.RegisterForNotifications(true, m_Utils.ApplicationGuid);
            m_Utils.CreateNewContext(indexType);

            // Set the username and password to something valid.
            GetStackHashPropertiesResponse settings = m_Utils.GetContextSettings();

            String testPath = "c:\\stackhashunittest\\testindex\\";

            settings.Settings.ContextCollection[0].ErrorIndexSettings.Folder = testPath;
            settings.Settings.ContextCollection[0].ErrorIndexSettings.Name   = "TestIndex";
            settings.Settings.ContextCollection[0].WinQualSettings.UserName  = m_UserName;
            settings.Settings.ContextCollection[0].WinQualSettings.Password  = m_Password;
            m_Utils.SetContextSettings(settings.Settings.ContextCollection[0]);

            // Make sure the index starts off empty.
            m_Utils.DeleteIndex(0);

            m_Utils.ActivateContext(0);

            for (int i = 0; i < numberOfAutoUnmanagedAndManagedScripts; i++)
            {
                StackHashScriptSettings scriptSettings = m_Utils.MakeScriptSettings(i, true, StackHashScriptDumpType.UnmanagedAndManaged, true);
                m_Utils.AddDebuggerScript(scriptSettings, false);
            }

            for (int i = 0; i < numberOfManualUnmanagedAndManagedScripts; i++)
            {
                StackHashScriptSettings scriptSettings = m_Utils.MakeScriptSettings(i + 100, true, StackHashScriptDumpType.UnmanagedAndManaged, false);
                m_Utils.AddDebuggerScript(scriptSettings, false);
            }

            for (int i = 0; i < numberOfAutoManagedScripts; i++)
            {
                StackHashScriptSettings scriptSettings = m_Utils.MakeScriptSettings(i + 200, true, StackHashScriptDumpType.ManagedOnly, true);
                m_Utils.AddDebuggerScript(scriptSettings, false);
            }

            for (int i = 0; i < numberOfManualManagedScripts; i++)
            {
                StackHashScriptSettings scriptSettings = m_Utils.MakeScriptSettings(i + 300, true, StackHashScriptDumpType.ManagedOnly, false);
                m_Utils.AddDebuggerScript(scriptSettings, false);
            }

            for (int i = 0; i < numberOfAutoUnmanagedScripts; i++)
            {
                StackHashScriptSettings scriptSettings = m_Utils.MakeScriptSettings(i + 400, true, StackHashScriptDumpType.UnmanagedOnly, true);
                m_Utils.AddDebuggerScript(scriptSettings, false);
            }

            for (int i = 0; i < numberOfManualUnmanagedScripts; i++)
            {
                StackHashScriptSettings scriptSettings = m_Utils.MakeScriptSettings(i + 500, true, StackHashScriptDumpType.UnmanagedOnly, false);
                m_Utils.AddDebuggerScript(scriptSettings, false);
            }

            try
            {
                // Synchronize so we have a copy of just the product list.
                StartSynchronizationResponse resp = m_Utils.StartSynchronization(0, 60000);

                StackHashClientData clientData = m_Utils.LastClientData;

                StackHashWinQualSyncCompleteAdminReport adminReport = m_Utils.WinQualSyncAdminReport as StackHashWinQualSyncCompleteAdminReport;
                Assert.AreNotEqual(null, adminReport);
                Assert.AreEqual(clientData.ApplicationGuid, adminReport.ClientData.ApplicationGuid);
                Assert.AreEqual(clientData.ClientId, adminReport.ClientData.ClientId);
                Assert.AreEqual(clientData.ClientName, adminReport.ClientData.ClientName);
                Assert.AreEqual(clientData.ClientRequestId, adminReport.ClientData.ClientRequestId);
                Assert.AreEqual(0, adminReport.ContextId);
                Assert.AreEqual(null, adminReport.LastException);
                Assert.AreEqual(StackHashAdminOperation.WinQualSyncCompleted, adminReport.Operation);
                Assert.AreEqual(StackHashAsyncOperationResult.Success, adminReport.ResultData);
                Assert.AreEqual(numberOfProducts, adminReport.ErrorIndexStatistics.Products);
                Assert.AreEqual(0, adminReport.ErrorIndexStatistics.Files);
                Assert.AreEqual(0, adminReport.ErrorIndexStatistics.Events);
                Assert.AreEqual(0, adminReport.ErrorIndexStatistics.Cabs);
                Assert.AreEqual(0, adminReport.ErrorIndexStatistics.EventInfos);


                // Enable sync for all the products.
                GetProductsResponse getProducts = m_Utils.GetProducts(0);


                foreach (StackHashProductInfo productInfo in getProducts.Products)
                {
                    Assert.AreEqual(false, productInfo.SynchronizeEnabled);
                    m_Utils.SetProductSynchronizationState(0, productInfo.Product.Id, true);

                    // Make sure there are no files for this product yet.
                    GetFilesResponse getFiles = m_Utils.GetFiles(0, productInfo.Product);

                    Assert.AreEqual(0, getFiles.Files.Count);
                }

                // Start the sync and wait for the sync and analyze to complete.
                resp = m_Utils.StartSynchronization(0, 120000, false, false, null);

                clientData = m_Utils.LastClientData;

                adminReport = m_Utils.WinQualSyncAdminReport as StackHashWinQualSyncCompleteAdminReport;
                Assert.AreNotEqual(null, adminReport);
                Assert.AreEqual(clientData.ApplicationGuid, adminReport.ClientData.ApplicationGuid);
                Assert.AreEqual(clientData.ClientId, adminReport.ClientData.ClientId);
                Assert.AreEqual(clientData.ClientName, adminReport.ClientData.ClientName);
                Assert.AreEqual(clientData.ClientRequestId, adminReport.ClientData.ClientRequestId);
                Assert.AreEqual(0, adminReport.ContextId);
                Assert.AreEqual(null, adminReport.LastException);
                Assert.AreEqual(StackHashAdminOperation.WinQualSyncCompleted, adminReport.Operation);
                Assert.AreEqual(StackHashAsyncOperationResult.Success, adminReport.ResultData);
                Assert.AreEqual(0, adminReport.ErrorIndexStatistics.Products); // Should have already added the product.
                Assert.AreEqual(numberOfFiles * numberOfProducts, adminReport.ErrorIndexStatistics.Files);
                Assert.AreEqual(numberOfEvents * numberOfFiles * numberOfProducts, adminReport.ErrorIndexStatistics.Events);
                Assert.AreEqual(numberOfCabs * numberOfEvents * numberOfFiles * numberOfProducts, adminReport.ErrorIndexStatistics.Cabs);
                Assert.AreEqual(numberOfEventInfos * numberOfEvents * numberOfFiles * numberOfProducts, adminReport.ErrorIndexStatistics.EventInfos);

                // Make sure the task is no longer running.
                GetStackHashServiceStatusResponse statusResp = m_Utils.GetServiceStatus();

                Assert.AreEqual(false, m_Utils.IsTaskRunning(statusResp.Status.ContextStatusCollection[0].TaskStatusCollection, StackHashTaskType.WinQualSynchronizeTask));
                Assert.AreEqual(false, m_Utils.IsTaskRunning(statusResp.Status.ContextStatusCollection[0].TaskStatusCollection, StackHashTaskType.AnalyzeTask));


                // Check that the scripts have been run ok. Both auto scripts should be run.
                StackHashProductInfoCollection products = m_Utils.GetProducts(0).Products;
                foreach (StackHashProductInfo product in products)
                {
                    StackHashFileCollection files = m_Utils.GetFiles(0, product.Product).Files;

                    foreach (StackHashFile file in files)
                    {
                        StackHashEventCollection events = m_Utils.GetEvents(0, product.Product, file).Events;

                        foreach (StackHashEvent currentEvent in events)
                        {
                            StackHashEventPackage eventPackage = m_Utils.GetEventPackage(0, product.Product, file, currentEvent).EventPackage;

                            foreach (StackHashCabPackage cab in eventPackage.Cabs)
                            {
                                StackHashScriptResultFiles scriptResults = m_Utils.GetDebugResultFiles(0, product.Product, file, currentEvent, cab.Cab).ResultFiles;

                                int numberOfAutoScripts = 2;
                                int expectedResults     = numberOfAutoScripts + numberOfAutoUnmanagedAndManagedScripts;

                                if (!useUnmanagedCabs)
                                {
                                    expectedResults += numberOfAutoManagedScripts;
                                }
                                else
                                {
                                    expectedResults += numberOfAutoUnmanagedScripts;
                                }

                                Assert.AreEqual(expectedResults, scriptResults.Count);
                            }
                        }
                    }
                }
            }
            finally
            {
                m_Utils.DeactivateContext(0);
                m_Utils.DeleteIndex(0);
            }
        }
Esempio n. 6
0
        public void RunBugReportSpecificEvent()
        {
            m_Utils.RegisterForNotifications(true, m_Utils.ApplicationGuid);
            m_Utils.CreateAndSetNewContext(ErrorIndexType.SqlExpress);

            GetContextBugTrackerPlugInSettingsResponse resp = m_Utils.GetContextBugTrackerPlugInSettings(0);

            Assert.AreNotEqual(null, resp.BugTrackerPlugInSettings);
            Assert.AreNotEqual(null, resp.BugTrackerPlugInSettings.PlugInSettings);
            Assert.AreEqual(0, resp.BugTrackerPlugInSettings.PlugInSettings.Count);

            resp.BugTrackerPlugInSettings.PlugInSettings.Add(new StackHashBugTrackerPlugIn());
            resp.BugTrackerPlugInSettings.PlugInSettings[0].Enabled    = true;
            resp.BugTrackerPlugInSettings.PlugInSettings[0].Name       = "TestPlugIn";
            resp.BugTrackerPlugInSettings.PlugInSettings[0].Properties = new StackHashNameValueCollection();
            resp.BugTrackerPlugInSettings.PlugInSettings[0].Properties.Add(new StackHashNameValuePair()
            {
                Name = "TestParam1", Value = "TestValue1"
            });
            resp.BugTrackerPlugInSettings.PlugInSettings[0].Properties.Add(new StackHashNameValuePair()
            {
                Name = "TestParam2", Value = "TestValue2"
            });

            m_Utils.SetContextBugTrackerPlugInSettings(0, resp.BugTrackerPlugInSettings);

            m_Utils.RestartService();
            m_Utils.ActivateContext(0);

            StackHashTestIndexData indexData = new StackHashTestIndexData();

            indexData.NumberOfProducts   = 1;
            indexData.NumberOfFiles      = 1;
            indexData.NumberOfEvents     = 1;
            indexData.NumberOfCabs       = 1;
            indexData.NumberOfEventInfos = 1;

            m_Utils.CreateTestIndex(0, indexData);

            try
            {
                StackHashProductInfoCollection  products = m_Utils.GetProducts(0).Products;
                StackHashFileCollection         files    = m_Utils.GetFiles(0, products[0].Product).Files;
                StackHashEventPackageCollection events   = m_Utils.GetProductEventPackages(0, products[0].Product).EventPackages;
                StackHashCabPackageCollection   cabs     = events[0].Cabs;

                StackHashBugReportDataCollection bugReportDataCollection = new StackHashBugReportDataCollection();
                bugReportDataCollection.Add(new StackHashBugReportData()
                {
                    Product    = products[0].Product,
                    File       = files[0],
                    TheEvent   = events[0].EventData,
                    Cab        = null,
                    ScriptName = null,
                    Options    = StackHashReportOptions.IncludeAllObjects
                });

                m_Utils.RunBugReportTask(0, bugReportDataCollection, 30000, true);
            }
            finally
            {
                m_Utils.DeactivateContext(0);
                m_Utils.DeleteIndex(0);
            }
        }
Esempio n. 7
0
        public void RunBugReportSpecificFileProgressCheckManyEventsAbortTest()
        {
            m_Utils.RegisterForNotifications(true, m_Utils.ApplicationGuid);
            m_Utils.CreateAndSetNewContext(ErrorIndexType.SqlExpress);

            GetContextBugTrackerPlugInSettingsResponse resp = m_Utils.GetContextBugTrackerPlugInSettings(0);

            Assert.AreNotEqual(null, resp.BugTrackerPlugInSettings);
            Assert.AreNotEqual(null, resp.BugTrackerPlugInSettings.PlugInSettings);
            Assert.AreEqual(0, resp.BugTrackerPlugInSettings.PlugInSettings.Count);

            resp.BugTrackerPlugInSettings.PlugInSettings.Add(new StackHashBugTrackerPlugIn());
            resp.BugTrackerPlugInSettings.PlugInSettings[0].Enabled    = true;
            resp.BugTrackerPlugInSettings.PlugInSettings[0].Name       = "TestPlugIn";
            resp.BugTrackerPlugInSettings.PlugInSettings[0].Properties = new StackHashNameValueCollection();
            resp.BugTrackerPlugInSettings.PlugInSettings[0].Properties.Add(new StackHashNameValuePair()
            {
                Name = "TestParam1", Value = "TestValue1"
            });
            resp.BugTrackerPlugInSettings.PlugInSettings[0].Properties.Add(new StackHashNameValuePair()
            {
                Name = "TestParam2", Value = "TestValue2"
            });

            m_Utils.SetContextBugTrackerPlugInSettings(0, resp.BugTrackerPlugInSettings);

            m_Utils.RestartService();
            m_Utils.ActivateContext(0);

            StackHashTestIndexData indexData = new StackHashTestIndexData();

            indexData.NumberOfProducts   = 1;
            indexData.NumberOfFiles      = 1;
            indexData.NumberOfEvents     = 200;
            indexData.NumberOfCabs       = 1;
            indexData.NumberOfEventInfos = 1;

            m_Utils.CreateTestIndex(0, indexData);

            try
            {
                StackHashProductInfoCollection  products = m_Utils.GetProducts(0).Products;
                StackHashFileCollection         files    = m_Utils.GetFiles(0, products[0].Product).Files;
                StackHashEventPackageCollection events   = m_Utils.GetProductEventPackages(0, products[0].Product).EventPackages;
                StackHashCabPackageCollection   cabs     = events[0].Cabs;

                StackHashBugReportDataCollection bugReportDataCollection = new StackHashBugReportDataCollection();
                bugReportDataCollection.Add(new StackHashBugReportData()
                {
                    Product    = products[0].Product,
                    File       = files[0],
                    TheEvent   = null,
                    Cab        = null,
                    ScriptName = null,
                    Options    = StackHashReportOptions.IncludeAllObjects
                });

                m_Utils.RunBugReportTask(0, bugReportDataCollection, 0, false); // Don't wait.
                m_Utils.WaitForBugReportProgress(30000);
                m_Utils.AbortTask(0, StackHashTaskType.BugReportTask);
                m_Utils.WaitForBugReportTaskCompleted(30000);

                // Check the progress reports.
                Assert.AreEqual(true, m_Utils.BugReportProgressReports.Count < 100);

                long lastProgress = -1;
                foreach (StackHashAdminReport report in m_Utils.BugReportProgressReports)
                {
                    StackHashBugReportProgressAdminReport progress = report as StackHashBugReportProgressAdminReport;

                    Assert.AreEqual(true, progress.CurrentEvent > lastProgress);
                    Assert.AreEqual(true, progress.CurrentEvent < progress.TotalEvents);
                    lastProgress = progress.CurrentEvent;
                }
            }
            finally
            {
                m_Utils.DeactivateContext(0);
                m_Utils.DeleteIndex(0);
            }
        }
Esempio n. 8
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 addRemoveEventNotes(int numberOfNotes)
        {
            StackHashTestIndexData testIndexData = new StackHashTestIndexData();

            testIndexData.NumberOfProducts   = 1;
            testIndexData.NumberOfFiles      = 1;
            testIndexData.NumberOfEvents     = 1;
            testIndexData.NumberOfEventInfos = 0;
            testIndexData.NumberOfCabs       = 0;

            // Add a context.
            CreateNewStackHashContextResponse resp = m_Utils.CreateNewContext(ErrorIndexType.SqlExpress);

            String testPath = "c:\\stackhashunittests\\testindex\\";

            resp.Settings.ErrorIndexSettings.Folder = testPath;
            resp.Settings.ErrorIndexSettings.Name   = "TestIndex";
            resp.Settings.ErrorIndexSettings.Type   = ErrorIndexType.SqlExpress;
            m_Utils.SetContextSettings(resp.Settings);
            m_Utils.DeleteIndex(0);
            m_Utils.ActivateContext(0);

            m_Utils.CreateTestIndex(0, testIndexData);

            try
            {
                // Enable all products so that they appear in searchs.
                StackHashProductInfoCollection products = m_Utils.GetProducts(0).Products;
                StackHashProduct         product        = products[0].Product;
                StackHashFileCollection  files          = m_Utils.GetFiles(0, product).Files;
                StackHashEventCollection events         = m_Utils.GetEvents(0, product, files[0]).Events;


                // Add the specified number of event notes.
                for (int eventCount = 0; eventCount < numberOfNotes; eventCount++)
                {
                    StackHashNoteEntry note = new StackHashNoteEntry();
                    note.Note        = "Note" + (eventCount + 1).ToString();
                    note.Source      = "USER";
                    note.User        = "******";
                    note.TimeOfEntry = DateTime.Now.AddDays(-1);

                    m_Utils.AddEventNote(0, product, files[0], events[0], note);

                    StackHashNotes notes = m_Utils.GetEventNotes(0, product, files[0], events[0]).Notes;

                    Assert.AreEqual(eventCount + 1, notes.Count);
                    bool found = false;
                    foreach (StackHashNoteEntry noteEntry in notes)
                    {
                        if (noteEntry.NoteId == eventCount + 1)
                        {
                            Assert.AreEqual(note.Note, noteEntry.Note);
                            Assert.AreEqual(note.Source, noteEntry.Source);
                            Assert.AreEqual(note.User, noteEntry.User);
                            Assert.AreEqual(DateTime.UtcNow.Date, noteEntry.TimeOfEntry.Date);
                            found = true;
                            break;
                        }
                    }

                    Assert.AreEqual(true, found);
                }

                // Now delete the event notes.
                int expectedEventNotes = numberOfNotes;

                for (int eventCount = 0; eventCount < numberOfNotes; eventCount++)
                {
                    m_Utils.DeleteEventNote(0, product, files[0], events[0], eventCount + 1);

                    expectedEventNotes--;

                    StackHashNotes notes = m_Utils.GetEventNotes(0, product, files[0], events[0]).Notes;

                    Assert.AreEqual(expectedEventNotes, notes.Count);

                    bool found = false;
                    foreach (StackHashNoteEntry noteEntry in notes)
                    {
                        if (noteEntry.NoteId == eventCount + 1)
                        {
                            found = true;
                            break;
                        }
                    }

                    Assert.AreEqual(false, found);
                }
            }
            finally
            {
                m_Utils.DeactivateContext(0);
                m_Utils.DeleteIndex(0);
            }
        }