Exemplo n.º 1
0
            public void TestGetSingleList()
            {
                var list = listQueries.GetList(3);

                Assert.IsNotNull(list);
                Assert.AreEqual(true, list.Name.Equals("Test List 1"));
                Assert.AreEqual(2, list.ShoppingListItems.Count);
            }
Exemplo n.º 2
0
        public void TestAddListToDBNoItems()
        {
            var listName = "Test List 4";

            var lists = new List <LAList>
            {
                new LAList {
                    Name = listName
                }
            };

            ListQueries.AddList(lists[0]);
            var result = ListQueries.GetList(3);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.LAListItems.Count, 0, "Number of list items is not 0");

            var findResult = ListQueries.GetList(3);

            Assert.IsNotNull(findResult);
            Assert.AreEqual <string>("Test List 4", findResult.Name);

            ListQueries.RemoveList(findResult.ID);
            Assert.AreEqual(2, ListQueries.GetLists().Count);
        }
Exemplo n.º 3
0
        public void TestAddListItem()
        {
            LAList testList = new LAList()
            {
                Name = "List to Remove"
            };

            ListQueries.AddList(testList);

            Assert.IsNotNull(ListQueries.GetList(testList.ID));
            Assert.AreEqual(0, ListQueries.GetList(testList.ID).LAListItems.Count);

            var newItem = new LAListItem()
            {
                Description = "Test Item",
                Done        = true,
                ListID      = testList.ID
            };

            var result    = ListQueries.AddItemToList(newItem);
            var foundList = ListQueries.GetList(testList.ID);

            Assert.AreEqual(true, result);
            Assert.IsNotNull(foundList);
            Assert.AreEqual(1, foundList.LAListItems.Count);

            ListQueries.RemoveList(foundList.ID);
            Assert.AreEqual(2, ListQueries.GetLists().Count);
        }
Exemplo n.º 4
0
        public void TestGetSingleList()
        {
            var list = ListQueries.GetList(1);

            Assert.IsNotNull(list);
            Assert.AreEqual(1, list.ID);
            Assert.AreEqual(true, list.Name.Equals("Groceries"));
            Assert.AreEqual(4, list.LAListItems.Count);
        }
Exemplo n.º 5
0
        public HttpResponseMessage SingleList(int listId)
        {
            var result = listQueries.GetList(listId);

            if (result != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, result));
            }
            return(Request.CreateResponse(HttpStatusCode.NotFound));
        }
Exemplo n.º 6
0
        public void TestRemoveItemBadId()
        {
            LAList testList  = ListQueries.GetList(1);
            var    itemCount = testList.LAListItems.Count;

            var result = ListQueries.DeleteItemFromList(-99);

            testList = ListQueries.GetList(1);
            Assert.AreEqual(-1, result);
            Assert.AreEqual(itemCount, testList.LAListItems.Count);
        }
Exemplo n.º 7
0
        public void TestAddDuplicateItem()
        {
            var newItem = new LAListItem()
            {
                Description = "Milk",
                ListID      = 1
            };

            var result = ListQueries.AddItemToList(newItem);

            Assert.AreEqual(false, result);
            Assert.AreEqual(4, ListQueries.GetList(1).LAListItems.Count);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        public void TestRemoveList()
        {
            LAList testList = new LAList()
            {
                Name = "List to Remove"
            };

            ListQueries.AddList(testList);

            var findList = ListQueries.GetList(testList.ID);

            Assert.IsNotNull(findList, "Test List not found.");
            Assert.AreEqual <string>("List to Remove", findList.Name);

            var result = ListQueries.RemoveList(findList.ID);

            Assert.AreEqual(true, result);
            Assert.IsNull(ListQueries.GetList(3), "List 3 not removed.");
        }
Exemplo n.º 11
0
        public void TestRemoveListItem()
        {
            LAList testList = ListQueries.GetList(1);

            Assert.IsNotNull(testList);

            Assert.IsTrue(ListQueries.AddItemToList(new LAListItem()
            {
                Description = "Bread", ListID = 1
            }));

            testList = ListQueries.GetList(1);
            Assert.IsNotNull(testList);
            Assert.AreEqual(5, testList.LAListItems.Count);

            var result = ListQueries.DeleteItemFromList(testList.LAListItems[4].ID);

            testList = ListQueries.GetList(1);
            Assert.IsNotNull(testList);

            Assert.AreEqual(1, result);
            Assert.AreEqual(4, testList.LAListItems.Count);
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
        public void TestGetListZeroListID()
        {
            var list = ListQueries.GetList(0);

            Assert.AreEqual(null, list);
        }
Exemplo n.º 14
0
        public void TestGetListBadListID()
        {
            var list = ListQueries.GetList(-99);

            Assert.AreEqual(null, list);
        }
Exemplo n.º 15
0
        public void TestGetNonExistantList()
        {
            var list = ListQueries.GetList(99);

            Assert.AreEqual(null, list);
        }