public Instructor GetInstructorInfo(string id)
 {
     var errors = new List<string>();
     var repository = new InstructorRepository();
     var service = new InstructorService(repository);
     return service.GetInstructorInfo(id, ref errors);
 }
コード例 #2
0
        public void AssignGradeErrorTest1()
        {
            //// Arrange
            var errors = new List<string>();
            Mock<IInstructorRepository> mockRepository = new Mock<IInstructorRepository>();
            InstructorService iserv = new InstructorService(mockRepository.Object);

            iserv.AssignGrade(null, string.Empty, 1, string.Empty, ref errors);
            Assert.AreEqual(1, errors.Count);
        }
コード例 #3
0
        public void AssignGradeErrorTest3()
        {
            //// Arrange
            var errors = new List<string>();
            Mock<IInstructorRepository> mockRepository = new Mock<IInstructorRepository>();
            InstructorService iserv = new InstructorService(mockRepository.Object);

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

            iserv.AssignGrade(s, "1", 1, string.Empty, ref errors);
            Assert.AreEqual(1, errors.Count);
        }
        public string InsertInstructor(Instructor instructor)
        {
            var errors = new List<string>();
            var repository = new InstructorRepository();
            var service = new InstructorService(repository);
            service.InsertInstructor(instructor, ref errors);
            if (errors.Count == 0)
            {
                return "ok";
            }

            return "error";
        }
        public void InsertInstructorTest()
        {
            //// Arrange
            var errors = new List<string>();
            var mockRepository = new Mock<IInstructorRepository>();
            var instructorService = new InstructorService(mockRepository.Object);

            //// Act
            instructorService.InsertInstructor(null, ref errors);

            //// Assert
            Assert.AreEqual(1, errors.Count);
        }
        public string DeleteInstructor(string id)
        {
            var errors = new List<string>();
            var repository = new InstructorRepository();
            var service = new InstructorService(repository);
            service.DeleteInstructor(id, ref errors);

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

            return "error";
        }
コード例 #7
0
        public string AssignGrade(Schedule schedule, string studentId, int instructorId, string grade)
        {
            var errors = new List<string>();
            var repository = new InstructorRepository(this.entities);
            var service = new InstructorService(repository);
            service.AssignGrade(schedule, studentId, instructorId, grade, ref errors);

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

            return "error";
        }
        public void InsertInstructorTest3()
        {
            //// Arranage
            var errors = new List<string>();
            var mockRepository = new Mock<IInstructorRepository>();
            var instructorService = new InstructorService(mockRepository.Object);
            var instructor = new Instructor { FirstName = string.Empty };

            //// Act
            instructorService.InsertInstructor(instructor, ref errors);

            //// Assert
            Assert.AreEqual(1, errors.Count);
        }
コード例 #9
0
        public void AssignGrade()
        {
            //// Arrange
            var errors = new List<string>();
            Mock<IInstructorRepository> mockRepository = new Mock<IInstructorRepository>();
            InstructorService iserv = new InstructorService(mockRepository.Object);

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

            mockRepository.Setup(x => x.AssignGradeToStudent(s, "1", 1, "A+", ref errors));

            iserv.AssignGrade(s, "1", 1, "A+", ref errors);

            mockRepository.Verify(x => x.AssignGradeToStudent(s, "1", 1, "A+", ref errors), Times.Once());
        }
コード例 #10
0
 public List<Instructor> GetInstructorList()
 {
     var errors = new List<string>();
     var repository = new InstructorRepository(this.entities);
     var service = new InstructorService(repository);
     return service.GetInstructorList(ref errors);
 }
コード例 #11
0
        public string UpdateInstructor(Instructor instructor)
        {
            var errors = new List<string>();
            var repository = new InstructorRepository(this.entities);
            var service = new InstructorService(repository);
            service.UpdateInstructor(instructor, ref errors);

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

            return "error";
        }
コード例 #12
0
        public string RespondToPreReqOverride(int scheduleId, string studentId)
        {
            var errors = new List<string>();
            var repository = new InstructorRepository(this.entities);
            var service = new InstructorService(repository);
            service.RespondToPreReqOverride(scheduleId, studentId, ref errors);

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

            return "error";
        }
コード例 #13
0
        public void InsertInstructor()
        {
            //// Arranage
            var errors = new List<string>();
            var mockRepository = new Mock<IInstructorRepository>();
            var instructorService = new InstructorService(mockRepository.Object);
            var instructor = new Instructor { InstructorId = 2, FirstName = "bb", LastName = "cc", Title = "nope" };

            mockRepository.Setup(x => x.AddInstructor(instructor, ref errors));
            mockRepository.Setup(x => x.IsNotDuplicateInstructor(instructor, ref errors)).Returns(true);

            //// Act
            instructorService.InsertInstructor(instructor, ref errors);

            //// Assert
            mockRepository.Verify(x => x.AddInstructor(instructor, ref errors), Times.Once());
        }
