Example #1
0
        /// <summary>
        /// Each test will start by testing for an empty table, and each test
        /// will leave the database state as it found it.
        /// </summary>
        private void TruncatePersonTable()
        {
            // We have to work with what we have :)
            peopleProvider = new PeopleProvider();
            var people = peopleProvider.ListPeople();

            people.ToList().ForEach(p => peopleProvider.DeletePerson(p.ID));
        }
Example #2
0
        public void SQLite_CreatePerson_CheckCorrect()
        {
            TruncatePersonTable();

            // Check no one on the table
            var people = peopleProvider.ListPeople();

            Assert.AreEqual(0, people.Count());

            var person = GetNewPerson("Joe", "Smith", 40);

            peopleProvider.CreatePerson(person);

            people = peopleProvider.ListPeople();
            Assert.AreEqual(1, people.Count(), $"Expected 1 person, list contains {people.Count()}", null);

            if (people.Count() > 0)
            {
                var actualPerson = people.ToArray()[0];
                Assert.AreEqual(GetPersonString(person), GetPersonString(actualPerson), $"Expected person {person.FirstName} {person.LastName} {person.Age} but got {actualPerson.FirstName} {actualPerson.LastName} {actualPerson.Age}", null);
            }

            TruncatePersonTable();
        }