コード例 #1
0
        public async Task ReturnEmptyList()
        {
            // Arrange
            var authorDbSetMock = Builder <Author> .CreateListOfSize(3).Build().ToAsyncDbSetMock();

            _authorRepositoryMock.Setup(m => m.Query()).Returns(authorDbSetMock.Object);

            // Act
            var result = await _authorController.Search("Invalid");

            // Assert
            Assert.NotNull(result);

            var objectResult = result as OkObjectResult;

            Assert.NotNull(objectResult);

            var content = objectResult.Value as AuthorListModel;

            Assert.NotNull(content);

            Assert.Equal(0, content.Authors.Count());
        }