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); }
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); } }
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); } }
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); } }
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); } }
private void AddLesson(TreeNavigator navigator, Lesson lesson) { navigator.AddChild() .SetValue(imageCol, LessonIcon) .SetValue(nameCol, lesson.Title) .SetValue(subjectCol, lesson.Subject) .SetValue(lessonCol, lesson) .MoveToParent(); }
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(); }
public virtual void AddLesson(Lesson lesson) { lesson.Subject = this; this.Lessons.Add(lesson); }
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); }
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); }
public void TryToSetNullTitle() { Lesson lesson = new Lesson(); lesson.Title = null; Assert.IsNotNull(lesson.Title); Assert.AreEqual(Lesson.DefaultTitle, lesson.Title); }
public void TryToSetEmptyTitle() { Lesson lesson = new Lesson(); lesson.Title = string.Empty; Assert.IsNotNullOrEmpty(lesson.Title); Assert.AreEqual(Lesson.DefaultTitle, lesson.Title); }
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); }