/// <summary>
        /// Default constructor
        /// </summary>
        public CoursesController()
        {
            UnitOfWork <AppDataContext> uow = new UnitOfWork <AppDataContext>();

            _service           = new CoursesServiceProvider(uow);
            _assignmentService = new AssignmentServiceProvider(uow);
        }
Example #2
0
        public void GetCoursesBySemester_ReturnsEmptyListWhenNoDataDefined()
        {
            // Arrange:
            var mockUnitOfWork = new MockUnitOfWork <MockDataContext>();
            var service        = new CoursesServiceProvider(mockUnitOfWork);
            // Act:
            var result = service.GetCourseInstancesBySemester("20151");

            // Assert:
            var expected = new List <CourseInstanceDTO>();

            Assert.AreEqual(expected.Count, result.Count);
        }
        public void Setup()
        {
            // TODO: code which will be executed before each test!

            _mockUnitOfWork = new MockUnitOfWork <MockDataContext>();
            _dataFactory    = new MockDataFactory();

            // Setting up mock repos to be used
            _mockUnitOfWork.SetRepositoryData(_dataFactory.GetMockRepo <Person>());
            _mockUnitOfWork.SetRepositoryData(_dataFactory.GetMockRepo <CourseTemplate>());
            _mockUnitOfWork.SetRepositoryData(_dataFactory.GetMockRepo <CourseInstance>());
            _mockUnitOfWork.SetRepositoryData(_dataFactory.GetMockRepo <AssignmentGroup>());
            _mockUnitOfWork.SetRepositoryData(_dataFactory.GetMockRepo <Assignment>());

            _mockUnitOfWork.SetRepositoryData(_dataFactory.GetMockRepo <TeacherRegistration>());

            // Creating the service using the new mock UOW
            _service = new CoursesServiceProvider(_mockUnitOfWork);
        }
 public CoursesController(IUnitOfWork uow)
 {
     _service = new CoursesServiceProvider(uow);
 }
        public void CourseServicesTestsSetup()
        {
            _mockUnitOfWork = new MockUnitOfWork <MockDataContext>();

            #region Persons
            var persons = new List <Person>
            {
                // Of course I'm the first person,
                // did you expect anything else?
                new Person
                {
                    ID    = 1,
                    Name  = "Daníel B. Sigurgeirsson",
                    SSN   = SSN_DABS,
                    Email = "*****@*****.**"
                },
                new Person
                {
                    ID    = 2,
                    Name  = NAME_GUNNA,
                    SSN   = SSN_GUNNA,
                    Email = "*****@*****.**"
                }
            };
            #endregion

            #region Course templates

            var courseTemplates = new List <CourseTemplate>
            {
                new CourseTemplate
                {
                    CourseID    = "T-514-VEFT",
                    Description = "Í þessum áfanga verður fjallað um vefþj...",
                    Name        = "Vefþjónustur"
                }
            };
            #endregion

            #region Courses
            var courses = new List <CourseInstance>
            {
                new CourseInstance
                {
                    ID         = COURSEID_VEFT_20153,
                    CourseID   = "T-514-VEFT",
                    SemesterID = "20153"
                },
                new CourseInstance
                {
                    ID         = COURSEID_VEFT_20163,
                    CourseID   = "T-514-VEFT",
                    SemesterID = "20163"
                }
            };
            #endregion

            #region Teacher registrations
            _teacherRegistrations = new List <TeacherRegistration>
            {
                new TeacherRegistration
                {
                    ID = 101,
                    CourseInstanceID = COURSEID_VEFT_20153,
                    SSN  = SSN_DABS,
                    Type = TeacherType.MainTeacher
                }
            };
            #endregion

            _mockUnitOfWork.SetRepositoryData(persons);
            _mockUnitOfWork.SetRepositoryData(courseTemplates);
            _mockUnitOfWork.SetRepositoryData(courses);
            _mockUnitOfWork.SetRepositoryData(_teacherRegistrations);

            // TODO: this would be the correct place to add
            // more mock data to the mockUnitOfWork!

            _service = new CoursesServiceProvider(_mockUnitOfWork);
        }
