public async Task Request_Auth_App_Pass(string url) { var req = new HttpRequestMessage(HttpMethod.Get, url); await AccessTokenProvider.AuthenticateRequestAsAppAsync(req); var res = await Client.SendAsync(req); }
private async Task <HttpResponseMessage> DeleteResource(string url) { var req = new HttpRequestMessage(HttpMethod.Delete, url); await AccessTokenProvider.AuthenticateRequestAsAppAsync(req); return(await Client.SendAsync(req)); }
public async Task CallWithAppAuthenticationSucceeds(string url) { var req = new HttpRequestMessage(HttpMethod.Get, url); await AccessTokenProvider.AuthenticateRequestAsAppAsync(req); var res = await Client.SendAsync(req); Assert.Equal(HttpStatusCode.OK, res.StatusCode); }
public async Task GetOneProject_AfterDelete(string url, string projectNumber) { var req = new HttpRequestMessage(HttpMethod.Get, $"{url}/{projectNumber}"); await AccessTokenProvider.AuthenticateRequestAsAppAsync(req); var res = await Client.SendAsync(req); Assert.Equal(HttpStatusCode.NotFound, res.StatusCode); }
private async Task <int> GetLocationId(string province, string city) { var reqMasterlist = new HttpRequestMessage(HttpMethod.Get, "/api/masterlists"); await AccessTokenProvider.AuthenticateRequestAsAppAsync(reqMasterlist); var resMasterlist = await Client.SendAsync(reqMasterlist); string jsonString = await resMasterlist.Content.ReadAsStringAsync(); var locations = JsonConvert.DeserializeObject <OkResponse <MasterResource> >(jsonString).payload.Locations; return(locations[province][city]); }
private async Task <int> GetDisciplineIdFromName(string disciplineName) { var reqMasterlist = new HttpRequestMessage(HttpMethod.Get, "/api/masterlists"); await AccessTokenProvider.AuthenticateRequestAsAppAsync(reqMasterlist); var resMasterlist = await Client.SendAsync(reqMasterlist); string jsonString = await resMasterlist.Content.ReadAsStringAsync(); var disc = JsonConvert.DeserializeObject <OkResponse <MasterResource> >(jsonString).payload.Disciplines; return(disc[disciplineName].DisciplineID); }
public async Task GetOneUser_ExpectOneDiscipline(string url) { var req = new HttpRequestMessage(HttpMethod.Get, $"{url}/{userId}"); await AccessTokenProvider.AuthenticateRequestAsAppAsync(req); var res = await Client.SendAsync(req); Assert.Equal(HttpStatusCode.OK, res.StatusCode); string jsonString = await res.Content.ReadAsStringAsync(); var jsonObject = JsonConvert.DeserializeObject <OkResponse <UserProfile> >(jsonString); Assert.Single(jsonObject.payload.Disciplines); }
private async Task <HttpResponseMessage> GetResponseMessage_Location_POST(string url, string province, string city) { var location = JsonConvert.SerializeObject(GetLocationResource(province, city)); var req = new HttpRequestMessage(HttpMethod.Post, url) { Content = new StringContent( location, Encoding.UTF8, "application/json" ) }; await AccessTokenProvider.AuthenticateRequestAsAppAsync(req); return(await Client.SendAsync(req)); }
public async Task GetDisciplines_AfterCreate(string url) { var added = Data_POST_Pass().Select(p => p.GetValue(1)).ToHashSet(); var req = new HttpRequestMessage(HttpMethod.Get, url); await AccessTokenProvider.AuthenticateRequestAsAppAsync(req); var res = await Client.SendAsync(req); Assert.Equal(HttpStatusCode.OK, res.StatusCode); string jsonString = await res.Content.ReadAsStringAsync(); var jsonObject = JsonConvert.DeserializeObject <OkResponse <MasterResource> >(jsonString); Assert.True(added.IsProperSubsetOf(jsonObject.payload.Disciplines.Keys)); }
private async Task <HttpResponseMessage> GetResponseMessage_Skill_POST(string url, int disciplineId, string skillName) { var discSkill = JsonConvert.SerializeObject(GetDisciplineSkillResource(disciplineId, skillName)); var req = new HttpRequestMessage(HttpMethod.Post, url) { Content = new StringContent( discSkill, Encoding.UTF8, "application/json" ) }; await AccessTokenProvider.AuthenticateRequestAsAppAsync(req); return(await Client.SendAsync(req)); }
public async Task GetOneProject_AfterUpdate(string url, string projectNumber, string title) { var req = new HttpRequestMessage(HttpMethod.Get, $"{url}/{projectNumber}"); await AccessTokenProvider.AuthenticateRequestAsAppAsync(req); var res = await Client.SendAsync(req); Assert.Equal(HttpStatusCode.OK, res.StatusCode); string jsonString = await res.Content.ReadAsStringAsync(); var jsonObject = JsonConvert.DeserializeObject <OkResponse <ProjectProfile> >(jsonString); Assert.Equal(title, jsonObject.payload.ProjectSummary.Title); Assert.Single(jsonObject.payload.Openings); }
public async Task UpdateOneUser_Second(string url) { var userProfile = JsonConvert.SerializeObject(GetUserProfile(getTwo: false)); var req = new HttpRequestMessage(HttpMethod.Put, $"{url}/{userId}") { Content = new StringContent( userProfile, Encoding.UTF8, "application/json" ) }; await AccessTokenProvider.AuthenticateRequestAsAppAsync(req); var res = await Client.SendAsync(req); Assert.Equal(HttpStatusCode.OK, res.StatusCode); }
public async Task CreateOneProject(string url, string projectNumber, string title, string discipline, HashSet <string> skills) { var projectProfile = JsonConvert.SerializeObject(GetProjectProfile(managerId, projectNumber, title, discipline, skills)); var req = new HttpRequestMessage(HttpMethod.Post, url) { Content = new StringContent( projectProfile, Encoding.UTF8, "application/json" ) }; await AccessTokenProvider.AuthenticateRequestAsAppAsync(req); var res = await Client.SendAsync(req); Assert.Equal(HttpStatusCode.Created, res.StatusCode); }
public async Task UpdateOneProject(string url, string projectNumber, string title, string discipline, HashSet <string> skills) { // var discipline = "Automation"; // var skills = new HashSet<string> { "Automated teller machines", "Digital labor" }; var projectProfile = JsonConvert.SerializeObject(GetProjectProfile(managerId, projectNumber, title, discipline, skills)); var req = new HttpRequestMessage(HttpMethod.Put, $"{url}/{projectNumber}") { Content = new StringContent( projectProfile, Encoding.UTF8, "application/json" ) }; await AccessTokenProvider.AuthenticateRequestAsAppAsync(req); var res = await Client.SendAsync(req); Assert.Equal(HttpStatusCode.OK, res.StatusCode); }
public async Task SearchUsers(string url) { var searchWord = "ge"; var reqSearch = JsonConvert.SerializeObject(GetRequestSearch(searchWord)); var req = new HttpRequestMessage(HttpMethod.Post, url) { Content = new StringContent( reqSearch, Encoding.UTF8, "application/json" ) }; await AccessTokenProvider.AuthenticateRequestAsAppAsync(req); var res = await Client.SendAsync(req); Assert.Equal(HttpStatusCode.OK, res.StatusCode); string jsonString = await res.Content.ReadAsStringAsync(); var jsonObject = JsonConvert.DeserializeObject <OkResponse <IEnumerable <UserSummary> > >(jsonString); var userNames = jsonObject.payload.Select(us => $"{us.FirstName} {us.LastName}").ToList(); Assert.True(userNames.All(name => name.ToLower().Trim().Contains(searchWord))); }