public void WhenUpVoted_TheVotesCount_ShouldIncreaseByOne() { var hasVoteIncreased = false; DomainEvents.ListenFor <QuestionUpVoted>(@event => { hasVoteIncreased = true; }); var poster = new Poster(new Name("Joe", "Bloggs")); var content = new PlainTextContent(); var question = new Question("A question", content, poster); question.UpVote(Guid.NewGuid()); Assert.Equal(1, question.GetVoteCount()); Assert.True(hasVoteIncreased); }
public void WhenAContributorAddsAnAsnwer_TheAnswer_ShouldBeAdded() { var poster = new Poster(new Name("Joe", "Bloggs")); var content = new PlainTextContent(); var question = new Question("A question", content, poster); var contributor = new Contributor(new Name("Joe", "Bloggs"), new Reputation(1000)); var answer = new Answer(question.Id, contributor, new PlainTextContent("This is an answer")); var isAdded = false; DomainEvents.ListenFor <AnswerAdded>(@event => { isAdded = true; }); question.AddAnAnswer(answer); Assert.True(isAdded); Assert.Equal(1, question.Answers.Count); }
public void WhenThePosterUnacceptsAnAsnwer_TheAnswer_ShouldBeMarkedAsNotAccepted() { var poster = new Poster(new Name("Joe", "Bloggs")); var content = new PlainTextContent(); var question = new Question("A question", content, poster); var contributor = new Contributor(new Name("Joe", "Bloggs"), new Reputation(1000)); var answer = new Answer(question.Id, contributor, new PlainTextContent("This is an answer")); question.AddAnAnswer(answer); question.AcceptAnswer(answer.Id, poster.Id); var isUnaccepted = false; DomainEvents.ListenFor <AnswerUnaccepted>(@event => { isUnaccepted = true; }); question.UnacceptAnswer(answer.Id, poster.Id); Assert.True(isUnaccepted); Assert.Null(question.AcceptedAnswer); }