public void PurgeDeletesSoftDeletesNoTimestamp()
 {
     File.VoidCreate();
     SoftDelete.VoidCreate();
     Backup.VoidCreate();
     _backuper.AfterSuccessfulSave(File);
     AssertFile.Exists(true, File);
     AssertFile.Exists(true, Backup);
     AssertFile.Exists(false, SoftDelete);
 }
Beispiel #2
0
        public async Task Update_Soft_Delete_Column(Type dataContextType)
        {
            // Arrange
            using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType);
            SoftDelete softDelete = await dataContext.Create <SoftDelete>(new SoftDelete());

            // Act / Assert
            Assert.ThrowsAsync <ArgumentException>(async() =>
            {
                await dataContext.Update <SoftDelete>(new { softDelete.SoftDeleteId, RecordStatus = 999 });
            });
        }
Beispiel #3
0
        public async Task Insert_With_Soft_Delete(Type dataContextType)
        {
            // Arrange
            using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType);

            // Act
            SoftDelete softDelete = await dataContext.Create(new SoftDelete()).ConfigureAwait(false);

            // Assert
            Assert.Greater(softDelete.SoftDeleteId, 0);
            Assert.AreEqual(1, softDelete.RecordStatus);
        }
        public async Task Insert_For_Soft_Delete()
        {
            using (IDbConnection connection = LocalDbTestHelper.OpenTestConnection(TestContext.CurrentContext.Test.FullName))
            {
                // Act
                SoftDelete softDelete = await connection.Create <SoftDelete>(new SoftDelete()).ConfigureAwait(false);

                // Assert
                Assert.Greater(softDelete.SoftDeleteId, 0);
                Assert.AreEqual(1, softDelete.RecordStatus);
            }
        }
Beispiel #5
0
        public async Task Soft_Delete_Entity(Type dataContextType)
        {
            // Arrange
            using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType);
            SoftDelete softDelete = await dataContext.Create(new SoftDelete());

            // Act
            await dataContext.Delete <SoftDelete>(new { softDelete.SoftDeleteId, });

            // Assert
            Assert.IsNull(await dataContext.Read <SoftDelete>(new { softDelete.SoftDeleteId }));
        }
        public void TryRestoreWhenHasSoftDelete()
        {
            SoftDelete.Save(_dummy);
            AssertFile.Exists(false, File);
            AssertFile.Exists(true, SoftDelete);

            Assert.IsTrue(_backuper.CanRestore(File));
            Assert.IsTrue(_backuper.TryRestore(File));

            Assert.AreEqual(_dummy, File.Read <DummySerializable>());
            AssertFile.Exists(true, File);
            AssertFile.Exists(false, SoftDelete);
            AssertFile.Exists(false, Backup);
        }
        public async Task Update_Soft_Delete_Column()
        {
            using (IDbConnection connection = LocalDbTestHelper.OpenTestConnection(TestContext.CurrentContext.Test.FullName))
            {
                // Arrange
                SoftDelete softDelete = await connection.Create <SoftDelete>(new SoftDelete()).ConfigureAwait(false);

                // Act / Assert
                Assert.ThrowsAsync <ArgumentException>(async() =>
                {
                    await connection.Update <SoftDelete>(new { softDelete.SoftDeleteId, RecordsStatus = 999 });
                });
            }
        }
