public async Task Post_ReceivesUnknownId_ReturnsNotFound() { // Arrange _contactRepository.GetContactById(1).Returns(NullContact.GetInstance()); var controller = CreateController(); // Act var actionResult = await controller.Details(new ContactUpdateViewModel { Id = 1 }); // Assert actionResult.Should().BeOfType <NotFoundResult>(); }
public void Get_CannotFindContact_ReturnsNotFound() { // Arrange _contactRepository.GetContactById(1).Returns(NullContact.GetInstance()); var controller = CreateController(); // Act var actionResult = controller.Details(1); // Assert actionResult.Should().BeOfType <NotFoundResult>(); }
public async Task UnknownId_ReturnsNotFound() { // Arrange _contactRepository.GetContactById(1).Returns(NullContact.GetInstance()); var controller = CreateController(); // Act var actionResult = await controller.Favorite(1); // Assert actionResult.Should().BeOfType <NotFoundResult>(); }
public async Task Post_ContactCouldNotBeCreated_ReturnsBadRequest() { // Arrange _contactRepository.AddContact(Arg.Any <Contact>()).Returns(NullContact.GetInstance()); var controller = CreateController(); // Act var actionResult = await controller.Add(new Contact()); // Assert actionResult.Should().BeOfType <BadRequestResult>(); }
public Contact GetContactById(int id) { var contact = _context.Contacts .Include(c => c.EmailAddresses) .Include(c => c.TelephoneNumbers) .Include(c => c.Relationships) .Include(c => c.StatusUpdates) .Include(c => c.Activities) .Include(c => c.Gifts) .Include(c => c.Reminders) .FirstOrDefault(c => c.Id == id); return(contact ?? NullContact.GetInstance()); }