示例#1
0
        public void AskAQuestion_NullQuestionSubmitted_ThrowException()
        {
            var mockQuestionRepository = new Mock <IQuestionRepository>();
            var mockAnswerRepository   = new Mock <IAnswerRepository>();

            var askUC = new AskUC(mockAnswerRepository.Object, mockQuestionRepository.Object);

            Assert.ThrowsException <NullReferenceException>(() => askUC.AskAQuestion(null));
        }
示例#2
0
        public void AskAQuestion_Successful()
        {
            var mockQuestionRepository = new Mock <IQuestionRepository>();

            mockQuestionRepository.Setup(u => u.Create(It.IsAny <QuestionTO>()))
            .Returns(MockQuestion);
            var mockAnswerRepository = new Mock <IAnswerRepository>();

            DateTime date      = DateTime.Now;
            var      question2 = new QuestionTO {
                IsResolved = false, Message = "Je n'arrive pas à faire un test!", Title = "Problème avec Tests", Date = date, AuthorId = 1
            };

            var askUC         = new AskUC(mockAnswerRepository.Object, mockQuestionRepository.Object);
            var addedQuestion = askUC.AskAQuestion(question2);

            Assert.IsNotNull(addedQuestion);
            mockQuestionRepository.Verify((m => m.Create(It.IsAny <QuestionTO>())), Times.Once());
        }