Ejemplo n.º 1
0
        public AddPostCommandTests()
        {
            var author = new Author {
                Id = _authorId, UserName = "******", DisplayName = "Author 1"
            };

            AuthorRepositoryMock.Setup(m => m.SingleOrDefaultAsync(It.IsAny <Expression <Func <Author, bool> > >(), It.IsAny <CancellationToken>())).ReturnsAsync(author);
        }
Ejemplo n.º 2
0
        public async Task Handler_Should_ReturnNotFoundException_WhenInvalidUser()
        {
            AuthorRepositoryMock.Setup(m => m.SingleOrDefaultAsync(It.IsAny <Expression <Func <Author, bool> > >(), It.IsAny <CancellationToken>())).ReturnsAsync(default(Author));

            var result = await Mediator.Send(new AddPostCommand
            {
                UserName    = "******",
                Categories  = "category",
                Title       = "title",
                Content     = "content",
                Description = "description"
            });

            result.IsSuccess.Should().BeFalse();
            result.Exception.Should().BeOfType <NotFoundException>();
        }