Ejemplo n.º 1
0
        public void LoadInListItemProprieties()
        {
            var t = new TodoItem
            {
                Priority    = 4,
                Description = "test",
                DueDate     = new DateTime(1999, 9, 13),
                Category    = new Category {
                    Description = "new category"
                }
            };

            t.AddComment(new TodoComment {
                Text = "comment 1"
            });
            t.AddComment(new TodoComment {
                Text = "comment 2"
            });

            _todoItemRepository.Add(t);
            _todoItemRepository.SaveChanges();
            Assert.AreNotEqual(0, t.Id);

            var newRepo = _kernel.Get <ITodoItemRepository>();

            var t2 = newRepo.FindAll().First(it => it.Id == t.Id);

            Assert.AreEqual(t.Category.Id, t2.Category.Id);
            Assert.AreEqual(2, t2.Comments.Count);
            Assert.AreEqual(t.Comments.ToArray()[0].Id, t2.Comments.ToArray()[0].Id);
            Assert.AreEqual(t.Comments.ToArray()[1].Id, t2.Comments.ToArray()[1].Id);

            Assert.AreSame(t2, t2.Comments.ToArray()[0].TodoItem);
        }
Ejemplo n.º 2
0
        public void CascadeDelete()
        {
            var t = new TodoItem
            {
                Priority    = 4,
                Description = "test",
                DueDate     = new DateTime(1999, 9, 13),
                Category    = new Category {
                    Description = "new category"
                }
            };

            t.AddComment(new TodoComment {
                Text = "comment 1"
            });
            t.AddComment(new TodoComment {
                Text = "comment 2"
            });

            _todoItemRepository.Add(t);
            _todoItemRepository.SaveChanges();

            _todoItemRepository.Remove(t);
            _todoItemRepository.SaveChanges();

            var newRepo = _kernel.Get <ITodoItemRepository>();

            Assert.IsNull(newRepo.FindById(t.Id));
        }
Ejemplo n.º 3
0
        public void CreateTodoItemWithComments()
        {
            var t = new TodoItem {
                Priority = 4, Description = "test", DueDate = new DateTime(1999, 9, 13)
            };

            t.AddComment(new TodoComment()
            {
                Text = "test comment 1"
            });
            t.AddComment(new TodoComment()
            {
                Text = "test comment 2"
            });
            _todoItemRepository.Add(t);
            _todoItemRepository.SaveChanges();
            Assert.AreNotEqual(0, t.Id);

            foreach (var comment in t.Comments)
            {
                Assert.AreNotEqual(0, comment.Id);
            }
        }