Example #1
0
 public void DefaultValues()
 {
     Lesson lesson = new Lesson();
     Assert.AreEqual(Lesson.DefaultTitle, lesson.Title);
     Assert.IsNotNull(lesson.Cards);
     Assert.AreEqual(0, lesson.Cards.Count);
     Assert.IsNull(lesson.Subject);
 }
Example #2
0
        public void CreateLessonInDB()
        {
            Lesson lesson = new Lesson { Title = "The title" };
            SaveOrUpdate(lesson);

            using (this.Session.BeginTransaction()) {
                var dbLessons = Retrieve<Lesson>();
                Assert.AreEqual(1, dbLessons.Count);
                Assert.AreEqual(lesson.Title, dbLessons[0].Title);
            }
        }
Example #3
0
        public void DefaultValuesFromDB()
        {
            Lesson lesson = new Lesson();
            SaveOrUpdate(lesson);

            using (this.Session.BeginTransaction()) {
                var dbLessons = Retrieve<Lesson>();
                Assert.AreEqual(Lesson.DefaultTitle, dbLessons[0].Title);
                Assert.IsNotNull(dbLessons[0].Cards);
                Assert.AreEqual(0, dbLessons[0].Cards.Count);
                Assert.IsNull(dbLessons[0].Subject);
            }
        }
Example #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);
            }
        }
Example #5
0
        public void CheckCascadeWithCards()
        {
            Lesson lesson = new Lesson { Title = "The title" };
            Card card = new Card { Title = "Card title" };
            lesson.AddCard(card);

            SaveOrUpdate(lesson);

            using (this.Session.BeginTransaction()) {
                var dbLessons = Retrieve<Lesson>();
                Assert.AreEqual(1, dbLessons[0].Cards.Count);
                Assert.AreEqual(card.Title, dbLessons[0].Cards[0].Title);
            }
        }
Example #6
0
 private void AddLesson(TreeNavigator navigator, Lesson lesson)
 {
     navigator.AddChild()
         .SetValue(imageCol, LessonIcon)
         .SetValue(nameCol, lesson.Title)
         .SetValue(subjectCol, lesson.Subject)
         .SetValue(lessonCol, lesson)
         .MoveToParent();
 }
Example #7
0
        private void CreateLesson(object sender, EventArgs e)
        {
            var questionDialog = new QuestionDialog("Lesson");
            if (questionDialog.Run(treeView.ParentWindow) == Command.Ok) {
                var lesson = new Lesson { Title = questionDialog.Result };

                // Append lesson to the current selected subject
                var subjectNavigator = SearchSubjectNode();
                var selectedSubject = subjectNavigator.GetValue(subjectCol);
                selectedSubject.AddLesson(lesson);
                DatabaseManager.Instance.SaveOrUpdate(selectedSubject);

                AddLesson(subjectNavigator, lesson);
            }

            questionDialog.Dispose();
        }
Example #8
0
 public virtual void AddLesson(Lesson lesson)
 {
     lesson.Subject = this;
     this.Lessons.Add(lesson);
 }
Example #9
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);
        }
Example #10
0
        public void IntegrationWithCards()
        {
            Lesson lesson = new Lesson();
            Card card = new Card { Title = "Card title" };
            lesson.AddCard(card);

            Assert.AreEqual(1, lesson.Cards.Count);
            Assert.AreSame(card, lesson.Cards[0]);
            Assert.AreSame(lesson, card.Lesson);
        }
Example #11
0
 public void TryToSetNullTitle()
 {
     Lesson lesson = new Lesson();
     lesson.Title = null;
     Assert.IsNotNull(lesson.Title);
     Assert.AreEqual(Lesson.DefaultTitle, lesson.Title);
 }
Example #12
0
 public void TryToSetEmptyTitle()
 {
     Lesson lesson = new Lesson();
     lesson.Title = string.Empty;
     Assert.IsNotNullOrEmpty(lesson.Title);
     Assert.AreEqual(Lesson.DefaultTitle, lesson.Title);
 }
Example #13
0
        public void PropertiesExist()
        {
            Lesson lesson = new Lesson {
                Title = "A title"
            };

            Assert.AreEqual("A title", lesson.Title);
            Assert.AreEqual(0, lesson.Cards.Count);
            Assert.IsNull(lesson.Subject);
        }