public async Task BAM_HardwareAssetNotificationTemplate_Get_List() { var queryResult = _bamClient._client.GetAsync("api/V3/Template/GetHardwareAssetNotificationTemplates").Result; Assert.IsTrue(queryResult.IsSuccessStatusCode, "Query Status Code isn't Success: " + queryResult.StatusCode.ToString()); Assert.IsNotNull(queryResult, "queryResult is empty"); var resultSring = queryResult.Content.ReadAsStringAsync().Result; Assert.IsFalse(string.IsNullOrEmpty(resultSring), "Query resultSring is null"); var resultTemp = JsonConvert.DeserializeObject <TemplateClass[]>(resultSring); Assert.IsNotNull(resultTemp, "Query resultTemp is null"); Assert.IsTrue(resultTemp.Any(), "Query resultTemp doesn't contain any items"); var result = new TemplateClassList() { TemplateClasses = resultTemp.ToList() }; //var result = queryResult.Content.ReadAsAsync<ArticleList>().Result; Assert.IsNotNull(result, "Query result is null"); Assert.IsNotNull(result.TemplateClasses, "Articles list is null"); Assert.IsTrue(result.TemplateClasses.Any(), "Articles doesn't contain any items"); }
public async Task BAM_Templates_for_Class_FirstRecord_Get_List() { var templateList = GetTemplateList(); var deviceItem = templateList.TemplateClasses.Where(x => x.Name == "Computer").FirstOrDefault(); Assert.IsNotNull(deviceItem, "deviceItem is empty"); Assert.IsFalse(string.IsNullOrEmpty(deviceItem.Id), "deviceItem id is empty"); var queryResult = _bamClient._client.GetAsync(string.Format("api/V3/Template/GetTemplates?classId={0}", deviceItem.Id)).Result; Assert.IsTrue(queryResult.IsSuccessStatusCode, "Query Status Code isn't Success: " + queryResult.StatusCode.ToString()); Assert.IsNotNull(queryResult, "queryResult is empty"); var resultSring = queryResult.Content.ReadAsStringAsync().Result; Assert.IsFalse(string.IsNullOrEmpty(resultSring), "Query resultSring is null"); var resultTemp = JsonConvert.DeserializeObject <TemplateClass[]>(resultSring); Assert.IsNotNull(resultTemp, "Query resultTemp is null"); Assert.IsTrue(resultTemp.Any(), "Query resultTemp doesn't contain any items"); var result = new TemplateClassList() { TemplateClasses = resultTemp.ToList() }; //var result = queryResult.Content.ReadAsAsync<ArticleList>().Result; Assert.IsNotNull(result, "Query result is null"); Assert.IsNotNull(result.TemplateClasses, "Articles list is null"); Assert.IsTrue(result.TemplateClasses.Any(), "Articles doesn't contain any items"); }
private TemplateClassList GetTemplateList() { var queryResult = _bamClient._client.GetAsync("api/V3/Template/GetAllClasses").Result; var resultSring = queryResult.Content.ReadAsStringAsync().Result; var resultTemp = JsonConvert.DeserializeObject <TemplateClass[]>(resultSring); var result = new TemplateClassList() { TemplateClasses = resultTemp.ToList() }; return(result); }