public void DbExistsChecks()
        {
            CreateVersionChecker();

            VersionChecker.CheckAndUpdate();

            FileSystemServiceMock.Verify(fss => fss.CheckFileExists(DbService.DatabaseName), Times.Once);
        }
        public void CopyOfOldDbDeletesWhenMigrationsSuccessfulDone()
        {
            var appVersion       = new Version(2, 1);
            var currentDbVersion = "2.0";

            CreateVersionChecker(appVersion);
            DbServiceMock.Setup(ds => ds.SettingsGetValue(SettingsType.DBVersion)).Returns(currentDbVersion);
            MessageBoxServiceMock.Setup(mbs => mbs.AskWarningQuestion(It.IsAny <string>(),
                                                                      It.IsAny <object>(),
                                                                      It.IsAny <object>())).Returns(true);

            VersionChecker.CheckAndUpdate();

            FileSystemServiceMock.Verify(fss => fss.DeleteFile(DbService.DatabaseCopyName),
                                         Times.Once);
        }
        public void DbRevertedOnMigrationError()
        {
            var appVersion       = new Version(2, 1);
            var currentDbVersion = "2.0";

            CreateVersionChecker(appVersion);
            DbServiceMock.Setup(ds => ds.SettingsGetValue(SettingsType.DBVersion)).Returns(currentDbVersion);
            DbServiceMock.Setup(ds => ds.MigrateFrom2_0to2_1()).Throws <Exception>();
            MessageBoxServiceMock.Setup(mbs => mbs.AskWarningQuestion(It.IsAny <string>(),
                                                                      It.IsAny <object>(),
                                                                      It.IsAny <object>())).Returns(true);

            InvokeAndSwallowException(() => VersionChecker.CheckAndUpdate());

            FileSystemServiceMock.Verify(fss => fss.CreateFileCopy(DbService.DatabaseCopyName,
                                                                   DbService.DatabaseName,
                                                                   true),
                                         Times.Once);
            FileSystemServiceMock.Verify(fss => fss.DeleteFile(DbService.DatabaseCopyName),
                                         Times.Once);
        }