public void MustNotAddAnArticleWithDuplicatedTitle() { var articleAlreadySaved = ArticleBuilder.New().WithTitle(_articleModel.Title).Build(); _articleRepositoryMock.Setup(r => r.GetByTitle(_articleModel.Title)).Returns(articleAlreadySaved); var result = _articlesController.Post(_articleModel); var expectedResult = new ResultViewModel { Success = false, Message = "This title has already taken.", Data = null }; expectedResult.ToExpectedObject().ShouldMatch(result); //Assert.Throws<ArgumentException>(() => _articlesController.Post(_articleModel)).WithMessage("This title is already taken"); }
public void TheArticleMustNotHaveAInvalidContent(string invalidContent) { Assert.Throws <ArgumentException>(() => ArticleBuilder.New().WithContent(invalidContent).Build()) .WithMessage("Invalid Content"); }
public void TheArticleMustNotHaveAInvalidTitle(string invalidTitle) { Assert.Throws <ArgumentException>(() => ArticleBuilder.New().WithTitle(invalidTitle).Build()) .WithMessage("Invalid title"); }