예제 #1
0
        public void GetCountByAuthorIdDeletedFakeIdTest()
        {
            var repository = ArticleRepository.Create();
            var article    = this.CreateArticle(repository, SeedArticle.Create());
            var service    = this.GetArticlesService(repository);
            var result     = service.GetCountByAuthorIdDeleted("FAKE");

            Assert.Equal(0, result);
        }
예제 #2
0
        public void GetArticleById()
        {
            var repository = ArticleRepository.Create();
            var article    = this.CreateArticle(repository, SeedArticle.Create());
            var service    = this.GetArticlesService(repository);
            var result     = service.GetArticleById <ArticleDumyModel>(article.Id).GetAwaiter().GetResult();

            Assert.Equal(article.Title, result.Title);
        }
예제 #3
0
        public void GetCountByAuthorRealIdTest()
        {
            var repository = ArticleRepository.Create();
            var article    = this.CreateArticle(repository, SeedArticle.Create());
            var service    = this.GetArticlesService(repository);
            var result     = service.GetCountByAuthorId("ads");

            Assert.Equal(1, result);
        }
예제 #4
0
        public void GetCountOfLocalArticlesNoResultTest()
        {
            var repository = ArticleRepository.Create();
            var article    = this.CreateArticle(repository, SeedArticle.Create());
            var service    = this.GetArticlesService(repository);
            var result     = service.GetCountOfLocalArticles();

            Assert.Equal(0, result);
        }
예제 #5
0
        public void ArticleExistTrueTest()
        {
            var repository = ArticleRepository.Create();
            var article    = this.CreateArticle(repository, SeedArticle.Create());
            var service    = this.GetArticlesService(repository);
            var result     = service.ArticleExist(article.Id);

            Assert.True(result);
        }
예제 #6
0
        public void LastesArticleCreationDateTest()
        {
            var repository    = ArticleRepository.Create();
            var article       = this.CreateArticle(repository, SeedArticle.Create());
            var secondArticle = this.CreateArticle(repository, SeedArticle.CreateSecondArticle());
            var service       = this.GetArticlesService(repository);
            var result        = service.LastesArticleCreationDate();

            Assert.Equal(secondArticle.CreatedOn, result);
        }
예제 #7
0
        public void GetCountByRegionNoMatchTest()
        {
            var repository    = ArticleRepository.Create();
            var article       = this.CreateArticle(repository, SeedArticle.Create());
            var secondArticle = this.CreateArticle(repository, SeedArticle.CreateSecondArticle());
            var service       = this.GetArticlesService(repository);
            var result        = service.GetCountByRegion(Region.Sofia);

            Assert.Equal(0, result);
        }
예제 #8
0
        public void GetCountOfLocalArticlesOneMatchTest()
        {
            var repository        = ArticleRepository.Create();
            var article           = this.CreateArticle(repository, SeedArticle.Create());
            var articleWithRegion = this.CreateArticle(repository, SeedArticle.CreateSecondArticle());
            var service           = this.GetArticlesService(repository);
            var result            = service.GetCountOfLocalArticles();

            Assert.Equal(1, result);
        }
예제 #9
0
        public void GetLatesWithVideosOneMatchTest()
        {
            var repository    = ArticleRepository.Create();
            var article       = this.CreateArticle(repository, SeedArticle.Create());
            var secondArticle = this.CreateArticle(repository, SeedArticle.CreateSecondArticle());
            var service       = this.GetArticlesService(repository);
            var result        = service.GetLatesWithVideos <ArticleDumyModel>();

            Assert.Single(result);
        }
예제 #10
0
        public void GetLatesByCreatedTwoMatchesOnTest()
        {
            var repository    = ArticleRepository.Create();
            var article       = this.CreateArticle(repository, SeedArticle.Create());
            var secondArticle = this.CreateArticle(repository, SeedArticle.CreateSecondArticle());
            var service       = this.GetArticlesService(repository);
            var result        = service.GetLatesByCreatedOn <ArticleDumyModel>();

            Assert.Equal(2, result.Count());
        }
