public void ReadReviewBad() { //SETUP var options = SqliteInMemory.CreateOptions <CtorDbContext>(); using (var context = new CtorDbContext(options, false)) { context.Database.EnsureCreated(); var newEntity = new ReviewBad("John Doe") { NumStars = -1 }; newEntity.VoterName.ShouldEqual("Name: John Doe"); context.Add(newEntity); context.SaveChanges(); } using (var context = new CtorDbContext(options, false)) { //ATTEMPT var entity = context.ReviewBads.Single(); //VERIFY entity.VoterName.ShouldEqual("Name: Name: John Doe"); entity.NumStars.ShouldEqual(-1); } }
public void ReadReviewBadCtor1() { //SETUP var options = SqliteInMemory.CreateOptions <CtorDbContext>(); using var context = new CtorDbContext(options, true); //ATTEMPT var ex = Assert.Throws <InvalidOperationException>(() => context.Database.EnsureCreated()); //VERIFY ex.Message.ShouldStartWith("No suitable constructor found for entity type 'ReviewBadCtor1'."); }
public void ReadReviewsGood2WhichCtorUsed() { //SETUP var options = SqliteInMemory.CreateOptions <CtorDbContext>(); using var context = new CtorDbContext(options, false); context.Database.EnsureCreated(); var newEntity = new ReviewGood2("John Doe", 1); context.Add(newEntity); context.SaveChanges(); context.ChangeTracker.Clear(); //ATTEMPT var entity = context.Review2Goods.Single(); //VERIFY entity.VoterName.ShouldEqual("John Doe"); entity.NumStars.ShouldEqual(1); }