private void button1_Click(object sender, EventArgs e) { BugInformationDAO bugInformationDAO = new BugInformationDAO(); BugInformation bugInformation = new BugInformation { Cause = textBox2.Text, Symtons = textBox1.Text, BugId = Program.bugId }; if (string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox2.Text)) { MessageBox.Show("You must add symptons and cause"); } else { try { bugInformationDAO.Insert(bugInformation); MessageBox.Show("Added"); button1.Hide(); button2.Show(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } }
/// <summary> /// Truncate key fields from the input BugInformation and return a revised object /// certain values are truncated to {length} characters long, /// certain values are formatted to be more readable /// </summary> /// <param name="bugInfo">Non-truncated information from caller</param> /// <param name="bugFieldPairs">The collection of BugField/string pairs to truncate</param> /// <returns></returns> private static void TruncateSelectedFields(BugInformation bugInfo, IDictionary <BugField, string> bugFieldPairs) { bugFieldPairs[BugField.ProcessName] = TruncateString(bugInfo.ProcessName, 50, ".exe"); bugFieldPairs[BugField.Glimpse] = TruncateString(bugInfo.Glimpse, 50); bugFieldPairs[BugField.TestMessages] = TruncateString(bugInfo.TestMessages, 150, "...open attached A11y test file for full details."); bugFieldPairs[BugField.RuleSource] = RemoveSurroundingBrackets(bugInfo.RuleSource); }
private void SymptonsAndAssign_Load(object sender, EventArgs e) { BugInformationDAO bugInformationDAO = new BugInformationDAO(); BugInformation bugInformation = bugInformationDAO.GetById(Program.bugId); if (bugInformation != null) { button1.Hide(); button2.Show(); textBox1.Text = bugInformation.Symtons; textBox2.Text = bugInformation.Cause; } else { button1.Show(); button2.Show(); } ProgrammerDAO programmerDAO = new ProgrammerDAO(); List <ProjectDeveloper> list = programmerDAO.GetAll(); foreach (var l in list) { comboBox1.Items.Add(l.ProgrammerId + "," + l.FullName); //comboBox1.DisplayMember = l.FullName; //comboBox1.ValueMember = l.ProgrammerId.ToString(); } assignedUser(); }
public void TestBugFilingTelemetrySpecificRule() { using (ShimsContext.Create()) { SetUpShims(); // Save telemetry locally List <Tuple <TelemetryAction, IReadOnlyDictionary <TelemetryProperty, string> > > telemetryLog = new List <Tuple <TelemetryAction, IReadOnlyDictionary <TelemetryProperty, string> > >(); ShimLogger.PublishTelemetryEventTelemetryActionIReadOnlyDictionaryOfTelemetryPropertyString = (action, dict) => { telemetryLog.Add(new Tuple <TelemetryAction, IReadOnlyDictionary <TelemetryProperty, string> >(action, dict)); }; var bugInfo = new BugInformation(ruleForTelemetry: RuleId.BoundingRectangleContainedInParent.ToString()); var connInfo = new StubIConnectionInfo { ServerUriGet = () => FAKE_SERVER_URL, }; (int?bugId, string newBugId) = FileBugAction.FileNewBug(bugInfo, connInfo, false, 0, (_) => { }); Assert.AreEqual(RuleId.BoundingRectangleContainedInParent.ToString(), telemetryLog[0].Item2[TelemetryProperty.RuleId]); Assert.AreEqual("", telemetryLog[0].Item2[TelemetryProperty.UIFramework]); Assert.AreEqual(2, telemetryLog[0].Item2.Count); } }
/// <summary> /// Extract the template name from a BugInformation object /// </summary> /// <param name="bugInfo"></param> /// <returns>The name of the template</returns> private static string GetTemplateName(BugInformation bugInfo) { if (bugInfo.BugType.HasValue) { switch (bugInfo.BugType.Value) { case BugType.ColorContrast: return("BugColorContrast"); case BugType.SingleFailure: return("BugSingleFailure"); } } return("BugNoFailures"); }
public Task <Uri> CreateBugPreviewAsync(IConnectionInfo connectionInfo, BugInformation bugInfo) { string templateName = GetTemplateName(bugInfo); Dictionary <BugField, string> bugFieldPairs = bugInfo.ToAzureDevOpsBugFields(); TruncateSelectedFields(bugInfo, bugFieldPairs); Dictionary <AzureDevOpsField, string> fieldPairs = GenerateBugTemplate(bugFieldPairs, templateName); AddAreaAndIterationPathFields(connectionInfo, fieldPairs); return(Task <Uri> .Run(() => AzureDevOps.CreateBugPreview(connectionInfo.Project.Name, connectionInfo.Team?.Name, fieldPairs))); }
private void SymptomsAndAssign_Load(object sender, EventArgs e) { if (!Program.isTester) { textBox1.Enabled = false; textBox2.Enabled = false; button1.Hide(); button1.Enabled = false; button2.Hide(); button2.Hide(); button2.Enabled = false; button3.Hide(); label3.Text = "Message"; comboBox1.Hide(); // textBox3.Hide(); AssignDAO bugAssignMessageDao = new AssignDAO(); Assign bugAssignMessage = bugAssignMessageDao.GetById(Program.bugId); textBox3.Text = bugAssignMessage.Description; textBox3.Enabled = false; } BugInformationDAO bugInformationDAO = new BugInformationDAO(); BugInformation bugInformation = bugInformationDAO.GetById(Program.bugId); if (bugInformation != null) { button1.Hide(); button2.Show(); textBox1.Text = bugInformation.Symtons; textBox2.Text = bugInformation.Cause; } else { button1.Show(); button2.Show(); } ProgrammerDAO programmerDAO = new ProgrammerDAO(); List <Programmer> list = programmerDAO.GetAll(); foreach (var l in list) { comboBox1.Items.Add(l.ProgrammerId + "," + l.FullName); //comboBox1.DisplayMember = l.FullName; //comboBox1.ValueMember = l.ProgrammerId.ToString(); } // assignedUser(); }
public void FileNewBug_IsNotEnabled_ReturnsPlaceholder() { using (ShimsContext.Create()) { ShimBugReporter.IsEnabledGet = () => false; var bugInfo = new BugInformation(); var connInfo = new StubIConnectionInfo(); var output = FileBugAction.FileNewBug(bugInfo, connInfo, false, 0, (_) => { }); Assert.IsNull(output.bugId); Assert.IsNotNull(output.newBugId); Assert.IsTrue(string.IsNullOrEmpty(output.newBugId)); } }
public void TruncateSelectedFields_AllFieldsNull_AddsNullValues() { Dictionary <BugField, string> bugFieldPairs = new Dictionary <BugField, string>(); BugInformation bugInfo = new BugInformation(); PrivateType privateAzureDevOpsBugReporting = new PrivateType(typeof(AzureDevOpsBugReporting)); privateAzureDevOpsBugReporting.InvokeStatic("TruncateSelectedFields", bugInfo, bugFieldPairs); Assert.AreEqual(4, bugFieldPairs.Count); Assert.IsNull(bugFieldPairs[BugField.ProcessName]); Assert.IsNull(bugFieldPairs[BugField.Glimpse]); Assert.IsNull(bugFieldPairs[BugField.TestMessages]); Assert.IsNull(bugFieldPairs[BugField.RuleSource]); }
public void TruncateSelectedFields_GlimpseIsSpecified_AddsGlimpseValue() { string originalGlimpse = new string('y', 60); Dictionary <BugField, string> bugFieldPairs = new Dictionary <BugField, string>(); BugInformation bugInfo = new BugInformation(glimpse: originalGlimpse); PrivateType privateAzureDevOpsBugReporting = new PrivateType(typeof(AzureDevOpsBugReporting)); privateAzureDevOpsBugReporting.InvokeStatic("TruncateSelectedFields", bugInfo, bugFieldPairs); Assert.AreEqual(4, bugFieldPairs.Count); string modifiedGlimpse = bugFieldPairs[BugField.Glimpse]; Assert.AreEqual(new string('y', 50) + "...", modifiedGlimpse); Assert.IsNull(bugFieldPairs[BugField.ProcessName]); Assert.IsNull(bugFieldPairs[BugField.TestMessages]); Assert.IsNull(bugFieldPairs[BugField.RuleSource]); }
public void TruncateSelectedFields_TestMessagesIsSpecified_AddsTestMessagesValue() { string originalTestMessages = new string('z', 200); Dictionary <BugField, string> bugFieldPairs = new Dictionary <BugField, string>(); BugInformation bugInfo = new BugInformation(testMessages: originalTestMessages); PrivateType privateAzureDevOpsBugReporting = new PrivateType(typeof(AzureDevOpsBugReporting)); privateAzureDevOpsBugReporting.InvokeStatic("TruncateSelectedFields", bugInfo, bugFieldPairs); Assert.AreEqual(4, bugFieldPairs.Count); string modifiedTestMessages = bugFieldPairs[BugField.TestMessages]; Assert.AreEqual(new string('z', 150) + "...open attached", modifiedTestMessages.Substring(0, 166)); Assert.IsNull(bugFieldPairs[BugField.ProcessName]); Assert.IsNull(bugFieldPairs[BugField.Glimpse]); Assert.IsNull(bugFieldPairs[BugField.RuleSource]); }
/// <summary> /// Opens bug filing window with prepopulated data /// </summary> /// <param name="bugInfo">Dictionary of bug info from with which to populate the bug</param> /// <param name="connection">connection info</param> /// <param name="onTop">Is window always on top</param> /// <param name="zoomLevel">Zoom level for bug file window</param> /// <param name="updateZoom">Callback to update configuration with zoom level</param> /// <returns></returns> public static (int?bugId, string newBugId) FileNewBug(BugInformation bugInfo, IConnectionInfo connection, bool onTop, int zoomLevel, Action <int> updateZoom) { if (!BugReporter.IsEnabled) { return(null, string.Empty); } try { // Create a A11y-specific Guid for this bug to verify that we are uploading // attachment to the correct bug var a11yBugId = bugInfo.InternalGuid.HasValue ? bugInfo.InternalGuid.Value.ToString() : string.Empty; Uri url = BugReporter.CreateBugPreviewAsync(connection, bugInfo).Result; var bugId = FileBugWindow(url, onTop, zoomLevel, updateZoom); if (bugId.HasValue) { if (bugInfo.RuleForTelemetry != null) { Logger.PublishTelemetryEvent(TelemetryAction.Bug_Save, new Dictionary <TelemetryProperty, string> { { TelemetryProperty.RuleId, bugInfo.RuleForTelemetry }, { TelemetryProperty.UIFramework, bugInfo.UIFramework ?? string.Empty }, }); } else // if the bug is coming from the hierarchy tree, it will not have ruleID or UIFramework { Logger.PublishTelemetryEvent(TelemetryAction.Bug_Save); } } else { Logger.PublishTelemetryEvent(TelemetryAction.Bug_Cancel); } return(bugId, a11yBugId); } catch { return(null, string.Empty); } }
public void TruncateSelectedFields_RuleSourceIsSpecified_AddsRuleSourceValue() { const string ruleSourceContent = "weather: cold and clear"; string originalRuleSource = '[' + ruleSourceContent + ']'; Dictionary <BugField, string> bugFieldPairs = new Dictionary <BugField, string>(); BugInformation bugInfo = new BugInformation(ruleSource: originalRuleSource); PrivateType privateAzureDevOpsBugReporting = new PrivateType(typeof(AzureDevOpsBugReporting)); privateAzureDevOpsBugReporting.InvokeStatic("TruncateSelectedFields", bugInfo, bugFieldPairs); Assert.AreEqual(4, bugFieldPairs.Count); string modifiedRuleSource = bugFieldPairs[BugField.RuleSource]; Assert.AreEqual(ruleSourceContent, modifiedRuleSource); Assert.IsNull(bugFieldPairs[BugField.ProcessName]); Assert.IsNull(bugFieldPairs[BugField.Glimpse]); Assert.IsNull(bugFieldPairs[BugField.TestMessages]); }
internal static Dictionary <BugField, string> ToAzureDevOpsBugFields(this BugInformation bugInfo) { return(new Dictionary <BugField, string> { { BugField.WindowTitle, GetStringValue(bugInfo.WindowTitle) }, { BugField.Glimpse, GetStringValue(bugInfo.Glimpse) }, { BugField.HowToFixLink, GetStringValue(bugInfo.HowToFixLink) }, { BugField.HelpURL, GetStringValue(bugInfo.HelpUri) }, { BugField.RuleSource, GetStringValue(bugInfo.RuleSource) }, { BugField.RuleDescription, GetStringValue(bugInfo.RuleDescription) }, { BugField.TestMessages, GetStringValue(bugInfo.TestMessages) }, { BugField.ProcessName, GetStringValue(bugInfo.ProcessName) }, { BugField.InternalGuid, GetStringValue(bugInfo.InternalGuid) }, { BugField.ElementPath, GetStringValue(bugInfo.ElementPath) }, { BugField.RuleForTelemetry, GetStringValue(bugInfo.RuleForTelemetry) }, { BugField.UIFramework, GetStringValue(bugInfo.UIFramework) }, { BugField.ContrastRatio, GetStringValue(bugInfo.ContrastRatio) }, { BugField.FirstColorHex, GetStringValue(bugInfo.FirstColor) }, { BugField.SecondColorHex, GetStringValue(bugInfo.SecondColor) }, { BugField.ContrastFailureText, GetStringValue(bugInfo.ContrastFailureText) }, }); }
public void TestBugFilingTelemetryNoRule() { using (ShimsContext.Create()) { SetUpShims(); // Save telemetry locally List <Tuple <TelemetryAction, TelemetryProperty, string> > telemetryLog = new List <Tuple <TelemetryAction, TelemetryProperty, string> >(); ShimLogger.PublishTelemetryEventTelemetryActionTelemetryPropertyString = (action, property, value) => { telemetryLog.Add(new Tuple <TelemetryAction, TelemetryProperty, string>(action, property, value)); }; var bugInfo = new BugInformation(); var connInfo = new StubIConnectionInfo { ServerUriGet = () => FAKE_SERVER_URL, }; (int?bugId, string newBugId) = FileBugAction.FileNewBug(bugInfo, connInfo, false, 0, (_) => { }); Assert.AreEqual(0, telemetryLog.Count); } }
public void CreateBugPreviewAsync_TeamNameIsNotNull_ChainsThroughCorrectly() { using (ShimsContext.Create()) { const string expectedProjectName = "Ultra Project"; const string expectedTeamName = "Ultra Team"; string actualProjectName = null; string actualTeamName = null; Uri expectedUri = new Uri("https://www.bing.com"); AzureDevOpsIntegration integration = new ShimAzureDevOpsIntegration { CreateBugPreviewStringStringIReadOnlyDictionaryOfAzureDevOpsFieldString = (p, t, f) => { actualProjectName = p; actualTeamName = t; return(expectedUri); }, ConnectedToAzureDevOpsGet = () => true, }; ShimAzureDevOpsIntegration.GetCurrentInstance = () => integration; IBugReporting bugReporting = new AzureDevOpsBugReporting(); IConnectionInfo connectionInfo = new ConnectionInfo(expectedUri, new TeamProject(expectedProjectName, Guid.Empty), new Team(expectedTeamName, Guid.Empty)); BugInformation bugInfo = new BugInformation(); Uri actualUri = bugReporting.CreateBugPreviewAsync(connectionInfo, bugInfo).Result; Assert.AreEqual(expectedUri, actualUri); Assert.AreEqual(expectedProjectName, actualProjectName); Assert.AreEqual(expectedTeamName, actualTeamName); } }
public static Task <Uri> CreateBugPreviewAsync(IConnectionInfo connectionInfo, BugInformation bugInfo) { if (IsEnabled) { return(BugReporting.CreateBugPreviewAsync(connectionInfo, bugInfo)); } return(Task.FromResult((Uri)null)); }