public async Task AddEntry_When_Duplicate_Entry_Throws_exception() { //arrange var repository = Substitute.For <IPhoneBookRepository>(); repository.GetById("Test").Returns(new PhoneBookEntry()); var phoneBookService = new PhoneBookService(repository); //act + assert await Assert.ThrowsExceptionAsync <ApplicationException>(() => phoneBookService.AddEntry(new PhoneBookEntry { Name = "Test", PhoneNumber = "123" })); }