Esempio n. 1
0
        public bool DeleteUser(int id)
        {
            bool isDeleteable = (cacheDao.GetByOwner(id).Count == 0);

            isDeleteable = isDeleteable && (logEntryDao.GetLogentriesForUser(id).Count == 0);
            isDeleteable = isDeleteable && (ratingDao.GetRatingsForUser(id).Count == 0);

            if (isDeleteable)
            {
                return(userDao.DeleteById(id));
            }
            throw new Exception("Error: Unable to delete selected user. User owns caches and/or log entries and/or rating entries.");
        }
Esempio n. 2
0
        public void GetCachesByOwnerTest()
        {
            const int     ownerId  = 49;
            IList <Cache> expected = new List <Cache>();

            expected.Add(new Cache {
                Id = 57
            });
            expected.Add(new Cache {
                Id = 75
            });
            expected.Add(new Cache {
                Id = 216
            });
            expected.Add(new Cache {
                Id = 238
            });
            expected.Add(new Cache {
                Id = 327
            });
            expected.Add(new Cache {
                Id = 429
            });
            expected.Add(new Cache {
                Id = 444
            });
            expected.Add(new Cache {
                Id = 459
            });

            IList <Cache> actual = target.GetByOwner(ownerId);

            Assert.AreEqual(expected.Count, actual.Count);

            foreach (Cache cache in expected)
            {
                Assert.IsTrue(actual.Contains(cache));
            }
        }