Beispiel #1
0
        public void CreateItem_ShouldReturnNullIfUserIsNotFound()
        {
            // Arrange
            var dbContext  = SetupDatabase(nameof(CreateItem_ShouldReturnNullIfUserIsNotFound));
            var repository = new TodoItemRepository(dbContext);

            // Act
            var result = repository.CreateItem(3, new CreateTodoItemDto());

            // Assert
            Assert.Null(result);
        }
Beispiel #2
0
        public void CreateItem_ShouldReturnNullIfListIsNotFound()
        {
            // Arrange
            var dbContext  = SetupDatabase(nameof(CreateItem_ShouldReturnNullIfListIsNotFound));
            var repository = new TodoItemRepository(dbContext);
            var input      = new CreateTodoItemDto
            {
                TodoListId  = 10,
                Description = "Cheese"
            };

            // Act
            var result = repository.CreateItem(1, input);

            // Assert
            Assert.Null(result);
        }
Beispiel #3
0
        public void CreateItem_ShouldCreateItem()
        {
            // Arrange
            var dbContext  = SetupDatabase(nameof(CreateItem_ShouldCreateItem));
            var repository = new TodoItemRepository(dbContext);
            var input      = new CreateTodoItemDto
            {
                TodoListId  = 1,
                Description = "Cheese"
            };

            // Act
            var result = repository.CreateItem(1, input);

            // Assert
            Assert.NotNull(result);
            var item = dbContext.TodoItems.FirstOrDefault(t => t.Description == "Cheese");

            Assert.NotNull(item);
        }