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_ExpectedValues() { // Setup const string version = "Valid version"; // Call var createScript = new TestCreateScript(version); // Assert Assert.AreEqual(version, createScript.GetVersion()); }
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_UpgradeScriptNull_ThrowsArgumentNullException() { // Setup var createScript = new TestCreateScript("1"); // Call TestDelegate call = () => new FileMigrationScript(createScript, null); // Assert string paramName = Assert.Throws <ArgumentNullException>(call).ParamName; Assert.AreEqual("upgradeScript", paramName); }
public void CreateEmptyVersionedFile_InvalidPath_ThrowsArgumentException(string filePath) { // Setup const string version = "Valid version"; var createScript = new TestCreateScript(version); // Call TestDelegate call = () => createScript.CreateEmptyVersionedFile(filePath); // Assert string message = Assert.Throws <ArgumentException>(call).Message; Assert.AreEqual($"Fout bij het lezen van bestand '{filePath}': bestandspad mag niet leeg of ongedefinieerd zijn.", message); }
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); }
public void CreateEmptyVersionedFile_FileDoesNotExist_ReturnsVersionedFile() { // Setup const string version = "Valid version"; string filePath = TestHelper.GetScratchPadPath(nameof(CreateEmptyVersionedFile_FileDoesNotExist_ReturnsVersionedFile)); var createScript = new TestCreateScript(version); // Call IVersionedFile versionedFile = createScript.CreateEmptyVersionedFile(filePath); // Assert Assert.IsTrue(File.Exists(versionedFile.Location)); File.Delete(filePath); }
public void CreateEmptyVersionedFile_FileExistsButNotWritable_ThrowsArgumentException() { // Setup const string version = "Valid version"; string filePath = TestHelper.GetScratchPadPath(nameof(CreateEmptyVersionedFile_FileExistsButNotWritable_ThrowsArgumentException)); var createScript = new TestCreateScript(version); using (var disposeHelper = new FileDisposeHelper(filePath)) { disposeHelper.LockFiles(); // Call TestDelegate call = () => createScript.CreateEmptyVersionedFile(filePath); // Assert var exception = Assert.Throws <ArgumentException>(call); Assert.AreEqual("path", exception.ParamName); } }