예제 #11
0
        public void GetCount()
        {
            var repository = ArticleRepository.Create();

            this.CreateArticle(repository, SeedArticle.Create());
            var service = this.GetArticlesService(repository);
            var result  = service.GetCount();

            Assert.Equal(1, result);
        }
예제 #12
0
        public void GetLatesMostViewedTest()
        {
            var repository    = ArticleRepository.Create();
            var article       = this.CreateArticle(repository, SeedArticle.Create());
            var secondArticle = this.CreateArticle(repository, SeedArticle.CreateSecondArticle());
            var service       = this.GetArticlesService(repository);
            var result        = service.GetLatesMostViewed <ArticleDumyModel>();

            Assert.Equal(secondArticle.Id, result.First().Id);
        }
예제 #13
0
        public void GetCountBySubCategoryIdOneMatchTest()
        {
            var repository    = ArticleRepository.Create();
            var article       = this.CreateArticle(repository, SeedArticle.Create());
            var secondArticle = this.CreateArticle(repository, SeedArticle.CreateSecondArticle());
            var service       = this.GetArticlesService(repository);
            var result        = service.GetCountBySubCategoryId(1);

            Assert.Equal(1, result);
        }
예제 #14
0
        public void GetSumAllSeensTest()
        {
            var repository    = ArticleRepository.Create();
            var article       = this.CreateArticle(repository, SeedArticle.Create());
            var secondArticle = this.CreateArticle(repository, SeedArticle.CreateSecondArticle());
            var service       = this.GetArticlesService(repository);
            var result        = service.GetSumAllSeens();

            Assert.Equal(3, result);
        }
예제 #15
0
        public void DeleteByIdTest()
        {
            var repository    = ArticleRepository.Create();
            var article       = this.CreateArticle(repository, SeedArticle.Create());
            var secondArticle = this.CreateArticle(repository, SeedArticle.CreateSecondArticle());
            var service       = this.GetArticlesService(repository);

            service.DeleteById(article.Id).GetAwaiter();
            Assert.Equal(1, repository.All().Count());
        }
예제 #16
0
        public void GetAllBySubCategoryIdOneMatchTest()
        {
            var repository    = ArticleRepository.Create();
            var article       = this.CreateArticle(repository, SeedArticle.Create());
            var secondArticle = this.CreateArticle(repository, SeedArticle.CreateSecondArticle());
            var service       = this.GetArticlesService(repository);
            var result        = service.GetAllBySubCategoryId <ArticleDumyModel>(1);

            Assert.Single(result);
        }
예제 #17
0
        public void GetAllByAtuthorIdDeletedNoMatchesTest()
        {
            var repository    = ArticleRepository.Create();
            var article       = this.CreateArticle(repository, SeedArticle.Create());
            var secondArticle = this.CreateArticle(repository, SeedArticle.CreateSecondArticle());
            var service       = this.GetArticlesService(repository);
            var result        = service.GetAllByAtuthorIdDeleted <ArticleDumyModel>(article.AuthorId);

            Assert.Empty(result);
        }
예제 #18
0
        public void GetLatestByRegionNoMatcheshTest()
        {
            var region        = Region.Sofia_District;
            var repository    = ArticleRepository.Create();
            var article       = this.CreateArticle(repository, SeedArticle.Create());
            var secondArticle = this.CreateArticle(repository, SeedArticle.CreateSecondArticle());
            var service       = this.GetArticlesService(repository);
            var result        = service.GetLatestByRegion <ArticleDumyModel>(region);

            Assert.Empty(result);
        }
예제 #19
0
        public void AddToSeenCountTest()
        {
            var repository = ArticleRepository.Create();
            var article    = this.CreateArticle(repository, SeedArticle.Create());
            var service    = this.GetArticlesService(repository);
            var seenCount  = article.SeenCount;

            service.AddToSeenCount(article.Id).GetAwaiter().GetResult();

            Assert.Equal(seenCount + 1, article.SeenCount);
        }
