/// <summary> /// Update defect field value /// <para/> returns True if successfull /// </summary> /// <param name="bug">TDAPIOLELib.Bug Object</param> /// <param name="fieldName">Database Field name</param> /// <param name="newValue">New Field value</param> /// <param name="Post">Post the defect after updating valie</param> /// <returns>True if successfull</returns> public Boolean UpdateFieldValue(TDAPIOLELib.Bug bug, String fieldName, String newValue, Boolean Post = true) { bug[fieldName.ToUpper()] = newValue; if (Post) { bug.Post(); } return(true); }
/// <summary> /// creates a defect in ALM /// <para/>returns TDAPIOLELib.Bug Object /// </summary> /// <param name="defectDetails">Dictionary Object with Field name and field value strings</param> /// <returns>TDAPIOLELib.Bug Object</returns> public TDAPIOLELib.Bug Create(Dictionary <String, String> defectDetails) { TDAPIOLELib.BugFactory OBGFactory = tDConnection.BugFactory; TDAPIOLELib.Bug OBug = OBGFactory.AddItem(System.DBNull.Value); foreach (KeyValuePair <string, string> kvp in defectDetails) { OBug[kvp.Key.ToUpper()] = kvp.Value; } OBug.Post(); return(OBug); }
/*public int CountAll() * { * TDAPIOLELib.Recordset ORecordSet = Utilities.ExecuteQuery("Select Count(*) from Bug", tDConnection); * ORecordSet.First(); * return Convert.ToInt32(ORecordSet[0]); * }*/ /// <summary> /// Deletes a defect /// </summary> /// <param name="bug">TDAPIOLELib.Bug Object</param> /// <returns>true if successfull</returns> public Boolean Delete(TDAPIOLELib.Bug bug) { try { TDAPIOLELib.BugFactory OBGFactory = tDConnection.BugFactory; OBGFactory.RemoveItem(bug.ID); return(true); } catch (Exception ex) { throw ex; } }
/// <summary> /// Links defects to any ALM object /// </summary> /// <param name="obj">Object class from ALM</param> /// <param name="bug">TDAPIOLELib.Bug Object</param> /// <param name="comment">Comment</param> /// <returns>True if successfull</returns> private Boolean LinkDefectToEntities(Object obj, TDAPIOLELib.Bug bug, String comment = "") { TDAPIOLELib.ILinkable linkable = obj as TDAPIOLELib.ILinkable; TDAPIOLELib.LinkFactory OLinkFactory = linkable.BugLinkFactory; TDAPIOLELib.Link OLink = OLinkFactory.AddItem(bug); if (comment.Length > 0) { OLink.Comment = comment; } OLink.Post(); return(true); }
/// <summary> /// Delete all attachments from defect /// </summary> /// <param name="bug">TDAPIOLELib.Bug Object</param> /// <returns>True if Successfull</returns> public Boolean DeleteAllAttachments(TDAPIOLELib.Bug bug) { TDAPIOLELib.AttachmentFactory OAttachmentFactory; OAttachmentFactory = bug.Attachments; TDAPIOLELib.List AttachmentsList = OAttachmentFactory.NewList(""); foreach (TDAPIOLELib.Attachment OAttach in AttachmentsList) { OAttachmentFactory.RemoveItem(OAttach.ID); } return(true); }
/// <summary> /// Delete defect attachment by name /// </summary> /// <param name="bug">TDAPIOLELib.Bug Object</param> /// <param name="attachmentName">Name of attachment</param> /// <returns>True if successfull</returns> public Boolean DeleteAttachmentByName(TDAPIOLELib.Bug bug, String attachmentName) { TDAPIOLELib.AttachmentFactory OAttachmentFactory; OAttachmentFactory = bug.Attachments; TDAPIOLELib.List AttachmentsList = OAttachmentFactory.NewList(""); foreach (TDAPIOLELib.Attachment OAttach in AttachmentsList) { if (OAttach.Name.EndsWith(attachmentName)) { OAttachmentFactory.RemoveItem(OAttach.ID); break; } } return(true); }
/// <summary> /// Add Attachments to defect /// </summary> /// <param name="bug">TDAPIOLELib.Bug Object</param> /// <param name="attachmentsPath">List of attachment paths</param> /// <returns>True if Successfull</returns> public Boolean AddAttachment(TDAPIOLELib.Bug bug, List <String> attachmentsPath) { TDAPIOLELib.AttachmentFactory OAttachmentFactory; TDAPIOLELib.Attachment OAttachment; OAttachmentFactory = bug.Attachments; foreach (String AP in attachmentsPath) { if (System.IO.File.Exists(AP)) { OAttachment = OAttachmentFactory.AddItem(System.DBNull.Value); OAttachment.FileName = AP; OAttachment.Type = Convert.ToInt16(TDAPIOLELib.tagTDAPI_ATTACH_TYPE.TDATT_FILE); OAttachment.Post(); } } return(true); }
/// <summary> /// Downloads defect attachments /// </summary> /// <param name="bug"></param> /// <param name="attachmentDownloadPath"></param> /// <returns>True if Successfull</returns> public Boolean DownloadAttachments(TDAPIOLELib.Bug bug, String attachmentDownloadPath) { try { TDAPIOLELib.AttachmentFactory OAttachmentFactory; TDAPIOLELib.ExtendedStorage OExtendedStorage; if (bug.HasAttachment) { if ((System.IO.Directory.Exists(attachmentDownloadPath)) == false) { throw (new Exception("Attachment download path does not exist")); } //System.IO.Directory.CreateDirectory(AttachmentDownloadPath + "\\" + OBug.ID.ToString()); OAttachmentFactory = bug.Attachments; foreach (TDAPIOLELib.Attachment OAttachment in OAttachmentFactory.NewList("")) { OExtendedStorage = OAttachment.AttachmentStorage; OExtendedStorage.ClientPath = attachmentDownloadPath;// + "\\" + OBug.ID.ToString(); OAttachment.Load(true, OAttachment.Name); } return(true); } else { return(false); } } catch (Exception ex) { throw ex; } }
public void Verify_Defects() { Dictionary <String, String> defectDetails = new Dictionary <string, string>(); defectDetails.Add("BG_SUMMARY", "Defect created using Automation"); defectDetails.Add("BG_USER_TEMPLATE_01", "TEST"); defectDetails.Add("BG_DETECTED_IN_RCYC", "1014"); defectDetails.Add("BG_DETECTION_DATE", DateTime.Now.ToShortDateString()); defectDetails.Add("BG_SEVERITY", "Sev-3"); defectDetails.Add("BG_DETECTED_BY", "Sumeet.Kushwah"); TDAPIOLELib.Bug bug = aLM_CORE.Defect.Create(defectDetails); Console.WriteLine("Total Defects in Project : " + aLM_CORE.Defect.CountAll()); TDAPIOLELib.Recordset ORec = aLM_CORE.Defect.GetAllDetails(bug); Console.WriteLine("Writing all Database field names and values..."); for (int i = 0; i < ORec.RecordCount; i++) { for (int j = 0; j < ORec.ColCount; j++) { Console.WriteLine(ORec.ColName[j] + "--" + ORec[j]); } ORec.Next(); } //Create a test and Link defect to it // Create a test folder aLM_CORE.TestPlan.TestFolders.Create("Subject", "Dummy1"); //create a test here Dictionary <String, String> TestN = new Dictionary <String, String>(); TestN.Add("TS_NAME", "THIS IS DUMMUY TEST"); TestN.Add("TS_STATUS", "Ready"); TDAPIOLELib.Test test = aLM_CORE.TestPlan.Test.Create(TestN, "Subject\\Dummy1"); Console.WriteLine("Test Created Under Folder Subject\\Dummy1" + test.Name); aLM_CORE.Defect.LinkDefectToTest(test, bug, "Linking defect to test"); //Create a test set and Link defects to it aLM_CORE.TestLab.TestLabFolders.Create("Root", "Dummy1"); Dictionary <String, String> testSetDetails = new Dictionary <string, string>(); testSetDetails.Add("CY_CYCLE", "Dummy Test Set"); TDAPIOLELib.TestSet testSet = aLM_CORE.TestLab.TestSet.Create(testSetDetails, "Root\\Dummy1"); aLM_CORE.Defect.LinkDefectToTestSet(testSet, bug, "Test Set to Bug Linked"); TDAPIOLELib.TSTest tSTest = aLM_CORE.TestLab.TestSet.AddTest(testSet, test); aLM_CORE.Defect.LinkDefectToTestSetTest(tSTest, bug, "Test Set Test to Bug Linked"); TDAPIOLELib.List list = aLM_CORE.Defect.GetLinkedDefectsToTest(test); foreach (TDAPIOLELib.Bug bug1 in list) { Console.WriteLine("Defect Attached to test is : " + bug1.Summary); } list = aLM_CORE.Defect.GetLinkedDefectsToTestSet(testSet); foreach (TDAPIOLELib.Bug bug1 in list) { Console.WriteLine("Defect Attached to testset is : " + bug1.Summary); } list = aLM_CORE.Defect.GetLinkedDefectsToTestSetTest(tSTest); foreach (TDAPIOLELib.Bug bug1 in list) { Console.WriteLine("Defect Attached to testset test is : " + bug1.Summary); } List <String> Attach = new List <String>(); Attach.Add("C:\\Temp\\ALMUPLOAD\\DOC1.txt"); Attach.Add("C:\\Temp\\ALMUPLOAD\\DOC2.docx"); Attach.Add("C:\\Temp\\ALMUPLOAD\\DOC3.xlsx"); aLM_CORE.Defect.AddAttachment(bug, Attach); aLM_CORE.Defect.DownloadAttachments(bug, "C:\\Temp\\ALMDOWNLOAD"); aLM_CORE.Defect.DeleteAttachmentByName(bug, "DOC2.docx"); aLM_CORE.Defect.DeleteAllAttachments(bug); try { aLM_CORE.Defect.UpdateFieldValue(bug, "BG_STATUS", "Closed"); } catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); } bug = aLM_CORE.Defect.GetObjectWithID(Convert.ToInt32(bug.ID)); aLM_CORE.TestPlan.Test.Delete(test); aLM_CORE.TestPlan.TestFolders.Delete("Subject\\Dummy1"); aLM_CORE.TestLab.TestLabFolders.Delete("Root", "Dummy1"); aLM_CORE.TestLab.TestSet.Delete(testSet); aLM_CORE.Defect.Delete(bug); Console.WriteLine("Done"); }
/// <summary> /// Get all defect database field values. This Functions uses RecordSet object. /// <para/>You must have access to executing queries in ALM /// </summary> /// <param name="bug">TDAPIOLELib.Bug Object</param> /// <returns>true if successfull</returns> public TDAPIOLELib.Recordset GetAllDetails(TDAPIOLELib.Bug bug) { TDAPIOLELib.Recordset ORecordSet = Utilities.ExecuteQuery("Select * from Bug where BG_BUG_ID = " + bug.ID, tDConnection); ORecordSet.First(); return(ORecordSet); }
/// <summary> /// Links Defect to Run /// </summary> /// <param name="run">TDAPIOLELib.Run Object</param> /// <param name="bug">TDAPIOLELib.Bug Object</param> /// <param name="comment">Comment</param> /// <returns>True if Successfull</returns> public Boolean LinkDefectToRun(TDAPIOLELib.Run run, TDAPIOLELib.Bug bug, String comment = "") { return(LinkDefectToEntities(run, bug, comment)); }
/// <summary> /// Links Defect to TestSet /// </summary> /// <param name="testSet">TDAPIOLELib.TestSet Object</param> /// <param name="bug">TDAPIOLELib.Bug Object</param> /// <param name="comment">Comment</param> /// <returns>True if Successfull</returns> public Boolean LinkDefectToTestSet(TDAPIOLELib.TestSet testSet, TDAPIOLELib.Bug bug, String comment = "") { return(LinkDefectToEntities(testSet, bug, comment)); }
/// <summary> /// Links Defect to Requirement /// </summary> /// <param name="requirement">TDAPIOLELib.Req Object</param> /// <param name="bug">TDAPIOLELib.Bug Object</param> /// <param name="comment">Comment</param> /// <returns>True if Successfull</returns> public Boolean LinkDefectToRequirement(TDAPIOLELib.Req requirement, TDAPIOLELib.Bug bug, String comment = "") { return(LinkDefectToEntities(requirement, bug, comment)); }
/// <summary> /// Links defect to test step in test run /// </summary> /// <param name="step">TDAPIOLELib.Step Object</param> /// <param name="bug">TDAPIOLELib.Bug Object</param> /// <param name="comment">Comment</param> /// <returns>True if Successfull</returns> public Boolean LinkDefectToStep(TDAPIOLELib.Step step, TDAPIOLELib.Bug bug, String comment = "") { return(LinkDefectToEntities(step, bug, comment)); }