Exemple #1
0
        public async System.Threading.Tasks.Task QuestionnaireGetNotFound()
        {
            //Arrange
            var mockDbContext     = new Mock <IntegratedCourseSystemContext>();
            var questionnaireList = new List <Questionnaire> {
                new Questionnaire()
                {
                    Id = 0, StudentId = 0, ClassId = 0
                },
                new Questionnaire()
                {
                    Id = 1, StudentId = 1, ClassId = 0
                }
            };

            mockDbContext.Setup(x => x.Questionnaires).Returns(DbContextMock.GetQueryableMockDbSet(questionnaireList));
            var qController = new QuestionnaireController(mockDbContext.Object);
            //Act
            var result = await qController.GetQuestionnaire(new QuestionnaireController.QuestionnaireIdentityArgs {
                ClassId = 3, StudentId = 0
            });

            //Assert
            Assert.IsType <NotFoundResult>(result.Result);
        }
Exemple #2
0
        public async System.Threading.Tasks.Task QuestionnaireGetSuccesfull()
        {
            //Arrange
            var context = TestingUtilities.CreateInMemoryDatabaseContext("TestDatabaseGetQ");
            var data    = new List <Questionnaire>
            {
                new Questionnaire()
                {
                    Id = 0, StudentId = 0, ClassId = 0
                },
                new Questionnaire()
                {
                    Id = 1, StudentId = 1, ClassId = 0
                }
            };

            context.Questionnaires.Add(data[0]);
            context.SaveChanges();
            var qController = new QuestionnaireController(context);
            //Act
            var result = await qController.GetQuestionnaire(new QuestionnaireController.QuestionnaireIdentityArgs {
                ClassId = 0, StudentId = 0
            });

            var resValue  = result.Value;
            var resResult = result.Result;

            //Assert
            Assert.Equal(data.First(), resValue);
        }