public void Borrower_ShouldPersistAndRecall()
        {
            //---------------Set up test pack-------------------
            var borrower = new BorrowerBuilder()
                                .WithRandomProps()
                                .WithProp(b => b.Id = 0)
                                .WithValidTitleId()
                                .Build();
            //---------------Assert Precondition----------------

            using (var ctx = new LendingLibraryDbContext(_localDb.CreateConnection()))
            {
                //ctx.Set<Borrower>().Add(borrower);
                //ctx.Set(typeof (Borrower)).Add(borrower);
                //ctx.Set(borrower.GetType()).Add(borrower);
                //ctx.Entry(borrower).State = EntityState.Added;

                ctx.Borrowers.Add(borrower);
                ctx.SaveChanges();
            }

            using (var ctx = new LendingLibraryDbContext(_localDb.CreateConnection()))
            {
                //---------------Execute Test ----------------------
                var result = ctx.Set<Borrower>().Single();
                //---------------Test Result -----------------------
                PropertyAssert.AllPropertiesAreEqual(borrower, result, "Title");
            }

          
        }
Example #2
0
 public BookController(LendingLibraryDbContext context)
 {
     _context = context;
 }