Beispiel #1
0
        public void TestWipeDataDatabase1Ok()
        {
            //SETUP
            var options = this.CreateUniqueMethodOptions <DbContext1>();

            using (var context = new DbContext1(options))
            {
                context.Database.EnsureCreated();
                context.Add(new TopClass1 {
                    Dependents = new List <Dependent1> {
                        new Dependent1()
                    }
                });
                context.SaveChanges();
                context.TopClasses.Count().ShouldEqual(1);
                context.Dependents.Count().ShouldEqual(1);

                //ATTEMPT
                context.Database.EnsureClean();

                //VERIFY
                context.TopClasses.Count().ShouldEqual(0);
                context.Dependents.Count().ShouldEqual(0);
            }
        }
Beispiel #2
0
        public void TestEnsureDeletedThenCreateDatabase1Ok()
        {
            //SETUP
            var showLog = false;

#pragma warning disable 618
            var options = this.CreateUniqueClassOptionsWithLogging <DbContext1>(log =>
#pragma warning restore 618
            {
                if (showLog)
                {
                    _output.WriteLine(log.Message);
                }
            });
            using (var context = new DbContext1(options))
            {
                context.Database.EnsureDeleted();

                //ATTEMPT
                showLog = true;
                context.Database.EnsureClean();
                showLog = false;

                //VERIFY
                context.Add(new TopClass1());
                context.SaveChanges();
            }
        }