Beispiel #1
0
        public async Task ModifyRankAsync_ItemFound_SuccessfullyUpdatesRank()
        {
            // Arrange
            var user = new IdentityUser("user_1")
            {
                Id = Guid.NewGuid().ToString(),
            };

            _context.Users.Add(user);
            var item = new TodoItem(42, user.Id, "Fresh item", Importance.High)
            {
                Rank = 1,
            };

            _context.TodoItems.Add(item);
            int newRank = item.Rank + 5;
            await _context.SaveChangesAsync();

            // Act
            await _todoItemRepository.ModifyRankAsync(item.TodoItemId, newRank);

            // Assert
            TodoItem afterUpdate = await _context.TodoItems.SingleAsync(i => i.TodoItemId == item.TodoItemId);

            Assert.Equal(newRank, afterUpdate.Rank);
        }