Example #6
0
 /// <summary>
 ///
 /// </summary>
 CoursesController()
 {
     _service = new CoursesServiceProvider();
 }
        public CourseServicesTests()
        {
            _mockUnitOfWork = new MockUnitOfWork <MockDataContext>();

            #region Persons
            var persons = new List <Person> {
                // Of course I'm the first person,
                // did you expect anything else?
                new Person {
                    ID    = 1,
                    Name  = NAME_DABS,
                    SSN   = SSN_DABS,
                    Email = "*****@*****.**"
                },
                new Person {
                    ID    = 2,
                    Name  = NAME_GUNNA,
                    SSN   = SSN_GUNNA,
                    Email = "*****@*****.**"
                },
                new Person {
                    ID    = 3,
                    Name  = NAME_DAVID,
                    SSN   = SSN_DAVID,
                    Email = "*****@*****.**"
                },
                new Person {
                    ID    = 4,
                    Name  = NAME_DARRI,
                    SSN   = SSN_DARRI,
                    Email = "*****@*****.**"
                }
            };
            #endregion

            #region Course templates

            var courseTemplates = new List <CourseTemplate> {
                new CourseTemplate {
                    CourseID    = VEFT_TEMPLATE_ID,
                    Description = "Í þessum áfanga verður fjallað um vefþj...",
                    Name        = VEFT_TEMPLATE_NAME
                },
                new CourseTemplate {
                    CourseID    = PROG_TEMPLATE_ID,
                    Description = "Í þessum áfanga verður forritad slatta...",
                    Name        = PROG_TEMPLATE_NAME
                },
                new CourseTemplate {
                    CourseID    = GAGN_TEMPLATE_ID,
                    Description = "Í þessum áfanga verður forritad i drasl...",
                    Name        = GAGN_TEMPLATE_NAME
                }
            };
            #endregion

            #region Courses
            var courses = new List <CourseInstance> {
                new CourseInstance {
                    ID         = COURSEID_VEFT_20153,
                    CourseID   = VEFT_TEMPLATE_ID,
                    SemesterID = "20153"
                },
                new CourseInstance {
                    ID         = COURSEID_VEFT_20163,
                    CourseID   = VEFT_TEMPLATE_ID,
                    SemesterID = "20163"
                },
                new CourseInstance {
                    ID         = COURSEID_GAGN_20153,
                    CourseID   = GAGN_TEMPLATE_ID,
                    SemesterID = "20153"
                },
                new CourseInstance {
                    ID         = COURSEID_GAGN_20163,
                    CourseID   = GAGN_TEMPLATE_ID,
                    SemesterID = "20163"
                },
                new CourseInstance {
                    ID         = COURSEID_PROG_20143,
                    CourseID   = PROG_TEMPLATE_ID,
                    SemesterID = "20143"
                },
                new CourseInstance {
                    ID         = COURSEID_PROG_20163,
                    CourseID   = PROG_TEMPLATE_ID,
                    SemesterID = "20163"
                }
            };
            #endregion

            #region Teacher registrations
            _teacherRegistrations = new List <TeacherRegistration> {
                new TeacherRegistration {
                    ID = 101,
                    CourseInstanceID = COURSEID_VEFT_20153,
                    SSN  = SSN_DABS,
                    Type = TeacherType.MainTeacher
                },
                new TeacherRegistration {
                    ID = 102,
                    CourseInstanceID = COURSEID_PROG_20163,
                    SSN  = SSN_DARRI,
                    Type = TeacherType.AssistantTeacher
                },
                new TeacherRegistration {
                    ID = 103,
                    CourseInstanceID = COURSEID_PROG_20163,
                    SSN  = SSN_DAVID,
                    Type = TeacherType.AssistantTeacher
                },
                new TeacherRegistration {
                    ID = 104,
                    CourseInstanceID = COURSEID_PROG_20143,
                    SSN  = SSN_DAVID,
                    Type = TeacherType.MainTeacher
                },
                new TeacherRegistration {
                    ID = 105,
                    CourseInstanceID = COURSEID_GAGN_20163,
                    SSN  = SSN_DARRI,
                    Type = TeacherType.MainTeacher
                }
            };
            #endregion

            _mockUnitOfWork.SetRepositoryData(persons);
            _mockUnitOfWork.SetRepositoryData(courseTemplates);
            _mockUnitOfWork.SetRepositoryData(courses);
            _mockUnitOfWork.SetRepositoryData(_teacherRegistrations);

            _service = new CoursesServiceProvider(_mockUnitOfWork);
        }
