示例#1
0
        public void CheckCascadeWithImages()
        {
            Image image = new Image { Name = "The Image" };
            Card card = new Card { Title = "Test Image in DB" };
            card.AddImage(image);

            SaveOrUpdate(card);

            using (this.Session.BeginTransaction()) {
                var dbCards = Retrieve<Card>();
                Assert.AreEqual(1, dbCards[0].Images.Count);
                Assert.AreEqual(image.Name, dbCards[0].Images[0].Name);
            }
        }
示例#2
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);
            }
        }
示例#3
0
 public void DefaultValues()
 {
     Card card = new Card();
     Assert.AreEqual(Card.DefaultTitle, card.Title);
     Assert.IsNull(card.Description);
     Assert.IsNotNull(card.Images);
     Assert.AreEqual(0, card.Images.Count);
     Assert.AreNotEqual(new DateTime(), card.CreationDate);
     Assert.AreEqual(0, card.Points);
     Assert.AreEqual(Card.DefaultTargetPoints, card.TargetPoints);
     Assert.AreEqual(0, card.GroupId);
     Assert.AreEqual(card.CreationDate, card.GroupChangeDate);
     Assert.IsNull(card.Lesson);
     Assert.IsTrue(card.Visible);
 }
示例#4
0
        public void CreateCardInDB()
        {
            Card card = new Card {
                Title = "My Card",
                Description = "Description",
            };

            SaveOrUpdate(card);

            using (this.Session.BeginTransaction()) {
                var dbCard = Retrieve<Card>();
                Assert.AreEqual(1, dbCard.Count);
                Assert.AreEqual(card.Title, dbCard[0].Title);
                Assert.AreEqual(card.Description, dbCard[0].Description);
                Assert.AreEqual(card.CreationDate, dbCard[0].CreationDate);
                Assert.AreEqual(card.Points, dbCard[0].Points);
                Assert.AreEqual(card.TargetPoints, dbCard[0].TargetPoints);
                Assert.AreEqual(card.GroupId, dbCard[0].GroupId);
                Assert.AreEqual(card.GroupChangeDate, dbCard[0].GroupChangeDate);
                Assert.AreEqual(card.Visible, dbCard[0].Visible);
            }
        }
示例#5
0
 public virtual void AddCard(Card card)
 {
     card.Lesson = this;
     this.Cards.Add(card);
 }
示例#6
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);
        }
示例#7
0
        public void DefaultValuesFromDB()
        {
            Card card = new Card();
            SaveOrUpdate(card);

            using (this.Session.BeginTransaction()) {
                var dbCards = Retrieve<Card>();
                Assert.AreEqual(Card.DefaultTitle, dbCards[0].Title);
                Assert.IsNull(dbCards[0].Description);
                Assert.IsNotNull(dbCards[0].Images);
                Assert.AreEqual(0, dbCards[0].Images.Count);
                Assert.AreNotEqual(new DateTime(), dbCards[0].CreationDate);
                Assert.AreEqual(0, dbCards[0].Points);
                Assert.AreEqual(Card.DefaultTargetPoints, dbCards[0].TargetPoints);
                Assert.AreEqual(0, dbCards[0].GroupId);
                Assert.AreEqual(dbCards[0].CreationDate, dbCards[0].GroupChangeDate);
                Assert.IsNull(dbCards[0].Lesson);
                Assert.IsTrue(dbCards[0].Visible);
            }
        }
示例#8
0
 public void TryToSetNullTitle()
 {
     Card card = new Card();
     card.Title = null;
     Assert.IsNotNull(card.Title);
     Assert.AreEqual(Card.DefaultTitle, card.Title);
 }
示例#9
0
        public void TouchDate()
        {
            Card card = new Card();
            DateTime initialDate = card.GroupChangeDate;

            card.TouchDate();
            Assert.Greater(card.GroupChangeDate, initialDate);
        }
示例#10
0
 public void TryToSetEmptyTitle()
 {
     Card card = new Card();
     card.Title = string.Empty;
     Assert.IsNotNullOrEmpty(card.Title);
     Assert.AreEqual(Card.DefaultTitle, card.Title);
 }
示例#11
0
        public void ResetPoints()
        {
            Card card = new Card();
            Assert.DoesNotThrow(card.ResetPoints);
            Assert.AreEqual(0, card.Points);
            Assert.AreEqual(0, card.GroupId);

            while (card.GroupId == 0)
                card.GivePoint();
            var cardDate = card.GroupChangeDate;

            card.ResetPoints();
            Assert.AreEqual(0, card.Points);
            Assert.AreEqual(0, card.GroupId);
            Assert.AreNotEqual(cardDate, card.GroupChangeDate);
        }
示例#12
0
        public void PropertiesExist()
        {
            Card card = new Card {
                Title = "My Card",
                Description = "Description",
                TargetPoints = 3
            };

            Assert.AreEqual("My Card", card.Title);
            Assert.AreEqual("Description", card.Description);
            Assert.IsInstanceOf<DateTime>(card.CreationDate);
            Assert.AreEqual(0, card.Points);
            Assert.AreEqual(3, card.TargetPoints);
            Assert.AreEqual(0, card.GroupId);
            Assert.IsInstanceOf<DateTime>(card.GroupChangeDate);
            Assert.AreEqual(0, card.Images.Count);
            Assert.IsNull(card.Lesson);
            Assert.IsTrue(card.Visible);
        }
示例#13
0
        public void IsCompleted()
        {
            Card card = new Card();
            while (card.GroupId < Card.PointsForComplete) {
                Assert.IsFalse(card.IsComplete());
                card.GivePoint();
            }

            Assert.IsTrue(card.IsComplete());

            card.GivePoint();
            Assert.IsTrue(card.IsComplete());
        }
示例#14
0
        public void IntegrationWithImages()
        {
            Image image = new Image { Name = "My Image" };

            Card card = new Card();
            card.AddImage(image);

            Assert.AreEqual(1, card.Images.Count);
            Assert.AreSame(image, card.Images[0]);
        }
示例#15
0
        public void GivePoint()
        {
            Card card = new Card { TargetPoints = 2 };
            DateTime initialDate = card.GroupChangeDate;

            Assert.AreEqual(0, card.Points);
            Assert.AreEqual(0, card.GroupId);
            Assert.AreEqual(initialDate, card.GroupChangeDate);

            card.GivePoint();
            Assert.AreEqual(1, card.Points);
            Assert.AreEqual(0, card.GroupId);
            Assert.AreEqual(initialDate, card.GroupChangeDate);

            card.GivePoint();
            Assert.AreEqual(0, card.Points);
            Assert.AreEqual(1, card.GroupId);
            Assert.Greater(card.GroupChangeDate, initialDate);
        }