public void PostTitleReturns202()
        {
            //arrange


            var mockRepo = new Mock <LogLib.Interfaces.ICreateQuizRepository>();

            mockRepo.Setup(r => r.CreateTitle(It.IsAny <LogLibMod.Title>()));


            var mockGetRepo = new Mock <LogLib.Interfaces.IGetDataRepository>();

            mockGetRepo.Setup(r => r.UserExists(It.IsAny <int>())).Returns(true);
            mockGetRepo.Setup(r => r.TitleExists(It.IsAny <int>())).Returns(true);

            var controller = new CreateQuizController(mockRepo.Object, mockGetRepo.Object);

            //act

            var statusCode = Assert.IsType <StatusCodeResult>(controller.PostTitle(new Rest.Api.Models.TitleModel()
            {
            }));

            //assert


            Assert.Equal(202, statusCode.StatusCode);
        }
        public void GetReturnsStatusCode100()
        {
            //arrange
            var mockRepo   = new Mock <LogLib.Interfaces.ICreateQuizRepository>();
            var mockRepo2  = new Mock <LogLib.Interfaces.IGetDataRepository>();
            var controller = new CreateQuizController(mockRepo.Object, mockRepo2.Object);


            //act

            var statusCode = Assert.IsType <StatusCodeResult>(controller.Get());

            //assert

            Assert.Equal(100, statusCode.StatusCode);
        }
        public void PostAnswerSucceeds()
        {
            //arrange
            var mockRepo = new Mock <LogLib.Interfaces.ICreateQuizRepository>();

            mockRepo.Setup(r => r.CreateAnswer(It.IsAny <LogLibMod.Answer>()));

            var mockGetRepo = new Mock <LogLib.Interfaces.IGetDataRepository>();

            mockGetRepo.Setup(r => r.QuestionExists(It.IsAny <int>())).Returns(true);
            mockGetRepo.Setup(r => r.CategoryExists(It.IsAny <int>())).Returns(true);

            var controller = new CreateQuizController(mockRepo.Object, mockGetRepo.Object);

            //act assert
            var statusCode = Assert.IsType <StatusCodeResult>(controller.PostAnswer(new Rest.Api.Models.AnswerModel {
            }));

            Assert.Equal(202, statusCode.StatusCode);
        }
        public void PutRanksPassesCorrectly()
        {
            //arrange
            var mockRepo = new Mock <LogLib.Interfaces.ICreateQuizRepository>();

            mockRepo.Setup(r => r.SetCategoryRank(It.IsAny <int>(), It.IsAny <int>()));

            var mockGetRepo = new Mock <LogLib.Interfaces.IGetDataRepository>();

            var controller = new CreateQuizController(mockRepo.Object, mockGetRepo.Object);

            var categories = new Rest.Api.Models.CategoryModel[1]
            {
                new Rest.Api.Models.CategoryModel
                {
                    Rank = 1
                }
            };

            //act assert
            var statusCode = Assert.IsType <StatusCodeResult>(controller.PutCategoryRanks(categories));

            Assert.Equal(204, statusCode.StatusCode);
        }
Esempio n. 5
0
 public CreateQuizF(GreetingF greeting)
 {
     InitializeComponent();
     _controller = new CreateQuizController(this, greeting);
     _previousF  = greeting;
 }