예제 #1
0
        public void Setup()
        {
            _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 = "*****@*****.**"
                }
            };
            #endregion

            #region Course templates

            var courseTemplates = new List<CourseTemplate>
            {
                new CourseTemplate
                {
                    CourseID    = COURSE_TEMPLID_VEFT,
                    Description = "Í þessum áfanga verður fjallað um vefþj...",
                    Name        = COURSE_NAME_VEFT
                },
                new CourseTemplate
                {
                    CourseID    = COURSE_TEMPLID_PROG,
                    Description = "Í þessum áfanga verður fjallað um grunngildi forr...",
                    Name        = COURSE_NAME_PROG
                },
                new CourseTemplate
                {
                    CourseID    = COURSE_TEMPLID_TGRA,
                    Description = "Í þessum áfagna verður fjallað um tölvug...",
                    Name        = COURSE_NAME_TGRA

                }
            };
            #endregion

            #region Courses
            var courses = new List<CourseInstance>
            {
                new CourseInstance
                {
                    ID         = COURSEID_VEFT_20153,
                    CourseID   = COURSE_TEMPLID_VEFT,
                    SemesterID = "20153"
                },
                new CourseInstance
                {
                    ID         = COURSEID_VEFT_20163,
                    CourseID   = COURSE_TEMPLID_VEFT,
                    SemesterID = "20163"
                },
                new CourseInstance
                {
                    ID         = COURSEID_PROG_20153,
                    CourseID   = COURSE_TEMPLID_PROG,
                    SemesterID = "20153"
                },
                new CourseInstance
                {
                    ID         = COURSEID_TGRA_20153,
                    CourseID   = COURSE_TEMPLID_TGRA,
                    SemesterID = "20153"
                },
                new CourseInstance
                {
                    ID         = COURSEID_TGRA_20157,
                    CourseID   = COURSE_TEMPLID_TGRA,
                    SemesterID = "20173"
                }
            };
            #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               = 201,
                    CourseInstanceID = COURSEID_TGRA_20153,
                    SSN              = SSN_GUNNA,
                    Type             = TeacherType.MainTeacher
                }
            };
            #endregion

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

            _service = new CoursesServiceProvider(_mockUnitOfWork);
        }
예제 #2
0
 public CoursesController()
 {
     _service = new CoursesServiceProvider(new UnitOfWork<AppDataContext>());
 }
예제 #3
0
        public void GetCoursesBySemester_ReturnsEmptyListWhenNoDataDefined()
        {
            // Arrange:
            MockUnitOfWork<MockDataContext> _mockUnitOfWorkWithNoDataDefined = new MockUnitOfWork<MockDataContext>();
            CoursesServiceProvider _serviceWithNoDataDefined = new CoursesServiceProvider(_mockUnitOfWorkWithNoDataDefined);
            const string SEMESTER = "20153";

            // Act:
            var result = _serviceWithNoDataDefined.GetCourseInstancesBySemester(SEMESTER);

            // Assert:
            Assert.AreEqual(0, result.Count);
            Assert.AreEqual(false, result.Any());
        }
예제 #4
0
		public void Setup()
		{
			_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"
				},
                new CourseTemplate
                {
                    CourseID     = "T-409-TSAM",
                    Description  = "Í þessum áfanga verður fjallað um tölvusamskipti..",
                    Name         = "Tölvusamskipti"
                },
                new CourseTemplate
                {
                    CourseID    = "T-302-HONN",
                    Description = "Í þessum áfanga..",
                    Name        = "Hönnun og smíði hugbúnaðar"
                }
			};
			#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"
				},
                new CourseInstance
                {
                    ID = COURSEID_TSAM_20153,
                    CourseID = "T-409-TSAM",
                    SemesterID = "20153"
                },
                new CourseInstance
                {
                    ID = COURSEID_HONN_20153,
                    CourseID = "T-302-HONN",
                    SemesterID = "20153"
                }
			};
			#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_HONN_20153,
                    SSN              = SSN_GUNNA,
                    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);
		}
        public void Setup()
        {
            _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_MARCEL,
                    SSN   = SSN_MARCEL,
                    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-409-TSAM",
                    Description = "Í þessum áfanga verður fjallað um samskipti...",
                    Name        = "Tölvusamskipti"
                }
            };
            #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"
                },
                new CourseInstance
                {
                    ID         = COURSEID_TSAM_20153,
                    CourseID   = "T-409-TSAM",
                    SemesterID = "20153"
                }
            };
            #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);

            _service = new CoursesServiceProvider(_mockUnitOfWork);
        }
예제 #6
0
		public void Setup()
		{
			_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 = "*****@*****.**"
				},
                new Person
                {
                    ID      = 3,
                    Name    = "Hrafn Loftsson",
                    SSN     = SSN_HRAFN,
                    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 = "Fyrstu skref í forritun...",
                    Name        = "Forritun"
                }
			};
            #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"
                },
                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_HRAFN,
                    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);
		}
        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);
        }