Beispiel #8
0
        public async Task Update_Soft_Delete_Entity(Type dataContextType)
        {
            // Arrange
            using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType);
            SoftDelete original = await dataContext.Create <SoftDelete>(new SoftDelete()
            {
                Value = "Value"
            });

            // Act / Assert
            SoftDelete updated = await dataContext.Update <SoftDelete>(new { original.SoftDeleteId, Value = "Another Value" });

            // Assert
            Assert.AreEqual(original.SoftDeleteId, updated.SoftDeleteId);
            Assert.AreEqual("Another Value", updated.Value);
        }
 public void PurgeDeletesSoftDeletes()
 {
     foreach (var backup in TimestampedBackups)
     {
         backup.VoidCreate();
     }
     SoftDelete.VoidCreate();
     File.VoidCreate();
     Backup.VoidCreate();
     Setting.NumberOfBackups = int.MaxValue;
     Setting.MaxAgeInDays    = int.MaxValue;
     _backuper.AfterSuccessfulSave(File);
     AssertFile.Exists(true, File);
     AssertFile.Exists(true, Backup);
     AssertFile.Exists(false, SoftDelete);
 }
        public void TryRestoreWhenHasBackupAndOriginal()
        {
            File.WriteAllText("File");
            SoftDelete.VoidCreate();
            Backup.VoidCreate();

            AssertFile.Exists(true, File);
            AssertFile.Exists(true, SoftDelete);
            AssertFile.Exists(true, Backup);

            Assert.Throws <InvalidOperationException>(() => _backuper.TryRestore(File));

            AssertFile.Exists(true, File);
            AssertFile.Exists(true, SoftDelete);
            AssertFile.Exists(true, Backup);
        }
 public void PurgeOld()
 {
     SoftDelete.VoidCreate();
     foreach (var backup in TimestampedBackups)
     {
         backup.VoidCreate();
     }
     Setting.TimeStampFormat = BackupSettings.DefaultTimeStampFormat;
     Setting.NumberOfBackups = int.MaxValue;
     Setting.MaxAgeInDays    = 2;
     _backuper.AfterSuccessfulSave(File);
     AssertFile.Exists(true, BackupOneMinuteOld);
     AssertFile.Exists(true, BackupOneHourOld);
     AssertFile.Exists(true, BackupOneDayOld);
     AssertFile.Exists(false, BackupOneMonthOld);
     AssertFile.Exists(false, BackupOneYearOld);
     AssertFile.Exists(false, SoftDelete);
 }
Beispiel #12
0
        public async Task Soft_Delete_List_Of_Entities(Type dataContextType)
        {
            // Arrange
            using IDataContext dataContext = DataContextTestHelper.SetupDataContext(dataContextType);
            SoftDelete sd1 = await dataContext.Create(new SoftDelete());

            SoftDelete sd2 = await dataContext.Create(new SoftDelete());

            SoftDelete sd3 = await dataContext.Create(new SoftDelete());

            // Act
            await dataContext.DeleteList <SoftDelete>(
                In <SoftDelete>(x => x.SoftDeleteId, new int[] { sd2.SoftDeleteId, sd3.SoftDeleteId }));

            // Assert
            Assert.AreEqual(0, (await dataContext.ReadList <SoftDelete>(
                                    In <SoftDelete>(x => x.SoftDeleteId, new int[] { sd2.SoftDeleteId, sd3.SoftDeleteId }))).Count());
            Assert.AreEqual(1, (await dataContext.ReadAll <SoftDelete>()).Count());
        }
 public void PurgeWhenHasSoftDelete()
 {
     File.VoidCreate();
     SoftDelete.VoidCreate();
     foreach (var backup in TimestampedBackups)
     {
         backup.VoidCreate();
     }
     Setting.NumberOfBackups = 3;
     Setting.MaxAgeInDays    = int.MaxValue;
     _backuper.AfterSuccessfulSave(File);
     AssertFile.Exists(true, File);
     AssertFile.Exists(true, BackupOneMinuteOld);
     AssertFile.Exists(true, BackupOneHourOld);
     AssertFile.Exists(true, BackupOneDayOld);
     AssertFile.Exists(true, BackupOneMonthOld);
     AssertFile.Exists(true, BackupOneYearOld);
     AssertFile.Exists(false, SoftDelete);
 }
Beispiel #14
0
        public override int GetHashCode()
        {
            //x return base.GetHashCode();
            //x return new { Id, CreatedAt, ModifiedAt, SoftDelete, Name, Url }.GetHashCode();
            unchecked
            {
                int       hash        = 17;    //x (int)2166136261; //x (int)397;
                const int primeNumber = 23;    //x 16777619;

                //TODO do suitable nullity checks
                hash = hash * primeNumber ^ Id.GetHashCode();
                hash = hash * primeNumber ^ CreatedAt.GetHashCode();
                hash = hash * primeNumber ^ ModifiedAt.GetHashCode();
                hash = hash * primeNumber ^ SoftDelete.GetHashCode();
                hash = hash * primeNumber ^ (Name == null
                                                                                        ? 0
                                                                                        : Name.GetHashCode());
                hash = hash * primeNumber ^ (Url == null
                                                                                        ? 0
                                                                                        : Url.GetHashCode());
                return(hash);
            }
        }