public async Task <IActionResult> PutTestAPI(int id, TestAPI testAPI) { if (id != testAPI.Id) { return(BadRequest()); } _context.Entry(testAPI).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TestAPIExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <TestAPI> > PostTestAPI(TestAPI testAPI) { _context.API.Add(testAPI); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTestAPI", new { id = testAPI.Id }, testAPI)); }
public void AddItems(bool PlayerItems) { if (TestAPI.IsHasToken) { new Thread(new ThreadStart(async() => { if (!PlayerItems) { itemsFormServer = await TestAPI.GetMarketItems(); } else { itemsFormServer = await TestAPI.GetPlayerItems(); } Dispatcher.Invoke(() => { AddItemsOnBoard(); }); })).Start(); } else { Debug.LogError("User haven't token"); } }
public async Task LoginWithAlreadyCreatedUser_Test() { var newUserJson = dataFake.GetDefaultLoginUserRequest(); var api = new TestAPI(); var loginWithNewUserResponse = await api.LoginWithAlreadyCreatedUser($"{_loginWithNewUser}", newUserJson); Assert.NotNull(loginWithNewUserResponse); Assert.AreEqual(newUserJson.createUser.Username, loginWithNewUserResponse.User.Username); Assert.AreEqual(newUserJson.createUser.Email, loginWithNewUserResponse.User.Email); }
public async Task RegisterNewUser_Test() { var newUserJson = dataFake.GetJCreateUSers(); var api = new TestAPI(); var response = await api.RegisterNewUser($"{_registerUserURL}", newUserJson); Assert.NotNull(response); Assert.AreEqual(newUserJson.createUser.Username, response.User.Username); Assert.AreEqual(newUserJson.createUser.Email, response.User.Email); }
public async Task CreateAnArticleWithAlreadyLogedInUser_Test() { var currentUser = dataFake.GetDefaultCurrentJNewUser(); var newArticle = dataFake.GetJCreateArticle(); var api = new TestAPI(); var newlyCreatedArticleResponse = await api.CreateAnArticleWithAlreadyLogedInUser($"{_createArticle}", currentUser, newArticle); Assert.NotNull(newlyCreatedArticleResponse); Assert.AreEqual(currentUser.User.Username, newlyCreatedArticleResponse.Article.Author.Username); Assert.AreEqual(newArticle.Article.Body, newlyCreatedArticleResponse.Article.Body); Assert.AreEqual(newArticle.Article.Description, newlyCreatedArticleResponse.Article.Description); Assert.AreEqual(newArticle.Article.Title, newlyCreatedArticleResponse.Article.Title); Assert.AreEqual(newArticle.Article.TagList, newlyCreatedArticleResponse.Article.TagList); }
//####################################################################################################################################### // Will do a Left mouse Click on the XenCenter element //####################################################################################################################################### public AutomationElement ClickOnXenCenterNode(AutomationElement XenCenterObj, string LogFilePath, int TerminateStatus) { Logger NewLogObj = new Logger(); NewLogObj.WriteLogFile(LogFilePath, "ClickOnXenCenterNode", "info"); NewLogObj.WriteLogFile(LogFilePath, "=============================", "info"); AutomationElementIdentity GuiObj = new AutomationElementIdentity(); try { // AutomationElement SearchObj=TypeInXenCenterSearchBox(XenCenterObj, TextToSelect, 1, LogFilePath); PropertyCondition TreeReturnCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "treeView", 1, LogFilePath); AutomationElement ServerPane = GuiObj.FindAutomationElement(XenCenterObj, TreeReturnCondition, TreeScope.Descendants, "Server Paniewe V", 0, LogFilePath); PropertyCondition XenCenterParentCondition = GuiObj.SetPropertyCondition("NameProperty", "XenCenter", 1, LogFilePath); AutomationElement XenCenterParentElement = GuiObj.FindAutomationElement(ServerPane, XenCenterParentCondition, TreeScope.Descendants, "XenCenterParentElement", 0, LogFilePath); ExpandCollapsePattern expPattern = XenCenterParentElement.GetCurrentPattern(ExpandCollapsePattern.Pattern) as ExpandCollapsePattern; Thread.Sleep(1000); if (string.Compare(expPattern.Current.ExpandCollapseState.ToString(), "Collapsed") == 0) { expPattern.Expand(); } TestAPI TestApiObj = new TestAPI(); TestApiObj.ClickLeftBtnOnAutomationElement(XenCenterParentElement, 1, LogFilePath); return(XenCenterParentElement); } catch (Exception Ex) { NewLogObj.WriteLogFile(LogFilePath, "Exception at ClickOnXenCenterNode" + Ex.ToString(), "fail"); if (TerminateStatus == 1) { NewLogObj.WriteLogFile(LogFilePath, TerminateStatus + "is 1.", "info"); NewLogObj.WriteLogFile(LogFilePath, "***Exiting application from ClickOnXenCenterNode as main menunot found**", "fail"); FileOperations FileObj = new FileOperations(); FileObj.ExitTestEnvironment(); return(null); } else { NewLogObj.WriteLogFile(LogFilePath, TerminateStatus + "is 0.", "info"); return(null); } } }
public async Task LoginButton_click(UIButton sender) { hud = new MTMBProgressHUD(View) { LabelText = "Waiting...", RemoveFromSuperViewOnHide = true, }; View.AddSubview(hud); hud.Show(animated: true); APIClient ApiClient = new APIClient(); TestAPI cd = new TestAPI(ApiClient); var apiResponse = await cd.ExecuteAsync <YourType>(); hud.Hide(animated: true); }
public async Task CreateAnCommentToNewlyCreatedArticle_Test() { var newlyCreatedArticle = dataFake.GetNewArticleForResponse(); var currentUser = dataFake.GetDefaultCurrentJNewUser(); var slug = newlyCreatedArticle.Slug; var newComment = dataFake.GetJCreateComment(); var api = new TestAPI(); var newlyCreatedCommentResponse = await api.CreateAnCommentToNewlyCreatedArticle($"{_createArticle}/{slug}/comments", currentUser, newComment); Assert.NotNull(newlyCreatedCommentResponse); Assert.AreEqual(currentUser.User.Username, newlyCreatedCommentResponse.Comment.Author.Username); Assert.AreEqual(newComment.Comment.Body, newlyCreatedCommentResponse.Comment.Body); }
public async Task LoginWithNewRegistratedUser_Test() { var newUserJson = dataFake.GetJCreateUSers(); var api = new TestAPI(); var registerNewUserResponse = await api.RegisterNewUser($"{_registerUserURL}", newUserJson); var loginWithNewUserResponse = await api.LoginWithAlreadyCreatedUser($"{_loginWithNewUser}", newUserJson); Assert.NotNull(loginWithNewUserResponse); Assert.AreEqual(registerNewUserResponse.User.Id, loginWithNewUserResponse.User.Id); Assert.AreEqual(registerNewUserResponse.User.Username, loginWithNewUserResponse.User.Username); Assert.AreEqual(registerNewUserResponse.User.Email, loginWithNewUserResponse.User.Email); Assert.AreEqual(registerNewUserResponse.User.Bio, loginWithNewUserResponse.User.Bio); Assert.AreEqual(registerNewUserResponse.User.Image, loginWithNewUserResponse.User.Image); Assert.AreEqual(registerNewUserResponse.User.UpdatedAt, loginWithNewUserResponse.User.UpdatedAt); Assert.AreEqual(registerNewUserResponse.User.CreatedAt, loginWithNewUserResponse.User.CreatedAt); }
public async Task <IActionResult> TestAPI() { await RefreshTokens(); var accessToken = await HttpContext.Authentication.GetTokenAsync("access_token"); //httpClient.SetBearerToken(accessToken); // or var httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); var testTask = await httpClient.GetAsync("http://localhost:1746/test"); var testReadStringTask = testTask.Content.ReadAsStringAsync(); TestAPI model = JsonConvert.DeserializeObject <TestAPI>(testReadStringTask.Result); return(View(model)); }
public void PostAPITestcase() { try { _qvizClient.Authenticate(QVizUser, QVizPassword); var project = _qvizClient.GetProject(QVizProject); var testTags = new List <Tag> { new Tag { tagId = null, tagName = "TestTag1" }, new Tag { tagId = null, tagName = "TestTag2" } }; /// Test PAI List <TestAPI> listTestAPI = new List <TestAPI>(); #region API header APIHeaderValue apiHeaderValue = new APIHeaderValue { headerValueId = null, key = "ContentType", value = "application/json" }; APIHeader header = new APIHeader { headerValueId = null, headerValue = apiHeaderValue, apiId = null, apiHeaderId = null, srNo = 1, }; List <APIHeader> headers = new List <APIHeader> { header }; #endregion #region API Query APIQueryValue apiQueryValue = new APIQueryValue { queryValueId = null, key = "projectId", value = "12334", }; APIQuery query = new APIQuery { queryValueId = null, queryValue = apiQueryValue, apiId = null, apiQueryId = null, srNo = 1, }; List <APIQuery> queries = new List <APIQuery> { query }; APIBodyValue apiBodyValue = new APIBodyValue { bodyValueId = null, jsonString = "{ id=\"100\", name=\"Cars\"}", }; APIBody body = new APIBody { srNo = 1, apiBodyId = null, bodyValueId = null, apiId = null, bodyValue = apiBodyValue, }; #endregion API api = new API { apiId = null, uri = "/Products", method = "GET", expectedHTTPStatus = 200, expectedJSONResult = "[{ id=\"100\", name=\"Cars\"}]", apiHeaders = headers, apiQueries = queries, apiBody = body, moduleId = null, subModuleId = null, apiTags = null, testAPIs = null, }; var testAPI = new TestAPI { srNo = 1, testAPIId = null, testCaseId = null, apiId = null, api = api, }; List <TestAPI> apis = new List <TestAPI> { testAPI }; // Test case TestCaseAPI apiTC = new TestCaseAPI { testCaseId = null, projectId = project.projectId, moduleId = modules.FirstOrDefault().moduleId, subModuleId = subModules.FirstOrDefault().subModuleId, description = "Demo API Test case " + DateTime.Now.Ticks, isAutomated = false, priority = "P1", severity = "1", expectedResult = "Demo API TC expected result", testCaseTypeId = testcaseTypes.FirstOrDefault(f => f.name.ToLower() == "api").testCaseTypeId, testToolID = "DemoTool1", testTags = testTags, testAPIs = apis, module = null, subModule = null, }; _qvizClient.PostAPITest(apiTC); string response = _qvizClient.LastResponse(); QVizResponseObject <TestCaseAPI> qVizResponse = JsonConvert.DeserializeObject <QVizResponseObject <TestCaseAPI> >(response); Assert.AreEqual("Test case created successfully", qVizResponse.Message); } catch (Exception error) { Assert.Fail(error.Message); } }
//######################################################################################### // Check the Xencenter server node tree for an element //Will perform a click on the found element if 'Click' is set to 1. ClickMouseBtn should be either left or right. will simulate right or left click //######################################################################################### public AutomationElement CheckXenCenterServerNodetree(AutomationElement XenCenterObj, string ElementToCheck, string LogFilePath, int TerminateStatus, int ClickRequired, string ClickMouseBtn) { Logger NewLogObj = new Logger(); NewLogObj.WriteLogFile(LogFilePath, "CheckXenCenterServerNodetree", "info"); NewLogObj.WriteLogFile(LogFilePath, "=============================", "info"); AutomationElementIdentity GuiObj = new AutomationElementIdentity(); try { PropertyCondition TreeReturnCondition = GuiObj.SetPropertyCondition("AutomationIdProperty", "treeView", 1, LogFilePath); AutomationElement ServerPane = GuiObj.FindAutomationElement(XenCenterObj, TreeReturnCondition, TreeScope.Descendants, "Server Paniewe V", 0, LogFilePath); PropertyCondition XenCenterParentCondition = GuiObj.SetPropertyCondition("NameProperty", "XenCenter", 1, LogFilePath); AutomationElement XenCenterParentElement = GuiObj.FindAutomationElement(ServerPane, XenCenterParentCondition, TreeScope.Descendants, "XenCenterParentElement", 0, LogFilePath); if (ClickRequired == 1) { int PatternSupport = GuiObj.CheckIfPatternIsSupported(XenCenterParentElement, "ExpandCollapse"); if (PatternSupport == 1) { ExpandCollapsePattern expPattern = XenCenterParentElement.GetCurrentPattern(ExpandCollapsePattern.Pattern) as ExpandCollapsePattern; Thread.Sleep(1000); if (string.Compare(expPattern.Current.ExpandCollapseState.ToString(), "Collapsed") == 0) { expPattern.Expand(); } } } TestAPI TestApiObj = new TestAPI(); //TestApiObj.ClickLeftBtnOnAutomationElement(XenCenterParentElement, 1, LogFilePath); //AutomationElement SearchElement = GuiObj.GetTheTreeElement(XenCenterParentElement, ElementToCheck, LogFilePath); AutomationElement SearchElement = GuiObj.CheckTreeForElementAndClickIfReqd(XenCenterParentElement, ElementToCheck, 0, "0", LogFilePath); if (SearchElement != null && ClickRequired == 1) { //TestApiObj.ClickLeftBtnOnAutomationElement(SearchElement, 1, LogFilePath); //SelectionItemPattern SelectionPattern = SearchElement.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern; //SelectionPattern.Select(); GuiObj.GetPositionFromBoundingRectangleAndClick(SearchElement, LogFilePath, ClickMouseBtn); } if (SearchElement != null) { NewLogObj.WriteLogFile(LogFilePath, "SearchElement found", "info"); return(SearchElement); } else { NewLogObj.WriteLogFile(LogFilePath, "SearchElement returnd is null", "fail"); if (TerminateStatus == 1) { NewLogObj.WriteLogFile(LogFilePath, TerminateStatus + "is 1.", "info"); NewLogObj.WriteLogFile(LogFilePath, "***Exiting application from CheckXenCenterServerNodetree as SearchElement returnd is null**", "fail"); FileOperations FileObj = new FileOperations(); FileObj.ExitTestEnvironment(); return(null); } else { NewLogObj.WriteLogFile(LogFilePath, TerminateStatus + "is 0.", "info"); return(null); } } } catch (Exception Ex) { NewLogObj.WriteLogFile(LogFilePath, "Exception at ClickOnXenCenterNode" + Ex.ToString(), "fail"); if (TerminateStatus == 1) { NewLogObj.WriteLogFile(LogFilePath, TerminateStatus + "is 1.", "info"); NewLogObj.WriteLogFile(LogFilePath, "***Exiting application from ClickOnXenCenterNode as main menunot found**", "fail"); FileOperations FileObj = new FileOperations(); FileObj.ExitTestEnvironment(); return(null); } else { NewLogObj.WriteLogFile(LogFilePath, TerminateStatus + "is 0.", "info"); return(null); } } }