public void Edit_ExistingEntryInPhoneBookBelongingToDifferentUser_ResponseStatusSetTo1() { FakePhoneBookRepository repository = new FakePhoneBookRepository(); PhoneBookService service = new PhoneBookService(repository) { GetUserId = () => 1 }; repository.phoneBook.Add(new PhoneBook { UserId = service.GetUserId() + 1, Id = 1 }); BaseResponse response = service.Edit(new EditPhoneBookRequest { Id = 1 }); Assert.AreEqual(1, response.Status); }
public void Edit_ExistingEntry_UpdatedInPhoneBook() { FakePhoneBookRepository repository = new FakePhoneBookRepository(); PhoneBookService service = new PhoneBookService(repository) { GetUserId = () => 1 }; repository.phoneBook.Add(new PhoneBook { Id = 1, UserId = service.GetUserId() }); BaseResponse response = service.Edit(new EditPhoneBookRequest { Id = 1, FirstName = "First", LastName="Last", Number="123456", PhoneTypeId=2 }); Assert.AreEqual(1, repository.phoneBook.First().Id); Assert.AreEqual("First", repository.phoneBook.First().FirstName); Assert.AreEqual("123456", repository.phoneBook.First().Number); Assert.AreEqual(2, repository.phoneBook.First().PhoneTypeId); }
public void Edit_NonExistingEntryInPhoneBook_ResponseStatusSetTo2() { FakePhoneBookRepository repository = new FakePhoneBookRepository(); PhoneBookService service = new PhoneBookService(repository) { GetUserId = () => 1 }; BaseResponse response = service.Edit(new EditPhoneBookRequest { Id = 1 }); Assert.AreEqual(2, response.Status); }