Esempio n. 1
0
        public void TestSoftDeleteServiceResetSoftDeleteNoCallSaveChangesOk()
        {
            //SETUP
            var options = SqliteInMemory.CreateOptions <SingleSoftDelDbContext>();

            using (var context = new SingleSoftDelDbContext(options))
            {
                context.Database.EnsureCreated();
                var book = context.AddBookWithReviewToDb();

                var config  = new ConfigSoftDeleteWithUserId(context);
                var service = new SingleSoftDeleteService <ISingleSoftDelete>(context, config);
                service.SetSoftDelete(book);

                //ATTEMPT
                var status = service.ResetSoftDelete(book, false);
                context.Books.Count().ShouldEqual(0);
                context.SaveChanges();
                context.Books.Count().ShouldEqual(1);

                //VERIFY
                status.IsValid.ShouldBeTrue(status.GetAllErrors());
                status.Result.ShouldEqual(1);
                context.Books.IgnoreQueryFilters().Count().ShouldEqual(1);
            }
        }
Esempio n. 2
0
        public void TestSoftDeleteServiceDddResetSoftDeleteOk()
        {
            //SETUP
            var options = SqliteInMemory.CreateOptions <SingleSoftDelDbContext>();

            using (var context = new SingleSoftDelDbContext(options))
            {
                context.Database.EnsureCreated();
                context.Database.EnsureCreated();
                var bookDdd = new BookDDD("Test");
                context.Add(bookDdd);
                context.SaveChanges();

                var config  = new ConfigSoftDeleteDDD();
                var service = new SingleSoftDeleteService <ISingleSoftDeletedDDD>(context, config);
                service.SetSoftDelete(bookDdd);

                //ATTEMPT
                var status = service.ResetSoftDelete(bookDdd);

                //VERIFY
                status.IsValid.ShouldBeTrue(status.GetAllErrors());
                status.Result.ShouldEqual(1);
            }
            using (var context = new SingleSoftDelDbContext(options))
            {
                context.BookDdds.Count().ShouldEqual(1);
                context.BookDdds.IgnoreQueryFilters().Count().ShouldEqual(1);
            }
        }
        public void TestResetSoftDeleteOk()
        {
            //SETUP
            var options = SqliteInMemory.CreateOptions <SingleSoftDelDbContext>();

            using var context = new SingleSoftDelDbContext(options);
            context.Database.EnsureCreated();
            var shadowClass = new ShadowDelClass();

            context.Add(shadowClass);
            context.Entry(shadowClass).Property("SoftDeleted").CurrentValue = true;
            context.SaveChanges();

            var config  = new ConfigSoftDeleteShadowDel(context);
            var service = new SingleSoftDeleteService <IShadowSoftDelete>(config);

            //ATTEMPT
            var status = service.ResetSoftDelete(shadowClass);

            //VERIFY
            status.IsValid.ShouldBeTrue(status.GetAllErrors());
            status.Result.ShouldEqual(1);
            context.ShadowDelClasses.Count().ShouldEqual(1);
        }