Exemplo n.º 1
0
        public void RemoveMoreThanOneElement()
        {
            dataAccess = new ItemsDataAccess(true);
            dataAccess.SaveItem(new Item()
            {
                Strength = 1, Dexterity = 2, Speed = 3, Defense = 4
            });
            dataAccess.SaveItem(new Item()
            {
                Strength = 2, Dexterity = 3, Speed = 4, Defense = 5
            });
            dataAccess.SaveItem(new Item()
            {
                Strength = 3, Dexterity = 4, Speed = 5, Defense = 6
            });

            dataAccess.DeleteItem(new Item()
            {
                Strength = 2, Dexterity = 3, Speed = 4, Defense = 5
            });
            dataAccess.DeleteItem(new Item()
            {
                Strength = 3, Dexterity = 4, Speed = 5, Defense = 6
            });
            List <Item> items = dataAccess.GetAllItem() as List <Item>;

            Assert.AreEqual(4, items[0].Defense);
        }
Exemplo n.º 2
0
        public void ItemIsUpdatedWhenThereAreMoreThanOneItem()
        {
            Item testItem = new Item()
            {
                Strength = 1, Health = 2, Speed = 3, Defense = 4
            };

            dataAccess = new ItemsDataAccess(true);
            dataAccess.SaveItem(testItem);
            dataAccess.SaveItem(new Item()
            {
                Strength = 2, Health = 3, Speed = 4, Defense = 5
            });
            dataAccess.SaveItem(new Item()
            {
                Strength = 3, Health = 4, Speed = 5, Defense = 6
            });

            testUpdateItemPage = new UpdateItemPage(testItem, dataAccess);
            testItem.Health    = 10;
            testItem.ItemNum   = 1;

            testUpdateItemPage.TestUpdateItem_Clicked();
            List <Item> temp = dataAccess.GetAllItem() as List <Item>;

            Assert.AreEqual(10, temp[0].Health);
        }
Exemplo n.º 3
0
        public void GetOneElement()
        {
            dataAccess = new ItemsDataAccess(true);
            dataAccess.SaveItem(new Item()
            {
                Strength = 1, Dexterity = 2, Speed = 3, Defense = 4
            });
            dataAccess.SaveItem(new Item()
            {
                Strength = 2, Dexterity = 3, Speed = 4, Defense = 5
            });
            dataAccess.SaveItem(new Item()
            {
                Strength = 3, Dexterity = 4, Speed = 5, Defense = 6
            });
            Item items = dataAccess.GetItem(3);

            Assert.AreEqual(6, items.Defense);
        }
Exemplo n.º 4
0
        public void GetWhenThereMoreThanOneElement()
        {
            dataAccess = new ItemsDataAccess(true);
            dataAccess.SaveItem(new Item()
            {
                Strength = 1, Health = 2, Speed = 3, Defense = 4
            });
            dataAccess.SaveItem(new Item()
            {
                Strength = 2, Health = 3, Speed = 4, Defense = 5
            });
            dataAccess.SaveItem(new Item()
            {
                Strength = 3, Health = 4, Speed = 5, Defense = 6
            });
            List <Item> items = dataAccess.GetAllItem() as List <Item>;

            Assert.AreEqual(6, items[2].Defense);
        }
Exemplo n.º 5
0
        public void GetWhenThereIsOneElement()
        {
            dataAccess = new ItemsDataAccess(true);
            dataAccess.SaveItem(new Item()
            {
                Strength = 1, Dexterity = 2, Speed = 3, Defense = 4
            });
            List <Item> items = dataAccess.GetAllItem() as List <Item>;

            Assert.AreEqual(1, items.Count);
        }
Exemplo n.º 6
0
        public void ListViewModelGetAllWhenThereAreMoreOneItem()
        {
            dataAccess = new ItemsDataAccess(true);
            dataAccess.SaveItem(new Item()
            {
                Strength = 1, Health = 2, Speed = 3, Defense = 4
            });
            dataAccess.SaveItem(new Item()
            {
                Strength = 2, Health = 3, Speed = 4, Defense = 5
            });
            dataAccess.SaveItem(new Item()
            {
                Strength = 3, Health = 4, Speed = 5, Defense = 6
            });

            testViewModel = new ListViewModel("List View", dataAccess);
            var task = testViewModel.ExecuteLoadItemsCommand();

            task.Wait();
            Assert.AreEqual(6, testViewModel.Items[2].Defense);
        }
Exemplo n.º 7
0
        public void DeleteWhenThereAreMoreThanOneItem()
        {
            Item testItem = new Item()
            {
                Strength = 3, Dexterity = 4, Speed = 10, Defense = 6
            };

            dataAccess = new ItemsDataAccess(true);
            dataAccess.SaveItem(testItem);
            dataAccess.SaveItem(new Item()
            {
                Strength = 2, Dexterity = 3, Speed = 4, Defense = 5
            });

            testItemDetailPage = new ItemDetailPage(testItem, dataAccess);

            testItem.ItemNum = 1;

            testItemDetailPage.TestDeleteItem_Clicked();

            List <Item> temp = dataAccess.GetAllItem() as List <Item>;

            Assert.AreEqual(3, temp[0].Dexterity);
        }
Exemplo n.º 8
0
        public void AddItemWhenThereAreItem()
        {
            dataAccess = new ItemsDataAccess(true);
            dataAccess.SaveItem(new Item()
            {
                Strength = 3, Dexterity = 4, Speed = 10, Defense = 6
            });
            testAddItemPage = new AddItemPage(dataAccess);

            testAddItemPage.Item.Speed = 5;

            testAddItemPage.TestSave_Clicked();

            List <Item> temp = dataAccess.GetAllItem() as List <Item>;

            Assert.AreEqual(5, temp[1].Speed);
        }
Exemplo n.º 9
0
        public void ItemIsUpdatedWhenThereIsOnlyOneItem()
        {
            Item testItem = new Item()
            {
                Strength = 1, Dexterity = 2, Speed = 3, Defense = 4
            };

            dataAccess = new ItemsDataAccess(true);
            dataAccess.SaveItem(testItem);
            testUpdateItemPage = new UpdateItemPage(testItem, dataAccess);
            testItem.Dexterity = 10;
            testItem.ItemNum   = 1;
            testUpdateItemPage.TestUpdateItem_Clicked();
            List <Item> temp = dataAccess.GetAllItem() as List <Item>;

            Assert.AreEqual(10, temp[0].Dexterity);
        }
Exemplo n.º 10
0
        public void DeleteWhenThereIsOneItem()
        {
            Item testItem = new Item()
            {
                Strength = 3, Health = 4, Speed = 10, Defense = 6
            };

            dataAccess = new ItemsDataAccess(true);
            dataAccess.SaveItem(testItem);

            testItem.ItemNum = 1;

            testItemDetailPage = new ItemDetailPage(testItem, dataAccess);

            testItemDetailPage.TestDeleteItem_Clicked();

            List <Item> temp = dataAccess.GetAllItem() as List <Item>;

            Assert.AreEqual(0, temp.Count);
        }