public async Task ItGetsSpeakerPresentations() { // Arrange // Act await Controller.GetPresentations(_id); // Assert SpeakerPresentationService.Verify(x => x.GetAll(_id), Times.Once()); }
public SpeakerPresentationServiceTestBase() { Repository = new Mock <ISpeakerMeetRepository>(); Repository.Setup(x => x.List(It.IsAny <SpeakerPresentationSpecification>())) .ReturnsAsync(new List <SpeakerPresentation>()); Service = new SpeakerPresentationService(Repository.Object); }
public async Task GivenException_ThenBadRequestResult() { // Arrange SpeakerPresentationService.Setup(x => x.GetAll(_id)).Throws(new Exception()); // Act var result = await Controller.GetPresentations(_id); // Assert Assert.IsAssignableFrom <BadRequestObjectResult>(result.Result); }
public async Task GivenException_ThenItLogsError() { // Arrange var ex = new Exception(); SpeakerPresentationService.Setup(x => x.GetAll(_id)).Throws(ex); // Act await Controller.GetPresentations(_id); // Assert Logger.Verify(x => x.LogError(ex, ex.Message), Times.Once()); }