public void GetAll_ItemsExist_ReturnsItems() { // Arrange A.CallTo(() => _repository.GetAllItems()).Returns(new[] { _todoItem }); // Act var result = _todoService.GetAll(); // Assert result.IsSuccess.Should().BeTrue(); result.Items.Single().Should().BeEquivalentTo(_todoItem); }
public void GetAll_ExistingTodos() { var mockDb = new Mock <IDatabase>(); var todoList = new List <Todo> { EXISTING_TODO, EXISTING_TODO2 }; mockDb.Setup(db => db.GetAll()).Returns(todoList); var service = new TodoService(mockDb.Object); service.GetAll().Should().HaveSameCount(todoList); service.GetAll().Should().Contain(todoList); }
public void CanGetAllTodo() { // setup var options = new DbContextOptionsBuilder <TodoContext>() .UseInMemoryDatabase(databaseName: "TodoDb1") .Options; using (var context = new TodoContext(options)) { context.Todos.Add(new Todo { Title = "Test Todo 1", Description = "Description Todo 1" }); context.Todos.Add(new Todo { Title = "Test Todo 2", Description = "Description Todo 2" }); context.Todos.Add(new Todo { Title = "Test Todo 3", Description = "Description Todo 3" }); context.Todos.Add(new Todo { Title = "Test Todo 4", Description = "Description Todo 4" }); context.Todos.Add(new Todo { Title = "Test Todo 5", Description = "Description Todo 5" }); context.SaveChanges(); } // operation var todoService = new TodoService(new TodoContext(options)); var result = todoService.GetAll(); // assert Assert.IsTrue(result.Any()); }
public IActionResult List() { var notificationService = new NotificationService(); var service = new TodoService(context, notificationService); return(View(service.GetAll())); }
// GET: api/TodoItems public async Task <IEnumerable <TodoItemModel> > GetTodoItems() { //var result = service.GetAll_(); IList <BllTodoItem> result = await service.GetAll(); return(result.Select(i => i.ToViewModel())); }
public async Task <IActionResult> GetAllTodos( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req, ILogger log) { var result = await _todoService.GetAll(); return(new OkObjectResult(result)); }
public ActionResult Index() { TodoIndexViewModel vm = new TodoIndexViewModel() { Tasks = service.GetAll() }; return(View(vm)); }
public void GetAll_NoTodos_ReturnsEmptyList() { var mockDb = new Mock <IDatabase>(); mockDb.Setup(db => db.GetAll()).Returns(new List <Todo>()); var service = new TodoService(mockDb.Object); service.GetAll().Should().BeEmpty(); }
public ApiResponse Get() { var response = new ApiResponse(); try { response.Data = _todoService.GetAll(); } catch (Exception ex) { response.HasError = true; response.ErrorMessage = ex.Message; } response.ResponseDate = DateTime.Now; return(response); }
public async void CanGetAllTodosByUserId() { using (var context = CreateContext()) { var todoService = new TodoService(context); var user = new User() { Email = "*****@*****.**", PasswordHash = "!@#QWE" }; await todoService.Create("Test", "Test", user); await todoService.Create("Test1", "Test1", user); var todos = todoService.GetAll(user.Id); Assert.Equal(2, todos.Count); } }
// GET: api/Items public async Task <IEnumerable <TodoItemModel> > Get() { IEnumerable <TodoItemModel> result = await service.GetAll(); return(result); }
// GET: /Todo/Index public IActionResult Index() { var items = todoService.GetAll(); return(View(items)); }
public IActionResult _list() { var model = service.GetAll(); return(PartialView(model)); }
public IEnumerable <TodoItem> GetAll() { return(_todoService.GetAll()); }
public void GetAllReturnsFullSet() { subject = new TodoService(mockContext.Object, logger); Assert.Equal(items, subject.GetAll()); }
public async Task <IEnumerable <Todo> > GetTodos() { // Note: If you don't need to return to the calling thread, use .ConfigureAwait(false) return(await _todoService.GetAll().ConfigureAwait(false)); }
public IEnumerable <Todo> Get() { return(todoService.GetAll()); }
public IActionResult List() { var service = new TodoService(context); return(View(service.GetAll())); }