예제 #20
0
        public void GetLastByCreatedOnTest()
        {
            var repository    = ArticleRepository.Create();
            var article       = this.CreateArticle(repository, SeedArticle.Create());
            var secondArticle = this.CreateArticle(repository, SeedArticle.CreateSecondArticle());
            var thirdArticle  = this.CreateArticle(repository, SeedArticle.CreateThirdArticle());
            var service       = this.GetArticlesService(repository);
            var result        = service.GetLastByCreatedOn <ArticleDumyModel>().GetAwaiter().GetResult();

            Assert.Equal(thirdArticle.Id, result.Id);
        }
예제 #21
0
        public void GetLatesMostCommentedTest()
        {
            var repository    = ArticleRepository.Create();
            var article       = this.CreateArticle(repository, SeedArticle.Create());
            var secondArticle = this.CreateArticle(repository, SeedArticle.CreateSecondArticle());
            var thirdArticle  = this.CreateArticle(repository, SeedArticle.CreateThirdArticle());
            var service       = this.GetArticlesService(repository);
            var result        = service.GetLatesMostCommented <ArticleDumyModel>();

            Assert.Empty(result);
        }
예제 #22
0
        public void GetLatesInternationalArticlesoneMatchTest()
        {
            var repository    = ArticleRepository.Create();
            var article       = this.CreateArticle(repository, SeedArticle.Create());
            var secondArticle = this.CreateArticle(repository, SeedArticle.CreateSecondArticle());
            var thirdArticle  = this.CreateArticle(repository, SeedArticle.CreateThirdArticle());
            var service       = this.GetArticlesService(repository);
            var result        = service.GetLatesInternationalArticles <ArticleDumyModel>(1);

            Assert.Single(result);
        }
예제 #23
0
        public void GetLatesInternationalArticlesTwoMatchesTest()
        {
            var repository    = ArticleRepository.Create();
            var article       = this.CreateArticle(repository, SeedArticle.Create());
            var secondArticle = this.CreateArticle(repository, SeedArticle.CreateSecondArticle());
            var thirdArticle  = this.CreateArticle(repository, SeedArticle.CreateThirdArticle());
            var service       = this.GetArticlesService(repository);
            var result        = service.GetLatesInternationalArticles <ArticleDumyModel>();

            Assert.Equal(2, result.Count());
        }
예제 #24
0
        public void GetLatestByRegionOneMatchTest()
        {
            var region        = Region.Burgas;
            var repository    = ArticleRepository.Create();
            var article       = this.CreateArticle(repository, SeedArticle.Create());
            var secondArticle = this.CreateArticle(repository, SeedArticle.CreateSecondArticle());
            var service       = this.GetArticlesService(repository);
            var result        = service.GetLatestByRegion <ArticleDumyModel>(region);

            Assert.Single(result);
        }
예제 #25
0
        public void GetAllByAtuthorIdDeletedOneMatchTest()
        {
            var repository    = ArticleRepository.Create();
            var article       = this.CreateArticle(repository, SeedArticle.Create());
            var secondArticle = this.CreateArticle(repository, SeedArticle.CreateSecondArticle());

            repository.Delete(article);
            repository.SaveChangesAsync().GetAwaiter().GetResult();

            var service = this.GetArticlesService(repository);
            var result  = service.GetAllByAtuthorIdDeleted <ArticleDumyModel>(article.AuthorId);

            Assert.Single(result);
        }
예제 #26
0
        public void UndeleteByIdTest()
        {
            var repository    = ArticleRepository.Create();
            var article       = this.CreateArticle(repository, SeedArticle.Create());
            var secondArticle = this.CreateArticle(repository, SeedArticle.CreateSecondArticle());

            repository.Delete(article);
            repository.SaveChangesAsync().GetAwaiter().GetResult();
            Assert.Equal(1, repository.All().Count());

            var service = this.GetArticlesService(repository);

            service.UndeleteById(article.Id).GetAwaiter();

            Assert.Equal(2, repository.All().Count());
        }