public void TestAddWithExistingUsername() { var username = "******"; var db = new PeopleDatabase(new Person(11, username)); Assert.That(() => db.Add(new Person(1, username)), Throws.InvalidOperationException); }
public void FindByIdWhenIdNotPresent() { var db = new PeopleDatabase(); db.Add(new Person(11, "Pesho")); Assert.That(() => db.FindById(1), Throws.InvalidOperationException); }
public void TestAddWithExistingId() { var id = 12; var db = new PeopleDatabase(new Person(id, "Az")); Assert.That(() => db.Add(new Person(id, "Ti")), Throws.InvalidOperationException); }
public void TestValidFindById() { var person = new Person(12, "Pesho"); var db = new PeopleDatabase(); db.Add(person); Assert.That(person, Is.EqualTo(db.FindById(12))); }
public void FindByIdWhenValid() { var db = new PeopleDatabase(); var person = new Person(11, "Pesho"); db.Add(person); Assert.That(db.FindById(11), Is.EqualTo(person)); }
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))); }
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); }
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); }