コード例 #1
0
ファイル: ScheduleServiceTest.cs プロジェクト: fastily/cse136
        public void AddCourseToScheduleErrorTest3()
        {
            //// Arranage
            var errors = new List<string>();
            var mockRepository = new Mock<IScheduleRepository>();
            var scheduleService = new ScheduleService(mockRepository.Object);
            var schedule = new Schedule { };
            //// Act
            scheduleService.AddCourseToSchedule(schedule, ref errors);

            //// Assert cant be null course object
            Assert.AreEqual(1, errors.Count);
        }
        public void InsertToSchTest()
        {
            //// Arrange
            var errors = new List<String>();
            var mockRepository = new Mock<IScheduleRepository>();
            var scheduleService = new ScheduleService(mockRepository.Object);

            //// Act
            scheduleService.InsertToSchedule(null, ref errors);

            //// Assert
            Assert.AreEqual(1, errors.Count);
        }
        public void DeleteFromSchTest2()
        {
            //// Arrange
            var errors = new List<String>();
            var mockRepository = new Mock<IScheduleRepository>();
            var scheduleService = new ScheduleService(mockRepository.Object);
            var schedule = new Schedule { Quarter = string.Empty, Year = string.Empty };

            //// Act
            scheduleService.DeleteFromSchedule(schedule, ref errors);

            //// Assert
            Assert.AreEqual(5, errors.Count);
        }
コード例 #4
0
ファイル: ScheduleController.cs プロジェクト: fastily/cse136
        public string DeleteCourseFromSchedule(int id)
        {
            var errors = new List<string>();
            var repository = new ScheduleRepository(this.entities);
            var service = new ScheduleService(repository);
            service.RemoveCourseFromSchedule(id, ref errors);

            if (errors.Count == 0)
            {
                return "ok";
            }

            return "error";
        }
コード例 #5
0
ファイル: ScheduleController.cs プロジェクト: fastily/cse136
        public string DeleteAllFromSchedule(ScheduleMin schedule)
        {
            var errors = new List<string>();
            var repository = new ScheduleRepository(this.entities);
            var service = new ScheduleService(repository);
            service.RemoveWholeSchedule(schedule.Year, schedule.Quarter, ref errors);

            if (errors.Count == 0)
            {
                return "ok";
            }

            return "error";
        }
コード例 #6
0
ファイル: ScheduleController.cs プロジェクト: fastily/cse136
        public string AddCourseToSchedule(Schedule schedule)
        {
            var errors = new List<string>();
            var repository = new ScheduleRepository(this.entities);
            var service = new ScheduleService(repository);
            service.AddCourseToSchedule(schedule, ref errors);

            if (errors.Count == 0)
            {
                return "ok";
            }

            return "error";
        }
        public void GetSchTest()
        {
            //// Arrange
            var errors = new List<String>();
            var mockRepository = new Mock<IScheduleRepository>();
            var scheduleService = new ScheduleService(mockRepository.Object);
            String year = string.Empty;
            String quarter = string.Empty;

            //// Act
            scheduleService.GetScheduleList(year, quarter, ref errors);

            //// Assert
            Assert.AreEqual(2, errors.Count);
        }
コード例 #8
0
ファイル: ScheduleServiceTest.cs プロジェクト: fastily/cse136
        public void AddCourseScheduleTest()
        {
            //// Arranage
            var errors = new List<string>();

            Mock<IScheduleRepository> mockRepository = new Mock<IScheduleRepository>();
            ScheduleService iserv = new ScheduleService(mockRepository.Object);

            Schedule s = new Schedule { ScheduleId = 99, Year = "1000", Quarter = "Winter", Session = "2" };

            mockRepository.Setup(x => x.AddCourseToSchedule(s, ref errors));

            //// Act
            ////iserv.AddCourseToSchedule(s, ref errors);

            //// Assert
            ////mockRepository.Verify(x => x.AddCourseToSchedule(s, ref errors), Times.Once());
        }