コード例 #14
0
        public void GetInstructorErrorTest1()
        {
            //// Arrange
            var errors = new List<string>();

            var mockRepository = new Mock<IInstructorRepository>();
            var instructorService = new InstructorService(mockRepository.Object);

            //// Act
            instructorService.GetInstructor(string.Empty, ref errors);

            //// Assert instructor id cannot be null
            Assert.AreEqual(1, errors.Count);
        }
コード例 #15
0
        public void UpdateInstructorTest()
        {
            //// Arranage
            var errors = new List<string>();

            Mock<IInstructorRepository> mockRepository = new Mock<IInstructorRepository>();
            InstructorService iserv = new InstructorService(mockRepository.Object);

            Instructor ins = new Instructor { InstructorId = 99, FirstName = "Test", LastName = "test" };

            mockRepository.Setup(x => x.UpdateInstructor(ins, ref errors));

            //// Act
            iserv.UpdateInstructor(ins, ref errors);

            //// Assert
            mockRepository.Verify(x => x.UpdateInstructor(ins, ref errors), Times.Once());
        }
コード例 #16
0
        public void UpdateInstructorErrorTest3()
        {
            //// Arranage
            var errors = new List<string>();
            var mockRepository = new Mock<IInstructorRepository>();
            var instructorService = new InstructorService(mockRepository.Object);
            var instructor = new Instructor { FirstName = "nick", LastName = string.Empty };

            //// Act
            instructorService.UpdateInstructor(instructor, ref errors);

            //// Assert last name cannot be empty
            Assert.AreEqual(1, errors.Count);
        }
コード例 #17
0
        public void UpdateInstructorErrorTest1()
        {
            //// Arranage
            var errors = new List<string>();
            var mockRepository = new Mock<IInstructorRepository>();
            var instructorService = new InstructorService(mockRepository.Object);

            //// Act
            instructorService.UpdateInstructor(null, ref errors);

            //// Assert instructor object not null
            Assert.AreEqual(1, errors.Count);
        }
コード例 #18
0
        public void UpdateInstructor()
        {
            //// Arranage
            var errors = new List<string>();
            var mockRepository = new Mock<IInstructorRepository>();
            var instructorService = new InstructorService(mockRepository.Object);
            var instructor = new Instructor { InstructorId = 2, FirstName = "bb", LastName = "zz", Title = "NOPE" };

            mockRepository.Setup(x => x.UpdateInstructor(instructor, ref errors));

            //// Act
            instructorService.UpdateInstructor(instructor, ref errors);

            //// Assert
            mockRepository.Verify(x => x.UpdateInstructor(instructor, ref errors), Times.Once());
        }
コード例 #19
0
        public void PreReqOverrideErrorTest2()
        {
            //// Arrange
            var errors = new List<string>();
            Mock<IInstructorRepository> mockRepository = new Mock<IInstructorRepository>();
            InstructorService iserv = new InstructorService(mockRepository.Object);

            iserv.RespondToPreReqOverride(2, string.Empty, ref errors);
            Assert.AreEqual(1, errors.Count);
        }
コード例 #20
0
        public void GetInstructorListTest()
        {
            //// Arrange
            var errors = new List<string>();

            Mock<IInstructorRepository> mockRepository = new Mock<IInstructorRepository>();
            InstructorService iserv = new InstructorService(mockRepository.Object);

            List<Instructor> crl = new List<Instructor>();
            crl.Add(new Instructor { InstructorId = 99, FirstName = "T", LastName = "Test", Title = "Tester" });

            mockRepository.Setup(x => x.GetInstructorList(ref errors)).Returns(crl);

            //// Act
            Instructor temp = iserv.GetInstructorList(ref errors)[0];

            //// Assert
            Assert.AreEqual(0, errors.Count);
            Assert.AreEqual(99, temp.InstructorId);
        }
コード例 #21
0
        public void GetInstructor()
        {
            //// Arrange
            var errors = new List<string>();

            Mock<IInstructorRepository> mockRepository = new Mock<IInstructorRepository>();
            InstructorService iserv = new InstructorService(mockRepository.Object);

            Instructor crl = new Instructor()
            {
                InstructorId = 99,
                FirstName = "T",
                LastName = "Test",
                Title = "Tester"
            };

            mockRepository.Setup(x => x.FindInstructorById(99, ref errors)).Returns(crl);

            //// Act
            Instructor temp = iserv.GetInstructor("99", ref errors);

            //// Assert
            Assert.AreEqual(0, errors.Count);
            Assert.AreEqual(99, temp.InstructorId);
            Assert.AreEqual("T", temp.FirstName);
            Assert.AreEqual("Test", temp.LastName);
        }
コード例 #22
0
        public void PreReqOverride()
        {
            //// Arrange
            var errors = new List<string>();
            Mock<IInstructorRepository> mockRepository = new Mock<IInstructorRepository>();
            InstructorService iserv = new InstructorService(mockRepository.Object);

            mockRepository.Setup(x => x.ApprovePreReqOverride(1, "1", ref errors));

            iserv.RespondToPreReqOverride(1, "1", ref errors);

            mockRepository.Verify(x => x.ApprovePreReqOverride(1, "1", ref errors), Times.Once());
        }