Esempio n. 1
0
        public void Read_Return_OkResult()
        {
            //Arrange
            var controller = new TodosController(_todoItemService, null, null);

            //Act
            var data = controller.Read();

            //Assert
            Assert.IsType <OkObjectResult>(data);
        }
Esempio n. 2
0
        public void ReadById_Return_BadRequestResult()
        {
            //Arrange
            var controller = new TodosController(_todoItemService, null, null);
            var id         = Guid.Empty;

            //Act
            var data = controller.Read(id);

            //Assert
            Assert.IsType <BadRequestObjectResult>(data);
        }
Esempio n. 3
0
        public void ReadById_Return_OkResult()
        {
            //Arrange
            var controller = new TodosController(_todoItemService, null, null);
            var id         = TestHelper.TodoItems.ElementAt(0).Id;

            //Act
            var data = controller.Read(id);

            //Assert
            Assert.IsType <OkObjectResult>(data);
        }
Esempio n. 4
0
        public void Update_ValidData_OkResult()
        {
            //Arrange
            var controller = new TodosController(_todoItemService, null, null);
            var id         = TestHelper.TodoItems.ElementAt(1).Id;

            //Act
            var existingItem = controller.Read(id);
            var okResult     = (OkObjectResult)existingItem;
            var item         = (TodoItem)okResult.Value;

            item.Name = "Updated Todo";

            var updatedData = controller.Update(id, item);

            //Assert
            Assert.IsType <OkObjectResult>(updatedData);
        }
Esempio n. 5
0
        public void Read_CountTodos_MatchResult()
        {
            //Arrange
            var controller = new TodosController(_todoItemService, null, null);

            //Act
            var data = controller.Read();

            //Assert
            Assert.IsType <OkObjectResult>(data);

            var okResult       = (OkObjectResult)data;
            var queryableItems = (IQueryable <TodoItem>)okResult.Value;
            var itemsCount     = queryableItems.AsEnumerable().Count();

            //Assert
            Assert.Equal(4, itemsCount);
        }
Esempio n. 6
0
        public void ReadById_Return_MatchResult()
        {
            //Arrange
            var controller = new TodosController(_todoItemService, null, null);
            var id         = TestHelper.TodoItems.ElementAt(0).Id;

            //Act
            var data = controller.Read(id);

            //Assert
            Assert.IsType <OkObjectResult>(data);

            var okResult = (OkObjectResult)data;
            var item     = (TodoItem)okResult.Value;

            //Assert
            Assert.Equal("Todo 1", item.Name);
            Assert.Equal(Priority.IMPORTANT, item.Priority);
        }