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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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());
        }
Beispiel #4
0
        public IActionResult List()
        {
            var notificationService = new NotificationService();

            var service = new TodoService(context, notificationService);

            return(View(service.GetAll()));
        }
Beispiel #5
0
        // 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()));
        }
Beispiel #6
0
        public async Task <IActionResult> GetAllTodos(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req,
            ILogger log)
        {
            var result = await _todoService.GetAll();

            return(new OkObjectResult(result));
        }
Beispiel #7
0
        public ActionResult Index()
        {
            TodoIndexViewModel vm = new TodoIndexViewModel()
            {
                Tasks = service.GetAll()
            };

            return(View(vm));
        }
Beispiel #8
0
        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);
        }
Beispiel #10
0
        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);
            }
        }
Beispiel #11
0
        // GET: api/Items
        public async Task <IEnumerable <TodoItemModel> > Get()
        {
            IEnumerable <TodoItemModel> result = await service.GetAll();

            return(result);
        }
Beispiel #12
0
        // 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());
 }
Beispiel #16
0
 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));
 }
Beispiel #17
0
 public IEnumerable <Todo> Get()
 {
     return(todoService.GetAll());
 }
Beispiel #18
0
        public IActionResult List()
        {
            var service = new TodoService(context);

            return(View(service.GetAll()));
        }