Ejemplo n.º 1
0
        private static void ValidateDatabaseVersion(RiskeerEntities riskeerEntities, string databaseFilePath)
        {
            try
            {
                string databaseVersion = riskeerEntities.VersionEntities.Select(v => v.Version).Single();
                if (!ProjectVersionHelper.IsValidVersion(databaseVersion))
                {
                    string m = string.Format(Resources.StorageSqLite_ValidateDatabaseVersion_DatabaseVersion_0_is_invalid,
                                             databaseVersion);
                    string message = new FileReaderErrorMessageBuilder(databaseFilePath).Build(m);
                    throw new StorageValidationException(message);
                }

                if (ProjectVersionHelper.IsNewerThanCurrent(databaseVersion))
                {
                    string m = string.Format(Resources.StorageSqLite_ValidateDatabaseVersion_DatabaseVersion_0_higher_then_current_DatabaseVersion_1_,
                                             databaseVersion, ProjectVersionHelper.GetCurrentDatabaseVersion());
                    string message = new FileReaderErrorMessageBuilder(databaseFilePath).Build(m);
                    throw new StorageValidationException(message);
                }
            }
            catch (InvalidOperationException e)
            {
                string message = new FileReaderErrorMessageBuilder(databaseFilePath).Build(Resources.StorageSqLite_ValidateDatabaseVersion_Database_must_have_one_VersionEntity_row);
                throw new StorageValidationException(message, e);
            }
        }
Ejemplo n.º 2
0
        public void IsNewerThanCurrentString_InvalidVersion_ReturnsFalse(string invalidVersion)
        {
            // Call
            bool isNewer = ProjectVersionHelper.IsNewerThanCurrent(invalidVersion);

            // Assert
            Assert.IsFalse(isNewer);
        }
Ejemplo n.º 3
0
        public void IsNewerThanCurrentString_NewerVersion_ReturnsTrue(string newerVersion)
        {
            // Call
            bool isNewer = ProjectVersionHelper.IsNewerThanCurrent(newerVersion);

            // Assert
            Assert.IsTrue(isNewer);
        }
Ejemplo n.º 4
0
        public void IsNewerThanCurrentString_SameVersion_ReturnsFalse()
        {
            // Setup
            string currentVersion = ProjectVersionHelper.GetCurrentDatabaseVersion();

            // Call
            bool isNewer = ProjectVersionHelper.IsNewerThanCurrent(currentVersion);

            // Assert
            Assert.IsFalse(isNewer);
        }