public async Task Should_ReturnOk_IfContactsListIsEmpty() { ContactsRepositoryMock .Setup(r => r.GetAllAsync()) .ReturnsAsync(new List <Contact>()); var response = await ControllerMock.GetAll(); Assert.IsType <OkObjectResult>(response); }
public async Task Should_ReturnOk() { ContactsRepositoryMock .Setup(cr => cr.GetAsync(It.IsAny <ObjectId>())) .ReturnsAsync(new Contact()); var response = await ControllerMock.Get("5d2b5b105c20853204e52c8a"); Assert.IsType <OkObjectResult>(response); }
public async Task Should_ReturnNotFound_IfContactNotExists() { ContactsRepositoryMock .Setup(cr => cr.GetAsync(It.IsAny <ObjectId>())) .ReturnsAsync(() => null); var response = await ControllerMock.Get("5d2b5b105c20853204e52c8a"); Assert.IsType <NotFoundResult>(response); }
public async Task Should_ReturnOk() { MapperMock .Setup(m => m.Map <Contact>(It.IsAny <CreateContactModel>())) .Returns(new Contact()); ContactsRepositoryMock .Setup(r => r.CreateAsync(It.IsAny <Contact>())) .Returns(Task.CompletedTask); var response = await ControllerMock.Post(It.IsAny <CreateContactModel>()); Assert.IsType <OkResult>(response); }