public void AddChildWithoutParent() { var image = new Image(); Assert.That(() => _images.Add(image), Throws.Exception.TypeOf<ForginKeyConstraintException>()); }
public void ParentWithChild() { var book = new Book(); _books.Add(book); var image = new Image(); image.IdBook = book.BookId; _books.Remove(book); Assert.That(() => _images.Add(image), Throws.Exception.TypeOf<ForginKeyConstraintException>()); }
public void AddChildWithoutParent() { var image = new Image(); Assert.That(() => { using (var transaction = new TransactionScope()) { Assert.That(() => _images.Add(image), Throws.Nothing); transaction.Complete(); } }, Throws.Exception.TypeOf<ForginKeyConstraintException>()); }
public void ParentWithChild() { Assert.That(() => { using (var transaction = new TransactionScope()) { var book = new Book(); _books.Add(book); var image = new Image(); image.IdBook = book.BookId; _books.Remove(book); Assert.That(() => _images.Add(image), Throws.Nothing); transaction.Complete(); } }, Throws.Exception.TypeOf<ForginKeyConstraintException>()); }
public void RemoveParentWithChild() { var book = new Book(); _books.Add(book); var image = new Image(); image.IdBook = book.BookId; _images.Add(image); Assert.AreNotEqual(book.BookId, 0); Assert.AreNotEqual(image.ImageId, 0); Assert.AreNotEqual(_books.Count, 0); Assert.AreNotEqual(_images.Count, 0); Assert.IsTrue(_images.Remove(image)); Assert.IsTrue(_books.Remove(book)); Assert.AreEqual(_books.Count, 0); Assert.AreEqual(_images.Count, 0); }
public void IdentityInsertAutoSetUninit() { Assert.That(() => { using (var transaction = new TransactionScope()) { using (new IdentityInsertScope(true)) { var image = new Image(); image.ImageId = 10; _images.Add(image); var book = new Book(); _books.Add(book); image.IdBook = book.BookId; Assert.That(book.BookId, Is.EqualTo(1)); Assert.That(image.ImageId, Is.EqualTo(10)); Assert.AreNotEqual(_books.Count, 0); Assert.AreNotEqual(_images.Count, 0); transaction.Complete(); } } }, Throws.Nothing); }
public void AddMultibeItems() { Assert.That(() => { using (var transaction = new TransactionScope()) { var image = new Image(); _images.Add(image); var book = new Book(); _books.Add(book); image.IdBook = book.BookId; Assert.AreNotEqual(book.BookId, 0); Assert.AreNotEqual(image.ImageId, 0); Assert.AreNotEqual(_books.Count, 0); Assert.AreNotEqual(_images.Count, 0); transaction.Complete(); } }, Throws.Nothing); }