コード例 #1
0
            public void ShouldExecutePostMethodWhenEntityIsAdded()
            {
                _context.AddInterceptor(new PostExecuteInterceptor());

                var book = new Book
                {
                    Name = "Harry Potter and the Goblet of Fire",
                    CreatedAt = DateTime.Now, // Need these for validation...
                    ModifiedAt = DateTime.Now
                };

                _context.Books.Add(book);
                _context.SaveChanges();

                Assert.True(book.IsPostExecuted);
            }
コード例 #2
0
            public void ShouldNotDeleteEntitiesWhenStateIsSetToModifiedDuringInterception()
            {
                _context.AddInterceptor(new SoftDeleteInterceptor());

                var book = new Book
                {
                    Name = "Harry Potter and the Prisoner of Azkaban",
                    CreatedAt = DateTime.Now, // Need these for validation...
                    ModifiedAt = DateTime.Now
                };

                _context.Books.Add(book);
                _context.SaveChanges();

                _context.Books.Remove(book);
                _context.SaveChanges();

                var otherBook = _context.Books.Find(book.Id);

                Assert.Same(book, otherBook);
                Assert.True(book.IsDeleted);
            }