public void ShouldReturnExactlyTwoArticles()
        {
            // Arrange
            var db             = Tests.GetDatabase();
            var articleService = new ArticleService(db);

            var articleData = this.GetArticleData();

            db.AddRange(articleData);
            db.SaveChanges();

            // Act
            var result = articleService.All();

            // Assert
            result
            .Should().AllBeOfType <ArticlesListingsServiceModel>()
            .And.HaveCount(2);
        }
Exemplo n.º 2
0
        public async Task AllShouldReturnCorrectNumberOfArticles()
        {
            // arrange
            const string database = "asdfasdfasdfasdfasdfasdfasdf";

            await using var context = new FakeDbContext(database);
            await context.SeedArticles(3);

            // act
            var mapper = new Mapper(new MapperConfiguration(conf =>
            {
                conf.AddProfile <ServiceMappingProfile>();
            }));

            await using var context2 = new FakeDbContext(database);
            var articleService = new ArticleService(context2, mapper, null);

            var articles = await articleService.All();

            Assert.Equal(3, articles.ToArray().Length);
        }
 public void FindArticle(Article article)
 {
     View.Model = ArticleService.All(article);
 }