public void AddContact_AddsContact_IfContactDoesNotExistsYet() { var repository = new PhoneBookRepository(_soundexFilter) { ConnectionString = _connectionString }; repository.SetOwnerGuid(_guid); var newContact = new Contact(); var contactId = repository.AddContact(newContact); var expected = newContact; var result = repository.GetContact(contactId); Assert.True(EqualContacts(expected, result)); }
public void UpdateContact_UpdatesContact_IfItExists() { var repository = new PhoneBookRepository(_soundexFilter) { ConnectionString = _connectionString }; repository.SetOwnerGuid(_guid); var newContact = new Contact(); repository.AddContact(newContact); var updatedContact = newContact; updatedContact.FirstName = "John"; updatedContact.LastName = "Doe"; repository.UpdateContact(updatedContact); var expected = updatedContact; var result = repository.GetContact(updatedContact.Id); Assert.True(EqualContacts(expected, result)); }
public void GetContact_ReturnsNull_IfIncorrectIdIsUsed() { var repository = new PhoneBookRepository(_soundexFilter) { ConnectionString = _connectionString }; repository.SetOwnerGuid(_guid); var result = repository.GetContact(9999); Assert.Null(result); }
public void RemoveContact_RemovesContact_IfContactExists() { var repository = new PhoneBookRepository(_soundexFilter) { ConnectionString = _connectionString }; repository.SetOwnerGuid(_guid); var newContact = new Contact(); var contactId = repository.AddContact(newContact); repository.RemoveContact(newContact); var result = repository.GetContact(contactId); Assert.Null(result); }
public void GetContact_ReturnsContact_IfCorrectIdIsUsed() { var repository = new PhoneBookRepository(_soundexFilter) { ConnectionString = _connectionString }; repository.SetOwnerGuid(_guid); var result = repository.GetContact(_contact.Id); var expected = _contact; Assert.True(EqualContacts(expected, result)); }