Exemplo n.º 1
0
        public void DatabaseFindByUsernameOrIdThrowsIOPWhenNotFound()
        {
            var db = new App.Database(this.PersonObjects);

            Assert.That(() => db.FindByUsername("Penka"), Throws.InvalidOperationException, "The database does not throw exceptions when the username is not found.");

            Assert.That(() => db.FindById(500), Throws.InvalidOperationException, "The database does not throw exceptions when the Id is not found");
        }
Exemplo n.º 2
0
        public void DatabaseFindByUsernameIsCaseSensitive()
        {
            var peopleObjects = this.PersonObjects;

            var db = new App.Database(peopleObjects);

            var firstUserName = peopleObjects.First().Name.ToLower();

            Assert.That(() => db.FindByUsername(firstUserName), Throws.InvalidOperationException, "The database is case insensitive");
        }
Exemplo n.º 3
0
        public void DatabaseFindByUsernameAndIdWorks()
        {
            var peopleObjects = this.PersonObjects;

            var firstPerson = peopleObjects[0];

            var db = new App.Database(peopleObjects);

            IPerson personByUsername;

            try
            {
                personByUsername = db.FindByUsername(firstPerson.Name);
                Assert.That(personByUsername, Is.EqualTo(firstPerson));
            }
            catch (Exception) { throw new AssertionException("The Database.FindByUsername() does not work properly"); }

            try
            {
                personByUsername = db.FindById(firstPerson.Id);
                Assert.That(personByUsername, Is.EqualTo(firstPerson));
            }
            catch (Exception) { throw new AssertionException("The Database.FindById() does not work properly"); }
        }
Exemplo n.º 4
0
        public void DatabaseFindByUsernameThrowsArgExWhenNull()
        {
            var db = new App.Database();

            Assert.That(() => db.FindByUsername(null), Throws.ArgumentNullException, "The Database.FindByUsername accepts null arguments");
        }