Esempio n. 1
0
        public void InsertCategoryTest()
        {
            IDatabase database = new Database(TestUtils.ConnString);
            Assert.NotNull(database);

            var categoryDao = new CategoryDao(database);
            InsertDummyData(categoryDao);
            Assert.Equal(items.Count, categoryDao.Count());
        }
Esempio n. 2
0
        public void FindAllCategoriesTest()
        {
            IDatabase database = new Database(TestUtils.ConnString);
            Assert.NotNull(database);

            var categoryDao = new CategoryDao(database);
            InsertDummyData(categoryDao);
            Assert.Equal(items.Count, categoryDao.Count());

            IList<Category> dbCategories = categoryDao.FindAll();
            Assert.NotNull(dbCategories);
            Assert.Equal(items.Count, dbCategories.Count);

            foreach (var cat in dbCategories)
            {
                Assert.True(items.Contains(cat));
            }
        }
Esempio n. 3
0
        public void FindCategoryByIdTest()
        {
            IDatabase database = new Database(TestUtils.ConnString);
            Assert.NotNull(database);

            var categoryDao = new CategoryDao(database);
            InsertDummyData(categoryDao);
            Assert.Equal(items.Count, categoryDao.Count());

            Category myCateg = categoryDao.FindById(AKROBATIK_ID);
            Assert.NotNull(myCateg);
            Assert.Equal(AKROBATIK_LABEL, myCateg.Label);

            categoryDao.Delete(myCateg.Id);
            Assert.Equal(3, categoryDao.Count());
        }
Esempio n. 4
0
        public void DeleteCategoryTest()
        {
            IDatabase database = new Database(TestUtils.ConnString);
            Assert.NotNull(database);

            var categoryDao = new CategoryDao(database);
            InsertDummyData(categoryDao);
            Assert.Equal(items.Count, categoryDao.Count());

            foreach(var item in items)
            {
                categoryDao.Delete(item.Id);
            }
            Assert.Equal(0, categoryDao.Count());
        }
Esempio n. 5
0
        public void UpdateCategoryTest()
        {
            IDatabase database = new Database(TestUtils.ConnString);
            Assert.NotNull(database);

            CategoryDao categoryDao = new CategoryDao(database);
            InsertDummyData(categoryDao);
            Assert.Equal(items.Count, categoryDao.Count());


            categoryDao.Update(new Category(COMEDY_ID, CATEGORY_UPDATE_STRING));
            var myNewCateg = categoryDao.FindById(COMEDY_ID);
            Assert.NotNull(myNewCateg);
            Assert.True(!items.Contains(myNewCateg));
            Assert.Equal(CATEGORY_UPDATE_STRING, myNewCateg.Label);
        }