コード例 #9
0
ファイル: ScheduleServiceTest.cs プロジェクト: fastily/cse136
        public void RemoveCourseFromScheduleErrorTest()
        {
            //// Arrange
            var errors = new List<string>();

            var mockRepository = new Mock<IScheduleRepository>();
            var scheduleService = new ScheduleService(mockRepository.Object);

            //// Act
            scheduleService.RemoveCourseFromSchedule(0, ref errors);

            //// Assert course id cannot be null
            Assert.AreEqual(1, errors.Count);
        }
コード例 #10
0
ファイル: ScheduleController.cs プロジェクト: fastily/cse136
        public List<Schedule> GetInstructorSchedule(int instructorId)
        {
            var service = new ScheduleService(new ScheduleRepository(this.entities));
            var errors = new List<string>();

            return service.GetInstructorSchedule(instructorId, ref errors);
        }
コード例 #11
0
ファイル: ScheduleController.cs プロジェクト: fastily/cse136
        public Schedule GetScheduleById(int id)
        {
            var service = new ScheduleService(new ScheduleRepository(this.entities));
            var errors = new List<string>();

            return service.GetScheduleById(id, ref errors);
        }
コード例 #12
0
ファイル: ScheduleController.cs プロジェクト: fastily/cse136
        public List<Ta> GetTaBySchedule(int scheduleId)
        {
            var service = new ScheduleService(new ScheduleRepository(this.entities));
            var errors = new List<string>();

            return service.GetTaBySchedule(scheduleId, ref errors);
        }
コード例 #13
0
ファイル: ScheduleController.cs プロジェクト: fastily/cse136
        public List<ScheduleMin> GetStudentScheduleListMin(string id)
        {
            var service = new ScheduleService(new ScheduleRepository(this.entities));
            var errors = new List<string>();

            return service.GetStudentScheduleMin(id, ref errors);
        }
コード例 #14
0
ファイル: ScheduleController.cs プロジェクト: fastily/cse136
        public List<Schedule> GetScheduleList(string year, string quarter)
        {
            var service = new ScheduleService(new ScheduleRepository(this.entities));
            var errors = new List<string>();

            return service.GetScheduleList(year, quarter, ref errors);
        }
コード例 #15
0
ファイル: ScheduleController.cs プロジェクト: fastily/cse136
 public List<ScheduleDay> GetDays()
 {
     var service = new ScheduleService(new ScheduleRepository(this.entities));
     var errors = new List<string>();
     return service.GetDays(ref errors);
 }
コード例 #16
0
ファイル: ScheduleServiceTest.cs プロジェクト: fastily/cse136
        public void GetScheduleListTest()
        {
            //// Arrange
            var errors = new List<string>();

            Mock<IScheduleRepository> mockRepository = new Mock<IScheduleRepository>();
            ScheduleService schedservice = new ScheduleService(mockRepository.Object);

            List<Schedule> crl = new List<Schedule>();
            crl.Add(new Schedule { ScheduleId = 99, Year = "1000", Quarter = "Winter", Session = "2" });

            mockRepository.Setup(x => x.GetScheduleList("1000", "Winter", ref errors)).Returns(crl);

            //// Act
            Schedule temp = schedservice.GetScheduleList("1000", "Winter", ref errors)[0];

            //// Assert
            Assert.AreEqual(99, temp.ScheduleId);
            ////Assert.AreEqual(3, rating);
        }
コード例 #17
0
 /// <summary>
 /// Get a list of schedule with filtering
 /// </summary>
 /// <param name="year">year selected</param>
 /// <param name="quarter">quarter selected</param>
 /// <param name="errors">error list</param>
 /// <returns>list of schedule</returns>
 public List<Schedule> GetScheduleList(string year, string quarter, ref List<string> errors)
 {
     var service = new ScheduleService(new ScheduleRepository());
     return service.GetScheduleList(year, quarter, ref errors);
 }