Ejemplo n.º 1
0
        public void ProductAddedUnhandledExceptionInPlugIn()
        {
            String dllLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            String[] folders = { dllLocation };

            BugTrackerManager manager = new BugTrackerManager(folders);

            Assert.AreEqual(true, manager.NumberOfPlugIns >= 1);

            StackHashBugTrackerPlugInSettings plugInSettings = new StackHashBugTrackerPlugInSettings();

            plugInSettings.PlugInSettings = new StackHashBugTrackerPlugInCollection();
            plugInSettings.PlugInSettings.Add(new StackHashBugTrackerPlugIn());
            plugInSettings.PlugInSettings[0].Name    = "TestPlugIn";
            plugInSettings.PlugInSettings[0].Enabled = true;

            BugTrackerContext plugInContext = new BugTrackerContext(manager, plugInSettings);

            StackHashBugTrackerPlugInDiagnosticsCollection fullDiagnostics = plugInContext.GetContextDiagnostics("TestPlugIn");

            Assert.AreEqual(1, fullDiagnostics.Count);
            NameValueCollection diagnostics = fullDiagnostics[0].Diagnostics.ToNameValueCollection();

            Assert.AreEqual("0", diagnostics["ProductAddedCount"]);
            Assert.AreEqual("0", diagnostics["ProductUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["FileAddedCount"]);
            Assert.AreEqual("0", diagnostics["FileUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["EventAddedCount"]);
            Assert.AreEqual("0", diagnostics["EventUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["EventNoteAddedCount"]);
            Assert.AreEqual("0", diagnostics["CabAddedCount"]);
            Assert.AreEqual("0", diagnostics["CabUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["CabNoteAddedCount"]);


            NameValueCollection properties = new NameValueCollection();

            properties.Add("UnhandledException", "1");

            plugInContext.SetProperties("TestPlugIn", properties);

            plugInContext.ProductAdded(null, BugTrackerReportType.Automatic, null);

            fullDiagnostics = plugInContext.GetContextDiagnostics("TestPlugIn");
            Assert.AreEqual(1, fullDiagnostics.Count);
            diagnostics = fullDiagnostics[0].Diagnostics.ToNameValueCollection();

            Assert.AreEqual("0", diagnostics["ProductAddedCount"]);
            Assert.AreEqual("0", diagnostics["ProductUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["FileAddedCount"]);
            Assert.AreEqual("0", diagnostics["FileUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["EventAddedCount"]);
            Assert.AreEqual("0", diagnostics["EventUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["EventNoteAddedCount"]);
            Assert.AreEqual("0", diagnostics["CabAddedCount"]);
            Assert.AreEqual("0", diagnostics["CabUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["CabNoteAddedCount"]);
        }
Ejemplo n.º 2
0
        public void LogInCallback()
        {
            // Empty so shouldn't report anything.
            StackHashBugTrackerPlugInSelectionCollection plugIns = new StackHashBugTrackerPlugInSelectionCollection();

            String dllLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            String[] folders = { dllLocation };

            BugTrackerTrace.LogMessageHook += new EventHandler <BugTrackerTraceEventArgs>(LogPlugInEvent);

            try
            {
                BugTrackerManager manager = new BugTrackerManager(folders);

                StackHashBugTrackerPlugInSettings plugInSettings = new StackHashBugTrackerPlugInSettings();
                plugInSettings.PlugInSettings = new StackHashBugTrackerPlugInCollection();
                plugInSettings.PlugInSettings.Add(new StackHashBugTrackerPlugIn());
                plugInSettings.PlugInSettings[0].Name    = "TestPlugIn";
                plugInSettings.PlugInSettings[0].Enabled = true;

                BugTrackerContext plugInContext = new BugTrackerContext(manager, plugInSettings);

                Assert.AreEqual(true, manager.NumberOfPlugIns >= 1);
                Assert.AreEqual(true, m_CallBackCount > 0);

                StackHashBugTrackerPlugInDiagnosticsCollection fullDiagnostics = plugInContext.GetContextDiagnostics("TestPlugIn");
                Assert.AreEqual(1, fullDiagnostics.Count);
                NameValueCollection diagnostics = fullDiagnostics[0].Diagnostics.ToNameValueCollection();

                Assert.AreEqual("0", diagnostics["ProductAddedCount"]);
                Assert.AreEqual("0", diagnostics["ProductUpdatedCount"]);
                Assert.AreEqual("0", diagnostics["FileAddedCount"]);
                Assert.AreEqual("0", diagnostics["FileUpdatedCount"]);
                Assert.AreEqual("0", diagnostics["EventAddedCount"]);
                Assert.AreEqual("0", diagnostics["EventUpdatedCount"]);
                Assert.AreEqual("0", diagnostics["EventNoteAddedCount"]);
                Assert.AreEqual("0", diagnostics["CabAddedCount"]);
                Assert.AreEqual("0", diagnostics["CabUpdatedCount"]);
                Assert.AreEqual("0", diagnostics["CabNoteAddedCount"]);

                BugTrackerProduct product  = new BugTrackerProduct("Name", "Version", 1);
                BugTrackerFile    file     = new BugTrackerFile("FileName", "FileVersion", 2);
                BugTrackerEvent   theEvent = new BugTrackerEvent("BugRef", "PlugInBugRef", 1, "EventTypeName", 1, new NameValueCollection());
                BugTrackerCab     cab      = new BugTrackerCab(1, 100, false, false, new NameValueCollection(), "c:\\test.cab");

                plugInContext.ProductAdded(plugIns, BugTrackerReportType.Automatic, product);
                plugInContext.ProductUpdated(plugIns, BugTrackerReportType.Automatic, product);

                plugInContext.FileAdded(plugIns, BugTrackerReportType.Automatic, product, file);
                plugInContext.FileUpdated(plugIns, BugTrackerReportType.Automatic, product, file);

                plugInContext.EventAdded(plugIns, BugTrackerReportType.Automatic, product, file, theEvent);
                plugInContext.EventUpdated(plugIns, BugTrackerReportType.Automatic, product, file, theEvent);
                plugInContext.EventManualUpdateCompleted(plugIns, BugTrackerReportType.Automatic, product, file, theEvent);
                plugInContext.EventNoteAdded(plugIns, BugTrackerReportType.Automatic, product, file, theEvent, new BugTrackerNote());

                plugInContext.CabAdded(plugIns, BugTrackerReportType.Automatic, product, file, theEvent, cab);
                plugInContext.CabUpdated(plugIns, BugTrackerReportType.Automatic, product, file, theEvent, cab);
                plugInContext.CabNoteAdded(plugIns, BugTrackerReportType.Automatic, product, file, theEvent, cab, new BugTrackerNote());


                fullDiagnostics = plugInContext.GetContextDiagnostics("TestPlugIn");
                Assert.AreEqual(1, fullDiagnostics.Count);
                diagnostics = fullDiagnostics[0].Diagnostics.ToNameValueCollection();

                Assert.AreEqual("0", diagnostics["ProductAddedCount"]);
                Assert.AreEqual("0", diagnostics["ProductUpdatedCount"]);
                Assert.AreEqual("0", diagnostics["FileAddedCount"]);
                Assert.AreEqual("0", diagnostics["FileUpdatedCount"]);
                Assert.AreEqual("0", diagnostics["EventAddedCount"]);
                Assert.AreEqual("0", diagnostics["EventCompleteCount"]);
                Assert.AreEqual("0", diagnostics["EventUpdatedCount"]);
                Assert.AreEqual("0", diagnostics["EventNoteAddedCount"]);
                Assert.AreEqual("0", diagnostics["CabAddedCount"]);
                Assert.AreEqual("0", diagnostics["CabUpdatedCount"]);
                Assert.AreEqual("0", diagnostics["CabNoteAddedCount"]);
            }
            finally
            {
                BugTrackerTrace.LogMessageHook -= new EventHandler <BugTrackerTraceEventArgs>(LogPlugInEvent);
            }
        }
Ejemplo n.º 3
0
        public void InvokeEachMethodSpecifyCorrectPlugIn()
        {
            StackHashBugTrackerPlugInSelectionCollection plugIns = new StackHashBugTrackerPlugInSelectionCollection();

            plugIns.Add(new StackHashBugTrackerPlugInSelection("TestPlugIn"));


            String dllLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            String[] folders = { dllLocation };

            BugTrackerManager manager = new BugTrackerManager(folders);

            StackHashBugTrackerPlugInSettings plugInSettings = new StackHashBugTrackerPlugInSettings();

            plugInSettings.PlugInSettings = new StackHashBugTrackerPlugInCollection();
            plugInSettings.PlugInSettings.Add(new StackHashBugTrackerPlugIn());
            plugInSettings.PlugInSettings[0].Name    = "TestPlugIn";
            plugInSettings.PlugInSettings[0].Enabled = true;

            BugTrackerContext plugInContext = new BugTrackerContext(manager, plugInSettings);

            Assert.AreEqual(true, manager.NumberOfPlugIns >= 1);

            StackHashBugTrackerPlugInDiagnosticsCollection fullDiagnostics = plugInContext.GetContextDiagnostics("TestPlugIn");

            Assert.AreEqual(1, fullDiagnostics.Count);
            NameValueCollection diagnostics = fullDiagnostics[0].Diagnostics.ToNameValueCollection();

            Assert.AreEqual("0", diagnostics["ProductAddedCount"]);
            Assert.AreEqual("0", diagnostics["ProductUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["FileAddedCount"]);
            Assert.AreEqual("0", diagnostics["FileUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["EventAddedCount"]);
            Assert.AreEqual("0", diagnostics["EventUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["EventNoteAddedCount"]);
            Assert.AreEqual("0", diagnostics["CabAddedCount"]);
            Assert.AreEqual("0", diagnostics["CabUpdatedCount"]);
            Assert.AreEqual("0", diagnostics["CabNoteAddedCount"]);

            BugTrackerProduct product  = new BugTrackerProduct("Name", "Version", 1);
            BugTrackerFile    file     = new BugTrackerFile("FileName", "FileVersion", 2);
            BugTrackerEvent   theEvent = new BugTrackerEvent("BugRef", "PlugInBugRef", 1, "EventTypeName", 1, new NameValueCollection());
            BugTrackerCab     cab      = new BugTrackerCab(1, 100, false, false, new NameValueCollection(), "c:\\test.cab");

            plugInContext.ProductAdded(plugIns, BugTrackerReportType.Automatic, product);
            plugInContext.ProductUpdated(plugIns, BugTrackerReportType.Automatic, product);

            plugInContext.FileAdded(plugIns, BugTrackerReportType.Automatic, product, file);
            plugInContext.FileUpdated(plugIns, BugTrackerReportType.Automatic, product, file);

            plugInContext.EventAdded(plugIns, BugTrackerReportType.Automatic, product, file, theEvent);
            plugInContext.EventUpdated(plugIns, BugTrackerReportType.Automatic, product, file, theEvent);
            plugInContext.EventManualUpdateCompleted(plugIns, BugTrackerReportType.Automatic, product, file, theEvent);
            plugInContext.EventNoteAdded(plugIns, BugTrackerReportType.Automatic, product, file, theEvent, new BugTrackerNote());

            plugInContext.CabAdded(plugIns, BugTrackerReportType.Automatic, product, file, theEvent, cab);
            plugInContext.CabUpdated(plugIns, BugTrackerReportType.Automatic, product, file, theEvent, cab);
            plugInContext.CabNoteAdded(plugIns, BugTrackerReportType.Automatic, product, file, theEvent, cab, new BugTrackerNote());


            fullDiagnostics = plugInContext.GetContextDiagnostics("TestPlugIn");
            Assert.AreEqual(1, fullDiagnostics.Count);
            diagnostics = fullDiagnostics[0].Diagnostics.ToNameValueCollection();

            Assert.AreEqual("1", diagnostics["ProductAddedCount"]);
            Assert.AreEqual("1", diagnostics["ProductUpdatedCount"]);
            Assert.AreEqual("1", diagnostics["FileAddedCount"]);
            Assert.AreEqual("1", diagnostics["FileUpdatedCount"]);
            Assert.AreEqual("1", diagnostics["EventAddedCount"]);
            Assert.AreEqual("1", diagnostics["EventCompleteCount"]);
            Assert.AreEqual("1", diagnostics["EventUpdatedCount"]);
            Assert.AreEqual("1", diagnostics["EventNoteAddedCount"]);
            Assert.AreEqual("1", diagnostics["CabAddedCount"]);
            Assert.AreEqual("1", diagnostics["CabUpdatedCount"]);
            Assert.AreEqual("1", diagnostics["CabNoteAddedCount"]);
        }