Пример #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"]);
        }