Exemple #1
0
        public void TestPostTopic()
        {
            ExpectedCourses expectedCourses = new ExpectedCourses();
            string          courseName      = expectedCourses.GetCourses()[0].title;
            DbTopics        dbTopics        = new DbTopics();
            string          topicName       = "Test Topic";
            ObjectResult    result          = (ObjectResult)topicsController.Post(courseName, topicName);
            int?            statusCode      = result.StatusCode;

            Assert.Equal(201, statusCode);
            Assert.True(dbTopics.IsExistTopic(courseName, topicName));
            topicsController.Delete(courseName, topicName);
        }
Exemple #2
0
        public void TestGetTopics()
        {
            ExpectedCourses expectedCourses = new ExpectedCourses();
            string          courseName      = expectedCourses.GetCourses()[0].title;
            ObjectResult    result          = (ObjectResult)topicsController.Get(courseName).Result;
            int?            statusCode      = result.StatusCode;

            Assert.Equal(200, statusCode);
            List <TopicAPI> actual         = (List <TopicAPI>)result.Value;
            ExpectedTopics  expectedTopics = new ExpectedTopics();
            List <Topic>    expected       = expectedTopics.GetTopics(courseName);

            Assert.Equal(expected.Count, actual.Count);
            for (int i = 0; i < expected.Count; ++i)
            {
                Assert.True(expected[i].name == actual[i].name && expected[i].course == expected[i].course);
            }
        }
Exemple #3
0
        public void TestGetCourses()
        {
            DbCourses         courses           = new DbCourses();
            CoursesController coursesController = new CoursesController(courses);
            ExpectedCourses   expectedCourses   = new ExpectedCourses();
            List <Course>     expected          = expectedCourses.GetCourses();
            ObjectResult      result            = (ObjectResult)coursesController.Get().Result;
            int?statusCode = result.StatusCode;

            Assert.Equal(200, statusCode);
            List <Course> actual = (List <Course>)result.Value;

            Assert.Equal(expected.Count, actual.Count);
            for (int i = 0; i < expected.Count; ++i)
            {
                Assert.Equal(expected[i].title, actual[i].title);
            }
        }