示例#1
0
        public void GetExistingTodoItems()
        {
            var existingItem = TodoItemBuilder.WithDefaultValues();

            _todoContext.TodoItems.Add(existingItem);
            _todoContext.SaveChanges();
            var itemId = existingItem.Id;

            _output.WriteLine($"Todo name {existingItem.Title}");

            var todoItemFromRepo = _todoItemRepository.GetById(itemId);

            Assert.Equal(existingItem.Title, todoItemFromRepo.Title);
        }
示例#2
0
        public async Task GetById_Should_CallFindById()
        {
            // Arrange
            var guid = Guid.NewGuid();

            _repositoryMock.Setup(x => x.FindById(It.IsAny <Guid>(), true)).ReturnsAsync(new TodoItem());

            // Act
            await _repository.GetById(guid);

            // Assert
            _repositoryMock.Verify(x => x.FindById(guid, true), Times.Once());
            _repositoryMock.VerifyNoOtherCalls();
        }