Beispiel #1
0
        public void InsertRestrictionTest()
        {
            if (database == null)
            {
                database = new Database(TestUtils.ConnString);
            }
            Assert.NotNull(database);

            var restrictionDao = new RestrictionDao(database);
            InsertDummyData(restrictionDao);
            Assert.Equal(items.Count, restrictionDao.Count());
        }
Beispiel #2
0
        public void FindAllRestrictionsTest()
        {
            if (database == null)
            {
                database = new Database(TestUtils.ConnString);
            }
            Assert.NotNull(database);

            var restrictionDao = new RestrictionDao(database);
            InsertDummyData(restrictionDao);
            Assert.Equal(items.Count, restrictionDao.Count());

            IList<Restriction> dbRestrictios = restrictionDao.FindAll();
            Assert.NotNull(dbRestrictios);
            Assert.Equal(items.Count, dbRestrictios.Count);

            foreach (var restriction in dbRestrictios)
            {
                Assert.True(items.Contains(restriction));
            }
        }
Beispiel #3
0
        public void UpdateRestrictionTest()
        {
            if (database == null)
            {
                database = new Database(TestUtils.ConnString);
            }
            Assert.NotNull(database);

            var restrictionDao = new RestrictionDao(database);
            InsertDummyData(restrictionDao);
            Assert.Equal(items.Count, restrictionDao.Count());

            var currRestriction = items[0];
            currRestriction.Start = ALTER_START;

            restrictionDao.Update(currRestriction);
            var myNewRestriction = restrictionDao.FindById(currRestriction.Id);
            Assert.NotNull(myNewRestriction);
            Assert.Equal(ALTER_START, myNewRestriction.Start);
        }
Beispiel #4
0
        public void DeleteRestrictionTest()
        {
            if (database == null)
            {
                database = new Database(TestUtils.ConnString);
            }
            Assert.NotNull(database);

            var restrictionDao = new RestrictionDao(database);
            InsertDummyData(restrictionDao);
            Assert.Equal(items.Count, restrictionDao.Count());

            foreach (var item in items)
            {
                restrictionDao.Delete(item.Id);
            }
            Assert.Equal(0, restrictionDao.Count());
        }
Beispiel #5
0
        public void FindRestrictionByIdTest()
        {
            if (database == null)
            {
                database = new Database(TestUtils.ConnString);
            }
            Assert.NotNull(database);

            var restrictionDao = new RestrictionDao(database);
            InsertDummyData(restrictionDao);
            Assert.Equal(items.Count, restrictionDao.Count());

            var currRestriction = items[0];

            var myRestriction = restrictionDao.FindById(currRestriction.Id);
            Assert.NotNull(myRestriction);
            Assert.Equal(currRestriction, myRestriction);

            restrictionDao.Delete(myRestriction.Id);
            Assert.Equal(items.Count - 1, restrictionDao.Count());
        }