Exemplo n.º 1
0
        public void ShouldNotBeValidStateIfAnyHashIsDifferent()
        {
            var migrations = new[] { new Migration("2006", "asdf", ""), new Migration("2007", "fdsa", "") };
            var hash       = new Dictionary <string, string>();

            foreach (var mig in migrations)
            {
                hash.Add(mig.Version, mig.Hash);
            }
            hash["2006"] = "222";
            var db = new MigrationTracker(migrations, hash);

            Assert.IsFalse(db.IsValidState());
        }
Exemplo n.º 2
0
        public void ShouldBeValidStateIfAllHashesAreTheSame()
        {
            var migrations = new[] { new Migration("2006", "asdf", ""), new Migration("2007", "fdsa", "") };
            var hash       = new Dictionary <string, string>();

            foreach (var mig in migrations)
            {
                hash.Add(mig.Version, mig.Hash);
            }
            var db = new MigrationTracker(migrations, hash);

            Assert.IsTrue(!db.IsHashMismatch());
            Assert.IsTrue(db.IsValidState());
        }
Exemplo n.º 3
0
        public void ShouldNotBeValidIfThereIsAMigrationGap()
        {
            var migrations = new List <Migration> {
                new Migration("2006", "asdf", ""), new Migration("2007", "fdsa", "")
            };
            var hash = new Dictionary <string, string>();

            foreach (var mig in migrations)
            {
                hash.Add(mig.Version, mig.Hash);
            }
            migrations.Insert(1, new Migration("2006-01", "fdsw", ""));
            var db = new MigrationTracker(migrations, hash);

            Assert.IsFalse(db.IsValidState());
        }