Example #8
0
 public CoursesController()
 {
     _service = new CoursesServiceProvider(new UnitOfWork <AppDataContext>());
 }
Example #9
0
        public CourseServicesTests()
        {
            _mockUnitOfWork = new MockUnitOfWork <MockDataContext>();

            #region Persons
            var persons = new List <Person>
            {
                new Person
                {
                    ID    = 1,
                    Name  = NAME_DABS,
                    SSN   = SSN_DABS,
                    Email = "*****@*****.**"
                },
                new Person
                {
                    ID    = 2,
                    Name  = NAME_GUNNA,
                    SSN   = SSN_GUNNA,
                    Email = "*****@*****.**"
                },
                new Person
                {
                    ID    = 3,
                    Name  = NAME_KHF,
                    SSN   = SSN_KHF,
                    Email = "*****@*****.**"
                }
            };
            #endregion

            #region Course templates

            var courseTemplates = new List <CourseTemplate>
            {
                new CourseTemplate
                {
                    CourseID    = "T-514-VEFT",
                    Description = "Í þessum áfanga verður fjallað um vefþj...",
                    Name        = "Vefþjónustur"
                },
                new CourseTemplate
                {
                    CourseID    = "T-111-PROG",
                    Description = "Í þessum áfanga verður fjallað um forritun...",
                    Name        = "Forritun"
                }
            };
            #endregion

            #region Courses
            var courses = new List <CourseInstance>
            {
                new CourseInstance
                {
                    ID         = COURSEID_VEFT_20143,
                    CourseID   = "T-514-VEFT",
                    SemesterID = "20143"
                },
                new CourseInstance
                {
                    ID         = COURSEID_VEFT_20153,
                    CourseID   = "T-514-VEFT",
                    SemesterID = "20153"
                },
                new CourseInstance
                {
                    ID         = COURSEID_VEFT_20163,
                    CourseID   = "T-514-VEFT",
                    SemesterID = "20163"
                },
                new CourseInstance
                {
                    ID         = COURSEID_PROG_20163,
                    CourseID   = "T-111-PROG",
                    SemesterID = "20163"
                }
            };
            #endregion

            #region Teacher registrations
            _teacherRegistrations = new List <TeacherRegistration>
            {
                new TeacherRegistration
                {
                    ID = 101,
                    CourseInstanceID = COURSEID_VEFT_20153,
                    SSN  = SSN_DABS,
                    Type = TeacherType.MainTeacher
                },
                new TeacherRegistration
                {
                    ID = 102,
                    CourseInstanceID = COURSEID_PROG_20163,
                    SSN  = SSN_KHF,
                    Type = TeacherType.AssistantTeacher
                }
            };
            #endregion

            _mockUnitOfWork.SetRepositoryData(persons);
            _mockUnitOfWork.SetRepositoryData(courseTemplates);
            _mockUnitOfWork.SetRepositoryData(courses);
            _mockUnitOfWork.SetRepositoryData(_teacherRegistrations);

            _service = new CoursesServiceProvider(_mockUnitOfWork);
        }