public void Upgrade_ValidParameters_ExpectedProperties()
        {
            // Setup
            string filePath = TestHelper.GetScratchPadPath(nameof(Upgrade_ValidParameters_ExpectedProperties));

            var mockRepository = new MockRepository();
            var versionedFile  = mockRepository.Stub <IVersionedFile>();

            versionedFile.Expect(vf => vf.Location).Return(filePath);
            mockRepository.ReplayAll();

            var createScript    = new TestCreateScript("2");
            var upgradeScript   = new TestUpgradeScript("1", "2");
            var migrationScript = new FileMigrationScript(createScript, upgradeScript);

            using (new FileDisposeHelper(filePath))
            {
                // Call
                IVersionedFile upgradedFile = migrationScript.Upgrade(versionedFile);

                // Assert
                Assert.IsNotNull(upgradedFile);
            }

            mockRepository.VerifyAll();
        }
        public void Constructor_ValidParameters_ExpectedProperties()
        {
            // Setup
            var createScript  = new TestCreateScript("2");
            var upgradeScript = new TestUpgradeScript("1", "2");

            // Call
            var migrationScript = new FileMigrationScript(createScript, upgradeScript);

            // Assert
            Assert.AreEqual(upgradeScript.FromVersion(), migrationScript.SupportedVersion());
            Assert.AreEqual(upgradeScript.ToVersion(), migrationScript.TargetVersion());
        }
        public void Constructor_CreateScriptNull_ThrowsArgumentNullException()
        {
            // Setup
            var upgradeScript = new TestUpgradeScript("1", "2");

            // Call
            TestDelegate call = () => new FileMigrationScript(null, upgradeScript);

            // Assert
            string paramName = Assert.Throws <ArgumentNullException>(call).ParamName;

            Assert.AreEqual("createScript", paramName);
        }
Exemple #4
0
        public void Constructor_ValidParameters_ReturnsExpectedValues()
        {
            // Setup
            const string fromVersion = "fromVersion";
            const string toVersion   = "toVersion";

            // Call
            var upgradeScript = new TestUpgradeScript(fromVersion, toVersion);

            // Assert
            Assert.AreEqual(fromVersion, upgradeScript.FromVersion());
            Assert.AreEqual(toVersion, upgradeScript.ToVersion());
        }
        public void Upgrade_VersionedFileNull_ThrowsArgumentNullException()
        {
            // Setup
            var createScript    = new TestCreateScript("2");
            var upgradeScript   = new TestUpgradeScript("1", "2");
            var migrationScript = new FileMigrationScript(createScript, upgradeScript);

            // Call
            TestDelegate call = () => migrationScript.Upgrade(null);

            // Assert
            string paramName = Assert.Throws <ArgumentNullException>(call).ParamName;

            Assert.AreEqual("sourceVersionedFile", paramName);
        }
Exemple #6
0
        public void Upgrade_InvalidTargetFilePath_ThrowsArgumentException(string targetFilePath)
        {
            // Setup
            const string fromVersion   = "fromVersion";
            const string toVersion     = "toVersion";
            var          upgradeScript = new TestUpgradeScript(fromVersion, toVersion);

            // Call
            TestDelegate call = () => upgradeScript.Upgrade("Filepath.ext", targetFilePath);

            // Assert
            var exception = Assert.Throws <ArgumentException>(call);

            Assert.AreEqual("targetLocation", exception.ParamName);
        }