public async Task Get_all_tasks() { // arrange await PrepareDatabase(); var service = new TodoService(); var controller = new TodoController(service); // act var result = await controller.GetAll(); // assert Assert.NotEmpty(result); Assert.Equal(2, result.Count); Assert.Equal(Todos, result); }
public async Task GetByQueryAsync_UsingNullAsQuery_MustThrowException() { var mockTodoDbContext = new DbContextMock <TodoDbContext>(DummyOptions); var mockLogger = new Mock <ILogger <TodoService> >(); var todoService = new TodoService(mockTodoDbContext.Object, mockLogger.Object); TodoItemQuery todoItemQuery = null; try { // ReSharper disable once ExpressionIsAlwaysNull await todoService.GetByQueryAsync(todoItemQuery).ConfigureAwait(false); Assert.Fail($"Expected to not be able to call method {nameof(todoService.GetByQueryAsync)} using null as argument"); } catch (Exception expectedException) { expectedException.Should() .NotBeNull() .And.BeAssignableTo <ArgumentNullException>() .Subject.As <ArgumentNullException>() .ParamName.Should().Be("instance"); } }