public void Comps_Graph_S05_TC04_CanPatchMe() { GraphPages.Navigation.Select("Graph explorer"); string userName = GraphUtility.GetConfigurationValue("GraphExplorerUserName"); if (!GraphUtility.IsLoggedIn()) { GraphUtility.ClickLogin(); GraphUtility.Login( userName, GraphUtility.GetConfigurationValue("GraphExplorerPassword")); } //Change the operation from GET to PATCH GraphUtility.ClickButton("GET"); GraphUtility.Click("PATCH"); string jobTitle = "JobTitle_" + DateTime.Now.ToString("M/d/yyyy/hh/mm/ss"); Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("jobTitle", jobTitle); GraphUtility.InputExplorerJSONBody(dic); GraphUtility.InputExplorerQueryString("https://graph.microsoft.com/v1.0/me" + "\n"); GraphBrowser.WaitForExploreResponse(); string patchResponse = GraphUtility.GetExplorerResponse(); //Change the operation from PATCH to GET GraphUtility.ClickButton("PATCH"); GraphUtility.Click("GET"); GraphUtility.InputExplorerQueryString("https://graph.microsoft.com/v1.0/me" + "\n"); string getResponse = GraphUtility.GetExplorerResponse(); //The response doesn't change means no GET response is returned.So wait and re-obtain it int waitTime = Int32.Parse(GraphUtility.GetConfigurationValue("WaitTime")); int retryCount = Int32.Parse(GraphUtility.GetConfigurationValue("RetryCount")); int i = 0; while (i < retryCount && getResponse == patchResponse) { GraphBrowser.Wait(TimeSpan.FromSeconds(waitTime)); getResponse = GraphUtility.GetExplorerResponse(); i++; } string newjobTitle = GraphUtility.GetProperty(getResponse, "jobTitle"); Assert.AreEqual(jobTitle, newjobTitle, "The patched property should be updated accordingly"); }
public void Comps_Graph_S05_TC05_CanPostDeleteGroup() { GraphPages.Navigation.Select("Graph explorer"); int waitTime = Int32.Parse(GraphUtility.GetConfigurationValue("WaitTime")); int retryCount = Int32.Parse(GraphUtility.GetConfigurationValue("RetryCount")); string userName = GraphUtility.GetConfigurationValue("GraphExplorerUserName"); if (!GraphUtility.IsLoggedIn()) { GraphUtility.ClickLogin(); GraphUtility.Login( userName, GraphUtility.GetConfigurationValue("GraphExplorerPassword")); } //Change the operation from GET to POST GraphUtility.ClickButton("GET"); GraphUtility.Click("POST"); Dictionary <string, string> postProperties = new Dictionary <string, string>(); postProperties.Add("description", "A group for test"); string groupDisplayName = "TestGroup_" + DateTime.Now.ToString("M/d/yyyy/hh/mm/ss"); postProperties.Add("displayName", groupDisplayName); postProperties.Add("mailEnabled", "false"); postProperties.Add("securityEnabled", "true"); postProperties.Add("mailNickname", "TestGroupMail"); GraphUtility.InputExplorerJSONBody(postProperties); GraphUtility.InputExplorerQueryString("https://graph.microsoft.com/v1.0/groups" + "\n"); GraphBrowser.WaitForExploreResponse(); string postResponse = GraphUtility.GetExplorerResponse(); string postID = GraphUtility.GetProperty(postResponse, "id"); string postDisplayName = GraphUtility.GetProperty(postResponse, "displayName"); // Reload the page to empty the response GraphBrowser.Refresh(); //Check whether the created group can be gotten GraphUtility.InputExplorerQueryString("https://graph.microsoft.com/v1.0/groups/" + postID + "\n"); GraphBrowser.WaitForExploreResponse(); string getResponse = GraphUtility.GetExplorerResponse(); string getDisplayName = GraphUtility.GetProperty(getResponse, "displayName"); Assert.AreEqual( postDisplayName, getDisplayName, "The posted group should be able to GET"); // Reload the page to empty the response GraphBrowser.Refresh(); GraphUtility.ClickButton("GET"); GraphUtility.Click("DELETE"); GraphUtility.InputExplorerQueryString("https://graph.microsoft.com/v1.0/groups/" + postID + "\n"); GraphBrowser.WaitForExploreResponse(); string deleteResponse = GraphUtility.GetExplorerResponse(); GraphUtility.Click("DELETE"); GraphUtility.ClickButton("GET"); GraphUtility.InputExplorerQueryString("https://graph.microsoft.com/v1.0/groups/" + postID + "\n"); int i = 0; do { GraphBrowser.Wait(TimeSpan.FromSeconds(waitTime)); getResponse = GraphUtility.GetExplorerResponse(); i++; } while (i < retryCount && getResponse.Equals(deleteResponse)); Assert.IsTrue( getResponse.Contains("Request_ResourceNotFound"), "The group should be deleted successfully"); }