public void GivenAnQuestionWithInvalidData_Create_StoresAQuestion() { // Arrange. Question question = new Question(); // Empty, invalid question var documentSession = new Mock<IDocumentSession>(); IQuestionService questionService = new QuestionService(documentSession.Object); // Act & Assert. Assert.Throws<ValidationException>(() => questionService.Create(question)); }
public void GivenAnQuestionWithInvalidData_Create_StoresAQuestion() { // Arrange. Question question = FakeQuestions.CreateAFakeQuestion(null, null); // No user created this question. var documentSession = new Mock<IDocumentSession>(); IQuestionService questionService = new QuestionService(documentSession.Object); // Act & Assert. Assert.Throws<ValidationException>(() => questionService.Create(question)); }
public void GivenAnQuestionWithValidData_Create_StoresAQuestion() { // Arrange. Question question = FakeQuestions.CreateAFakeQuestion("users/1", null); var documentSession = new Mock<IDocumentSession>(); IQuestionService questionService = new QuestionService(documentSession.Object); // Act. questionService.Create(question); // Assert. documentSession.Verify(x => x.Store(question), Times.Once()); documentSession.Verify(x => x.SaveChanges(), Times.Once()); }