Esempio n. 1
0
 public Instructor GetInstructor(string id)
 {
     var errors = new List<string>();
     var repository = new InstructorRepository(this.entities);
     var service = new InstructorService(repository);
     return service.GetInstructor(id, ref errors);
 }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }