コード例 #1
0
        public void CreateVersionState_Always_SetsApplied()
        {
            using (_mocks.Record())
            {
                SetupResult.For(_configuration.DesiredVersion).Return((long)2);
                SetupResult.For(_schemaStateManager.GetAppliedMigrationVersions(null)).Return(new long[] { 1, 2, 3 });
            }
            VersionState actual = _target.CreateVersionState(_migrations)[string.Empty];

            CollectionAssert.AreEqual(new long[] { 1, 2, 3 }, new List <long>(actual.Applied));
        }
コード例 #2
0
        VersionState GetVersionState(string key, ICollection <MigrationReference> migrations)
        {
            _configuration.ActiveConfigurationKey = key;
            var applied = _schemaStateManager.GetAppliedMigrationVersions(_configuration.Scope);

            _configuration.ActiveConfigurationKey = null;
            long desired = _configuration.DesiredVersion;
            long last    = 0;

            if (migrations.Count > 0)
            {
                List <MigrationReference> all = new List <MigrationReference>(migrations);
                last = all[all.Count - 1].Version;
            }
            if (desired > last)
            {
                throw new ArgumentException("DesiredVersion is greater than maximum migration!");
            }
            if (desired < 0)
            {
                desired = last;
            }
            return(new VersionState(last, desired, applied));
        }