Ejemplo n.º 1
0
        public void EmptyUpgradeListTest()
        {
            // All these means nothing to upgrade
            var chain = new MigrationChain(Enumerable.Empty <IUpgradeLink>());

            chain.Validate();
            var path = chain.GetUpgradePath(null);

            Assert.IsNotNull(path);
            Assert.AreEqual(0, path.Count());
            Assert.IsNull(chain.Target);
        }
Ejemplo n.º 2
0
        public void ConsistentUpgradeWithNullListTest([Values(null, "0.0", "0.1", "0.2", "0.3", "0.4", "1.0")] string current)
        {
            var currentVer = current == null ? null : Version.Parse(current);
            var chain      = new MigrationChain(new List <IUpgradeLink>
            {
                new UpgradeStub(null, "0.0"),
                new UpgradeStub("0.0", "0.1"),
                new UpgradeStub("0.1", "0.2"),
                new UpgradeStub("0.2", "0.3"),
            });

            chain.Validate();
            // All these means nothing to upgrade
            var path = chain.GetUpgradePath(currentVer);

            switch (current)
            {
            case null:
                Assert.AreEqual(4, path.Count());
                break;

            case "0.0":
                Assert.AreEqual(3, path.Count());
                break;

            case "0.1":
                Assert.AreEqual(2, path.Count());
                break;

            case "0.2":
                Assert.AreEqual(1, path.Count());
                break;

            case "0.3":
                Assert.AreEqual(0, path.Count());
                break;

            case "0.4":
                Assert.AreEqual(0, path.Count());
                break;

            case "1.0":
                Assert.AreEqual(0, path.Count());
                break;
            }
        }