コード例 #1
0
        public void CreateActivityTeacherRelationsTest()
        {
            using (var conn = Effort.DbConnectionFactory.CreateTransient())
            {
                var model = new DataModel(conn);

                using (var context = new DatabaseHelperExposer(model))
                {
                    // Create activity / teacher relations
                    var tt = CreateTimetable();
                    context.CreateActivityTeacherRelations(model, 2, tt.Activities[0].Resource);

                    // Get timetable entries
                    var ttEntry       = from a in model.TimetableActivityTeachers orderby a.Id select a;
                    var teacherEntry1 = ttEntry.First();
                    var teacherEntry2 = ttEntry.Skip(1).First();

                    // Check first teacher
                    Assert.AreEqual(2, teacherEntry1.ActivityId);
                    Assert.AreEqual(59, teacherEntry1.TeacherId);

                    // Check second teacher
                    Assert.AreEqual(2, teacherEntry2.ActivityId);
                    Assert.AreEqual(60, teacherEntry2.TeacherId);
                }
            }
        }
コード例 #2
0
        public void CreateActivitiesTest()
        {
            using (var conn = Effort.DbConnectionFactory.CreateTransient())
            {
                var model = new DataModel(conn);

                using (var context = new DatabaseHelperExposer(model))
                {
                    // Create activities
                    var tt = CreateTimetable();
                    context.CreateActivities(model, 1000, tt);

                    // Get timetable entry
                    var ttEntry = from a in model.TimetableActivities select a;

                    // Verify timetable ID matches
                    Assert.AreEqual(1000, ttEntry.First().TimetableId);

                    // Verify Day is parsed correctly and matches
                    Assert.AreEqual(5, ttEntry.First().Day);

                    // Verify timeslot is parsed correctly and matches
                    Assert.AreEqual(9, ttEntry.First().Timeslot);

                    // Verify subject matches
                    Assert.AreEqual(2, ttEntry.First().SubjectId);

                    // Verify collection params match
                    Assert.AreEqual(true, ttEntry.First().IsCollection);
                    Assert.AreEqual(259, ttEntry.First().CollectionId);
                }
            }
        }