Esempio n. 1
0
        public void NoKill()
        {
            var lf = new LoggerFactory();

            Func <ContentDbContext> dbp = () =>
            {
                var y = new DbContextOptionsBuilder();
                y.UseSqlServer("Data Source=.;Initial Catalog=EksCleanerTests;Integrated Security=True");
                return(new ContentDbContext(y.Options));
            };

            var contentDbContext = dbp();
            var db = contentDbContext.Database;

            db.EnsureDeleted();
            db.EnsureCreated();

            Add(contentDbContext, 15);
            contentDbContext.SaveChanges();

            var fakeDtp = new FakeDtp()
            {
                Snapshot = new DateTime(2020, 6, 20, 0, 0, 0, DateTimeKind.Utc)
            };
            var command = new RemoveExpiredEksCommand(contentDbContext, new FakeEksConfig(), fakeDtp, lf.CreateLogger <RemoveExpiredEksCommand>());

            var result = command.Execute();

            Assert.Equal(1, result.Found);
            Assert.Equal(1, result.Zombies);
            Assert.Equal(0, result.GivenMercy);
            Assert.Equal(1, result.Remaining);
            Assert.Equal(0, result.Reconciliation);
        }
Esempio n. 2
0
        public void Cleaner()
        {
            var lf = new LoggerFactory();

            Func <ContentDbContext> dbp = () =>
            {
                var y = new DbContextOptionsBuilder();
                y.UseSqlServer("Data Source=.;Initial Catalog=EksCleanerTests;Integrated Security=True");
                return(new ContentDbContext(y.Options));
            };

            var db = dbp().Database;

            db.EnsureDeleted();
            db.EnsureCreated();

            var command = new RemoveExpiredEksCommand(dbp(), new FakeEksConfig(), new StandardUtcDateTimeProvider(), lf.CreateLogger <RemoveExpiredEksCommand>());

            var result = command.Execute();

            Assert.Equal(0, result.Found);
            Assert.Equal(0, result.Zombies);
            Assert.Equal(0, result.GivenMercy);
            Assert.Equal(0, result.Remaining);
            Assert.Equal(0, result.Reconciliation);
        }
Esempio n. 3
0
        public void MoreRealistic()
        {
            var lf           = new LoggerFactory();
            var expEksLogger = new ExpiredEksLoggingExtensions(lf.CreateLogger <ExpiredEksLoggingExtensions>());

            var contentDbContext = _contentDbProvider.CreateNew();

            for (var i = 0; i < 20; i++)
            {
                Add(contentDbContext, i);
            }

            contentDbContext.SaveChanges();

            var fakeDtp = new FakeDtp()
            {
                Snapshot = new DateTime(2020, 6, 20, 0, 0, 0, DateTimeKind.Utc)
            };
            var fakeEksConfig = new FakeEksConfig()
            {
                CleanupDeletesData = true
            };
            var command = new RemoveExpiredEksCommand(contentDbContext, fakeEksConfig, fakeDtp, expEksLogger);

            var result = command.Execute();

            Assert.Equal(20, result.Found);
            Assert.Equal(5, result.Zombies);
            Assert.Equal(5, result.GivenMercy);
            Assert.Equal(15, result.Remaining);
            Assert.Equal(0, result.Reconciliation);
        }
Esempio n. 4
0
        public void Cleaner()
        {
            var lf           = new LoggerFactory();
            var expEksLogger = new ExpiredEksLoggingExtensions(lf.CreateLogger <ExpiredEksLoggingExtensions>());

            var command = new RemoveExpiredEksCommand(_contentDbProvider.CreateNew(), new FakeEksConfig(), new StandardUtcDateTimeProvider(), expEksLogger);

            var result = command.Execute();

            Assert.Equal(0, result.Found);
            Assert.Equal(0, result.Zombies);
            Assert.Equal(0, result.GivenMercy);
            Assert.Equal(0, result.Remaining);
            Assert.Equal(0, result.Reconciliation);
        }
Esempio n. 5
0
        public void NoKill()
        {
            var lf           = new LoggerFactory();
            var expEksLogger = new ExpiredEksLoggingExtensions(lf.CreateLogger <ExpiredEksLoggingExtensions>());

            var contentDbContext = _contentDbProvider.CreateNew();

            Add(contentDbContext, 15);
            contentDbContext.SaveChanges();

            var fakeDtp = new FakeDtp()
            {
                Snapshot = new DateTime(2020, 6, 20, 0, 0, 0, DateTimeKind.Utc)
            };
            var command = new RemoveExpiredEksCommand(contentDbContext, new FakeEksConfig(), fakeDtp, expEksLogger);

            var result = command.Execute();

            Assert.Equal(1, result.Found);
            Assert.Equal(1, result.Zombies);
            Assert.Equal(0, result.GivenMercy);
            Assert.Equal(1, result.Remaining);
            Assert.Equal(0, result.Reconciliation);
        }