Ejemplo n.º 1
0
        public async Task FindByIdAsyncShouldReturnCorrectArticle()
        {
            // Arrange
            var db = this.GetDatabase();

            var firstArticle = new Article {
                Id = 14, Title = "First article", Content = new String('p', 255)
            };
            var secondArticle = new Article {
                Id = 25, Title = "Second article", Content = new String('a', 255)
            };

            db.AddRange(firstArticle, secondArticle);
            await db.SaveChangesAsync();

            var articleService = new ArticleService(db);

            // Act
            var result = await articleService.ByIdAsync(secondArticle.Id);

            // Assert
            result
            .Id
            .Should()
            .Be(25);
        }