public void CountryPostTest(IDictionary testData) { #region Arrange var currentEntity = new CountryDataObject(); var include = ""; var token = ""; currentEntity.IsNew = Convert.ToBoolean(testData["IsNew"].ToString()); if (!currentEntity.IsNew) { currentEntity.URI = testData["URI"].ToString().Trim() != null ? testData["URI"].ToString().Trim().ToString() : null; include = testData["Include"].ToString().Trim(); } currentEntity.Abstract = testData["Abstract"]?.ToString().Trim() != null ? testData["Abstract"]?.ToString().Trim().ToString() : null; currentEntity.Flag = testData["Flag"]?.ToString().Trim() != null ? testData["Flag"]?.ToString().Trim().ToString() : null; currentEntity.LongName = testData["Long Name"]?.ToString().Trim() != null ? testData["Long Name"]?.ToString().Trim().ToString() : null; currentEntity.Name = testData["Name"]?.ToString().Trim() != null ? testData["Name"]?.ToString().Trim().ToString() : null; currentEntity.PopulationDensity = testData["Population Density"]?.ToString().Trim() == null ? (decimal?)null : Convert.ToDecimal(testData["Population Density"]?.ToString().Trim().Replace(".", ",")); currentEntity.PopulationTotal = Convert.ToInt64(testData["Population Total"]?.ToString().Trim()); var expected_result = ConvertToStatusCode(testData["Result"]); #endregion #region Act var json = JsonConvert.SerializeObject(currentEntity); var postUrl = APITestManager.doPostRequestBody(json, include); APIWebRequest request = new APIWebRequest(); var username = testData["Username"].ToString().Trim(); var password = testData["Password"].ToString().Trim(); token = request.getToken(APITestManager.getAuthenticateUrl(), username, password); using (var testResponse = request.ProcessAPIWebRequest(appUrl, APIWebRequest.TypeCall.Save, postUrl, token)) { var status_code = testResponse.StatusCode; var status_description = testResponse.Status; var response_body = testResponse.Body; #endregion #region Assert APITestManager.displayResponse(testResponse); Assert.AreEqual(expected_result, status_code); if (status_code == HttpStatusCode.OK) { // to be implemented } #endregion } }
public void VisitedPlacePostTest(IDictionary testData) { #region Arrange var currentEntity = new VisitedPlaceDataObject(); var include = ""; var token = ""; currentEntity.IsNew = Convert.ToBoolean(testData["IsNew"].ToString()); if (!currentEntity.IsNew) { currentEntity.Id = System.Guid.Parse(testData["Id"].ToString().Trim()); include = testData["Include"].ToString().Trim(); } currentEntity.CountryURI = testData["CountryURI"]?.ToString().Trim() != null ? testData["CountryURI"]?.ToString().Trim().ToString() : null; currentEntity.Date = Convert.ToDateTime(testData["Date"]?.ToString().Trim()); currentEntity.Description = testData["Description"]?.ToString().Trim() != null ? testData["Description"]?.ToString().Trim().ToString() : null; currentEntity.PlaceURI = testData["PlaceURI"]?.ToString().Trim() != null ? testData["PlaceURI"]?.ToString().Trim().ToString() : null; currentEntity.Typeofplace = (PlaceTypesEnum)Convert.ToInt32(testData["Type of place"]?.ToString().Trim()); currentEntity.UserProfileUri = testData["UserProfileUri"]?.ToString().Trim() != null ? testData["UserProfileUri"]?.ToString().Trim().ToString() : null; var expected_result = ConvertToStatusCode(testData["Result"]); #endregion #region Act var json = JsonConvert.SerializeObject(currentEntity); var postUrl = APITestManager.doPostRequestBody(json, include); APIWebRequest request = new APIWebRequest(); var username = testData["Username"].ToString().Trim(); var password = testData["Password"].ToString().Trim(); token = request.getToken(APITestManager.getAuthenticateUrl(), username, password); using (var testResponse = request.ProcessAPIWebRequest(appUrl, APIWebRequest.TypeCall.Save, postUrl, token)) { var status_code = testResponse.StatusCode; var status_description = testResponse.Status; var response_body = testResponse.Body; #endregion #region Assert APITestManager.displayResponse(testResponse); Assert.AreEqual(expected_result, status_code); if (status_code == HttpStatusCode.OK) { // to be implemented } #endregion } }
public void GORolePostTest(IDictionary testData) { #region Arrange var currentEntity = new GORoleDataObject(); var include = ""; var token = ""; currentEntity.IsNew = Convert.ToBoolean(testData["IsNew"].ToString()); if (!currentEntity.IsNew) { currentEntity.Name = testData["Name"].ToString().Trim() != null ? testData["Name"].ToString().Trim().ToString() : null; include = testData["Include"].ToString().Trim(); } currentEntity.Description = testData["Description"]?.ToString().Trim() != null ? testData["Description"]?.ToString().Trim().ToString() : null; currentEntity.DisplayName = testData["Display name"]?.ToString().Trim() != null ? testData["Display name"]?.ToString().Trim().ToString() : null; currentEntity.PasswordExpiry = Convert.ToInt32(testData["Password Expiry"]?.ToString().Trim()); currentEntity.PasswordPolicySummary = testData["Password Policy Summary"]?.ToString().Trim() != null ? testData["Password Policy Summary"]?.ToString().Trim().ToString() : null; currentEntity.PasswordRegEx = testData["Password RegEx"]?.ToString().Trim() != null ? testData["Password RegEx"]?.ToString().Trim().ToString() : null; var expected_result = ConvertToStatusCode(testData["Result"]); #endregion #region Act var json = JsonConvert.SerializeObject(currentEntity); var postUrl = APITestManager.doPostRequestBody(json, include); APIWebRequest request = new APIWebRequest(); var username = testData["Username"].ToString().Trim(); var password = testData["Password"].ToString().Trim(); token = request.getToken(APITestManager.getAuthenticateUrl(), username, password); using (var testResponse = request.ProcessAPIWebRequest(appUrl, APIWebRequest.TypeCall.Save, postUrl, token)) { var status_code = testResponse.StatusCode; var status_description = testResponse.Status; var response_body = testResponse.Body; #endregion #region Assert APITestManager.displayResponse(testResponse); Assert.AreEqual(expected_result, status_code); if (status_code == HttpStatusCode.OK) { // to be implemented } #endregion } }