Ejemplo n.º 1
0
 public ConfigCascadeDeleteShadowDel(CascadeSoftDelDbContext context)
     : base(context)
 {
     GetSoftDeleteValue   = entity => (byte)context.Entry(entity).Property("SoftDeleteLevel").CurrentValue;
     QuerySoftDeleteValue = entity => EF.Property <byte>(entity, "SoftDeleteLevel");
     SetSoftDeleteValue   = (entity, value) => context.Entry(entity).Property("SoftDeleteLevel").CurrentValue = value;
 }
Ejemplo n.º 2
0
        public void TestManuallySoftDeleteOk()
        {
            //SETUP
            var options = SqliteInMemory.CreateOptions <CascadeSoftDelDbContext>();

            using var context = new CascadeSoftDelDbContext(options);
            context.Database.EnsureCreated();
            var shadowClass = new ShadowCascadeDelClass();

            context.Add(shadowClass);
            context.SaveChanges();

            //ATTEMPT
            context.Entry(shadowClass).Property("SoftDeleteLevel").CurrentValue = (byte)1;
            context.SaveChanges();

            //VERIFY
            context.ShadowCascadeDelClasses.Count().ShouldEqual(0);
            context.ShadowCascadeDelClasses.IgnoreQueryFilters().Count().ShouldEqual(1);
        }
Ejemplo n.º 3
0
        public void TestResetSoftDeleteOk()
        {
            //SETUP
            var options = SqliteInMemory.CreateOptions <CascadeSoftDelDbContext>();

            using var context = new CascadeSoftDelDbContext(options);
            context.Database.EnsureCreated();
            var shadowClass = new ShadowCascadeDelClass();

            context.Add(shadowClass);
            context.Entry(shadowClass).Property("SoftDeleteLevel").CurrentValue = (byte)1;
            context.SaveChanges();

            var config  = new ConfigCascadeDeleteShadowDel(context);
            var service = new CascadeSoftDelService <IShadowCascadeSoftDelete>(config);

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

            //VERIFY
            status.IsValid.ShouldBeTrue(status.GetAllErrors());
            status.Result.ShouldEqual(1);
            context.ShadowCascadeDelClasses.Count().ShouldEqual(1);
        }
Ejemplo n.º 4
0
        public void TestGetSoftDeleteOk()
        {
            //SETUP
            var options = SqliteInMemory.CreateOptions <CascadeSoftDelDbContext>();

            using var context = new CascadeSoftDelDbContext(options);
            context.Database.EnsureCreated();
            var shadowClass = new ShadowCascadeDelClass();

            context.Add(shadowClass);
            context.Entry(shadowClass).Property("SoftDeleteLevel").CurrentValue = (byte)1;
            context.SaveChanges();

            context.ChangeTracker.Clear();

            var config  = new ConfigCascadeDeleteShadowDel(context);
            var service = new CascadeSoftDelService <IShadowCascadeSoftDelete>(config);

            //ATTEMPT
            var entities = service.GetSoftDeletedEntries <ShadowCascadeDelClass>().ToList();

            //VERIFY
            entities.Count().ShouldEqual(1);
        }