Ejemplo n.º 1
0
        public async Task CreateQuestionErrorTest()
        {
            // Arrange
            var repo     = new Mock <IRepositoryEnq>();
            var question = QuestionData.CreateTestInvalidQuestion;
            var context  = GetMockContext();

            var controller
                = new WriteApiController(repo.Object, context.Object);

            // Act
            var result = await controller.CreateQuestion(question);

            // Assert
            Assert.IsType <BadRequestResult>(result);
            VerifyMockContext(context, 0);
            repo.VerifyNoOtherCalls();
        }
Ejemplo n.º 2
0
        public async Task CreateQuestionTest()
        {
            // Arrange
            var repo    = new Mock <IRepositoryEnq>();
            var context = GetMockContext();

            var question = QuestionData.TestQuestionMinProps;
            var controller
                = new WriteApiController(repo.Object, context.Object);

            // Act
            var result = await controller.CreateQuestion(question);

            // Assert
            Assert.IsType <OkObjectResult>(result);

            repo.Verify(r => r.Create(question), Times.Once);
            repo.Verify(r => r.SaveAsync(), Times.Once);
            VerifyMockContext(context, 1);
            repo.VerifyNoOtherCalls();
        }