Beispiel #1
0
 public void DefaultValues()
 {
     Subject subject = new Subject();
     Assert.AreEqual(Subject.DefaultTitle, subject.Title);
     Assert.IsNotNull(subject.Lessons);
     Assert.AreEqual(0, subject.Lessons.Count);
 }
Beispiel #2
0
        public void CreateSubjectInDB()
        {
            Subject subject = new Subject { Title = "The title" };
            SaveOrUpdate(subject);

            using (this.Session.BeginTransaction()) {
                var dbSubjects = Retrieve<Subject>();
                Assert.AreEqual(1, dbSubjects.Count);
                Assert.AreEqual(subject.Title, dbSubjects[0].Title);
            }
        }
Beispiel #3
0
        public void DefaultValuesFromDB()
        {
            Subject subject = new Subject();
            SaveOrUpdate(subject);

            using (this.Session.BeginTransaction()) {
                var dbSubjects = Retrieve<Subject>();
                Assert.AreEqual(Subject.DefaultTitle, dbSubjects[0].Title);
                Assert.IsNotNull(dbSubjects[0].Lessons);
                Assert.AreEqual(0, dbSubjects[0].Lessons.Count);
            }
        }
Beispiel #4
0
        public void CheckCascadeWithLessons()
        {
            Subject subject = new Subject { Title = "The title" };
            Lesson lesson = new Lesson { Title = "Card title" };
            subject.AddLesson(lesson);

            SaveOrUpdate(subject);

            using (this.Session.BeginTransaction()) {
                var dbSubjects = Retrieve<Subject>();
                Assert.AreEqual(1, dbSubjects[0].Lessons.Count);
                Assert.AreEqual(lesson.Title, dbSubjects[0].Lessons[0].Title);
            }
        }
Beispiel #5
0
        private void CreateSubject(object sender, EventArgs e)
        {
            var questionDialog = new QuestionDialog("Subject");
            if (questionDialog.Run(treeView.ParentWindow) == Command.Ok) {
                var subject = new Subject { Title = questionDialog.Result };
                DatabaseManager.Instance.SaveOrUpdate(subject);

                AddSubject(subject);
            }

            questionDialog.Dispose();
        }
Beispiel #6
0
        private void AddSubject(Subject subject)
        {
            var navigator = store.AddNode()
                .SetValue(imageCol, SubjectIcon)
                .SetValue(nameCol, subject.Title)
                .SetValue(subjectCol, subject);

            foreach (var lesson in subject.Lessons)
                AddLesson(navigator, lesson);
        }
Beispiel #7
0
        public void IntegrationWithLessons()
        {
            Subject subject = new Subject();
            Lesson lesson = new Lesson { Title = "Lesson title" };
            subject.AddLesson(lesson);

            Assert.AreEqual(1, subject.Lessons.Count);
            Assert.AreSame(lesson, subject.Lessons[0]);
            Assert.AreSame(subject, lesson.Subject);
        }
Beispiel #8
0
 public void TryToSetNullTitle()
 {
     Subject subject = new Subject();
     subject.Title = null;
     Assert.IsNotNull(subject.Title);
     Assert.AreEqual(Subject.DefaultTitle, subject.Title);
 }
Beispiel #9
0
 public void TryToSetEmptyTitle()
 {
     Subject subject = new Subject();
     subject.Title = string.Empty;
     Assert.IsNotNullOrEmpty(subject.Title);
     Assert.AreEqual(Subject.DefaultTitle, subject.Title);
 }
Beispiel #10
0
 public void PropertiesExist()
 {
     Subject subject = new Subject { Title = "A subject" };
     Assert.AreEqual("A subject", subject.Title);
     Assert.AreEqual(0, subject.Lessons.Count);
 }