Esempio n. 1
0
        public void Test_Find_FindsCourseInDatabase()
        {
            Course testCourse = new Course("Intro to programming",975,"Epicodus","5 weeks");
              testCourse.Save();

              Course foundCourse = Course.Find(testCourse.GetId());

              Assert.Equal(testCourse, foundCourse);
        }
Esempio n. 2
0
        public void Test_Save_SavesToDatabase()
        {
            Course testCourse = new Course("Intro to programming",975,"Epicodus","5 weeks");

              testCourse.Save();
              List<Course> result = Course.GetAll();
              List<Course> testList = new List<Course>{testCourse};

              Assert.Equal(testList, result);
        }
Esempio n. 3
0
        public void Test_Save_AssignsIdToObject()
        {
            Course testCourse=new Course("Intro to programming",975,"Epicodus","5 weeks");

              testCourse.Save();
              Course savedCourse = Course.GetAll()[0];
              int result=savedCourse.GetId();
              int testId=testCourse.GetId();

              Assert.Equal(testId,result);
        }
Esempio n. 4
0
        public HomeModule()
        {
            Get["/"] = _ => {
            return View["index.cshtml"];
              };

              Get["/all"] = _ => {
            List<Course> allCourses=Course.GetAll();
            return View["view_all.cshtml", allCourses];
              };

              Post["/results"] = _ => {
            Course newCourse = new Course(
            Request.Form["new-course"],
            Request.Form["new-cost"],
            Request.Form["new-company"],
            Request.Form["new-duration"]);
            newCourse.Save();
            List<Course> allCourses=Course.GetAll();
            return View["results.cshtml", allCourses];
              };
              Get["/find"] = _ => {

            return View["find.cshtml"];
              };

              Get["/delete"] = _ => {

            return View["delete.cshtml"];
              };

              Get["/findForm"] = _ => {
            int idName = int.Parse(Request.Query["old-id"]);
            Course newCourse=Course.Find(idName);
            return View["find-result.cshtml",newCourse];
              };

              Post["/delete"] = _ => {
            Course.DeleteAll();
            return View["confirm.cshtml"];
              };
        }