internal void AddCourse()
        {
            Console.Write("Please provide a course id: ");
            var courseID = Console.ReadLine();

            while (!Validate.ValidCourseID(courseID))
            {
                Console.WriteLine("Course id violated standard format 4 alphabets prefix 4 digits suffix. Please retry as (COSC2425): ");
                courseID = Console.ReadLine();
            }
            Console.Write("Please provide course name: ");
            var courseName = Console.ReadLine();

            while (courseName == "")
            {
                Console.Write("Blank! Please enter course name: ");
                courseName = Console.ReadLine();
            }

            Console.Write("Please provide course description: ");
            var courseDes = Console.ReadLine();

            while (courseDes == "")
            {
                Console.Write("Blank! Please enter course description: ");
                courseDes = Console.ReadLine();
            }

            bool added = courseController.CreateCourse(courseID, courseName, courseDes);

            if (added)
            {
                Console.WriteLine("\nCongratulation! You added a new \"{0}\" course", courseID);
            }
            else
            {
                Console.WriteLine("\nSorry! You failed to add a course.");
            }
            Console.WriteLine("\nPress any key to continue...");
            Console.ReadLine();
        }
Beispiel #2
0
        public async void CreateCourse_OkResult()
        {
            // Arrange
            var mockCourseRepo = new Mock <IRepositoryAsync <Course> >();
            var controller     = new CourseController(null, mockCourseRepo.Object);

            // Act
            var result = await controller.CreateCourse("Test", "Test", 1, 1, 1, 1, 1, 1, 1);

            // Assert
            Assert.IsType <OkResult>(result);
        }