예제 #1
0
        public void TestAddWithExistingUsername()
        {
            var username = "******";

            var db = new PeopleDatabase(new Person(11, username));

            Assert.That(() => db.Add(new Person(1, username)), Throws.InvalidOperationException);
        }
예제 #2
0
        public void FindByIdWhenIdNotPresent()
        {
            var db = new PeopleDatabase();

            db.Add(new Person(11, "Pesho"));

            Assert.That(() => db.FindById(1), Throws.InvalidOperationException);
        }
예제 #3
0
        public void TestAddWithExistingId()
        {
            var id = 12;

            var db = new PeopleDatabase(new Person(id, "Az"));

            Assert.That(() => db.Add(new Person(id, "Ti")), Throws.InvalidOperationException);
        }
예제 #4
0
        public void TestValidFindById()
        {
            var person = new Person(12, "Pesho");
            var db     = new PeopleDatabase();

            db.Add(person);

            Assert.That(person, Is.EqualTo(db.FindById(12)));
        }
예제 #5
0
        public void FindByIdWhenValid()
        {
            var db = new PeopleDatabase();

            var person = new Person(11, "Pesho");

            db.Add(person);

            Assert.That(db.FindById(11), Is.EqualTo(person));
        }
예제 #6
0
        public void TestValidFindByUsername()
        {
            string username = "******";
            var    db       = new PeopleDatabase();

            var person = new Person(12, username);

            db.Add(person);
            Assert.That(person, Is.EqualTo(db.FindByUsername(username)));
        }
예제 #7
0
    public void PeopleShouldHaveUniqueUsernames()
    {
        var person       = new Person(1, "Pesho");
        var secondPerson = new Person(2, "Maria");

        var pDb = new PeopleDatabase(person, secondPerson);

        Assert
        .That(() => pDb.Add(new Person(3, "Pesho")),
              Throws.InvalidOperationException);
    }
예제 #8
0
        private static PeopleDatabase GetDatabase()
        {
            var database = new PeopleDatabase();

            for (var i = database.Count; i < 10; i++)
            {
                database.Add(Person.GenerateRandomPerson());
            }

            return(database);
        }
        public void PeopleDatabaseRemoveMethodShouldRemoveLastPersonCorrectly()
        {
            //Arrange
            var people = new List <Person>
            {
                new Person(15, "Ivan"),
                new Person(33, "Ginka"),
            };

            people.ForEach(p => this.database.Add(p));

            database.Add(new Person(11, "Sasho"));

            var collection = this.GetInncerDatabaseCollection();

            //Act
            this.database.Remove();

            //Assert
            CollectionAssert.AreEquivalent(people, collection);
        }