public void TestUpdateListName() { var listName = "Updated Name"; var result = listQueries.UpdateList(3, listName); Assert.AreEqual(true, result); Assert.AreEqual("Updated Name", db.LALists.Find(3).Name); Assert.AreEqual(2, db.LALists.Find(3).LAListItems.Count); }
public void TestUpdateListNameNull() { LAList testList = ListQueries.GetList(1); Assert.IsNotNull(testList); testList.Name = null; var result = ListQueries.UpdateList(testList); testList = ListQueries.GetList(1); testList.Name = "Groceries"; Assert.AreEqual(false, result); Assert.IsNotNull(testList); Assert.AreEqual("Groceries", testList.Name); }
public void TestUpdateListAddNullItems() { LAList testList = ListQueries.GetList(1); Assert.IsNotNull(testList); testList.LAListItems.Add(null); var result = ListQueries.UpdateList(testList); testList = null; testList = ListQueries.GetList(1); Assert.AreEqual(true, result); Assert.IsNotNull(testList); Assert.AreEqual("Groceries", testList.Name); Assert.AreEqual(4, testList.LAListItems.Count); }
public HttpStatusCode UpdateList() { JObject jsonObj = null; ShoppingList newList = null; ShoppingListItem newItem = null; jsonObj = JObject.Parse(Request.Content.ReadAsStringAsync().Result); newList = new ShoppingList(); newList.Id = (int)jsonObj["ID"]; newList.Name = jsonObj["Name"].ToString(); foreach (var jsonItem in jsonObj["LAListItems"].Children()) { newItem = new ShoppingListItem(); newItem.Id = (int)jsonItem["ID"]; newItem.ListId = (int)jsonItem["ListID"]; newItem.Description = jsonItem["Description"].ToString(); newItem.Checked = (bool)jsonItem["Done"]; newList.ShoppingListItems.Add(newItem); } var result = listQueries.UpdateList(newList.Id, newList.Name); if (result) { foreach (var item in newList.ShoppingListItems) { if (!listQueries.UpdateItemFromList(item)) { return(HttpStatusCode.InternalServerError); } } return(HttpStatusCode.OK); } return(HttpStatusCode.InternalServerError); }
public void TestUpdateListName() { LAList testList = ListQueries.GetList(1); Assert.IsNotNull(testList); testList.Name = "Updated Name"; var result = ListQueries.UpdateList(testList); testList = ListQueries.GetList(1); Assert.AreEqual(true, result); Assert.AreEqual("Updated Name", testList.Name); Assert.AreEqual(4, testList.LAListItems.Count); testList.Name = "Groceries"; var restoreName = ListQueries.UpdateList(testList); testList = ListQueries.GetList(1); Assert.AreEqual(true, restoreName); Assert.AreEqual("Groceries", testList.Name); }