Esempio n. 1
0
        public async Task GetArticlesQueryHandler_GivenNoArguments_ShouldReturnArticles()
        {
            GetArticlesQuery        query   = new GetArticlesQuery();
            GetArticlesQueryHandler handler = new GetArticlesQueryHandler();

            var request = await handler.Handle(query, new System.Threading.CancellationToken());

            Assert.IsType <List <ArticleDto> >(request);
        }
Esempio n. 2
0
        public async Task GivenValidRequest_WhenRequestContainsPossibleQueryParams_ReturnsArticlesVieWModel()
        {
            // Arrange
            var getArticlesCommand = new GetArticlesQuery("dragons", "joey.mckenzie", null, null, null);

            // Act
            var command  = new GetArticlesQueryHandler(UserManager, Context, Mapper);
            var response = await command.Handle(getArticlesCommand, CancellationToken.None);

            // Assert
            response.ShouldNotBeNull();
            response.ShouldBeOfType <ArticleViewModelList>();
            response.Articles.ShouldNotBeNull();
            response.Articles.ShouldBeOfType <List <ArticleDto> >();
            response.Articles.ShouldNotBeEmpty();
            response.Articles.FirstOrDefault()?.TagList.ShouldContain("dragons");
        }
Esempio n. 3
0
        public async Task GivenValidRequest_WhenRequestContainsLimitParam_ReturnsLimitedResultsArticlesInArticlesVieWModel()
        {
            // Arrange
            var getArticlesCommand = new GetArticlesQuery(null, null, null, 1, null);

            // Act
            var command  = new GetArticlesQueryHandler(UserManager, Context, Mapper);
            var response = await command.Handle(getArticlesCommand, CancellationToken.None);

            // Assert
            response.ShouldNotBeNull();
            response.ShouldBeOfType <ArticleViewModelList>();
            response.Articles.ShouldNotBeNull();
            response.Articles.ShouldBeOfType <List <ArticleDto> >();
            response.Articles.ShouldNotBeEmpty();
            response.Articles.Count().ShouldBe(1);
            response.Articles.ShouldContain(a => a.Author.Username == "joey.mckenzie");
            response.Articles.FirstOrDefault(a => a.Author.Username == "joey.mckenzie")?.TagList.ShouldNotBeEmpty();
        }
Esempio n. 4
0
        public async Task GivenValidRequest_WhenRequestContainsPossibleQueryParamsWithNoResultMatches_ReturnsArticlesVieWModelWithNoResults()
        {
            // Arrange
            var getArticlesCommand = new GetArticlesQuery(null, "joey.mckenzie", "thisUserDoesNotExist", null, null);

            // Act
            var command  = new GetArticlesQueryHandler(UserManager, Context, Mapper);
            var response = await command.Handle(getArticlesCommand, CancellationToken.None);

            // Assert
            response.ShouldNotBeNull();
            response.ShouldBeOfType <ArticleViewModelList>();
            response.Articles.ShouldNotBeNull();
            response.Articles.ShouldBeOfType <List <ArticleDto> >();
            response.Articles.ShouldBeEmpty();
            response.Articles.FirstOrDefault()?.Author.Following.ShouldBeTrue();
            response.Articles.FirstOrDefault()?.Favorited.ShouldBeTrue();
            response.Articles.FirstOrDefault()?.TagList.ShouldNotBeEmpty();
        }