示例#1
0
        public void TestGetSoftDeletedEntriesEmployeeSoftDeletedOk()
        {
            //SETUP
            var options = SqliteInMemory.CreateOptions <CascadeSoftDelDbContext>();

            using (var context = new CascadeSoftDelDbContext(options))
            {
                context.Database.EnsureCreated();
                var ceo = Employee.SeedEmployeeSoftDel(context);

                var config  = new ConfigCascadeDeleteWithUserId(context);
                var service = new CascadeSoftDelService <ICascadeSoftDelete>(config);
                service.SetCascadeSoftDelete(ceo.WorksFromMe.First()).IsValid.ShouldBeTrue();

                //ATTEMPT
                var softDeleted = service.GetSoftDeletedEntries <Employee>().ToList();

                //VERIFY
                softDeleted.Count.ShouldEqual(1);
                softDeleted.Single().Name.ShouldEqual(ceo.WorksFromMe.First().Name);
            }
        }
示例#2
0
        public void TestGetSoftDeletedEntriesCompanyOk()
        {
            //SETUP
            var userId  = Guid.NewGuid();
            var options = SqliteInMemory.CreateOptions <CascadeSoftDelDbContext>();

            using (var context = new CascadeSoftDelDbContext(options, userId))
            {
                context.Database.EnsureCreated();
                var customer = Customer.SeedCustomerWithQuotes(context, userId);

                var config  = new ConfigCascadeDeleteWithUserId(context);
                var service = new CascadeSoftDelService <ICascadeSoftDelete>(config);
                var status  = service.SetCascadeSoftDelete(customer);

                //ATTEMPT
                var softDeleted = service.GetSoftDeletedEntries <Customer>().ToList();

                //VERIFY
                softDeleted.Count.ShouldEqual(1);
                softDeleted.Single().CompanyName.ShouldEqual(customer.CompanyName);
            }
        }
示例#3
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);
        }