Пример #1
0
        public bool GetSteps_HistoryIsEmpty(NonNegativeInt stepsCount)
        {
            //arrange
            var(_, steps) = MigrationTestsContext.GenerateMigrationState(stepsCount.Item, missingCount: 0);

            //act
            var result = MigrationHandler.GetSteps(steps, allHistory: new List <MigrationHistory>(), lastLegacyMigrationVersion: new Version("1.1.1.1"));

            var originalVersions = steps.Select(x => x.Version.ToString());
            var filteredVersions = result.Select(r => r.Version.ToString());

            //assert
            return(originalVersions.SequenceEqual(filteredVersions));
        }
Пример #2
0
        public Property GetSteps_HistoryIsNotEmpty(NonNegativeInt present, NonNegativeInt missing, NonNegativeInt lastLegacyMigrationVersionNumber)
        {
            bool Predicate()
            {
                //arrange
                var(history, steps) = MigrationTestsContext.GenerateMigrationState(present, missing);
                var lastLegacyMigrationVersion = steps[lastLegacyMigrationVersionNumber.Item - 1];

                //act
                var result = MigrationHandler.GetSteps(steps, history, lastLegacyMigrationVersion.Version);

                var originalVersions = steps.Skip(present.Item).Select(x => x.Version.ToString());
                var filteredVersions = result.Select(r => r.Version.ToString());

                //assert
                return(originalVersions.SequenceEqual(filteredVersions));
            }

            return(new Func <bool>(Predicate).When(
                       present.Item > 0 &&
                       lastLegacyMigrationVersionNumber.Item > 0 &&
                       lastLegacyMigrationVersionNumber.Item <= present.Item + missing.Item &&
                       lastLegacyMigrationVersionNumber.Item >= present.Item));
        }