예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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());
        }