public void CreateEmptyVersionedFile_FileDoesNotExist_ReturnsVersionedFile() { // Setup const string query = ";"; string version = ProjectVersionHelper.GetCurrentDatabaseVersion(); string filePath = TestHelper.GetScratchPadPath(nameof(CreateEmptyVersionedFile_FileDoesNotExist_ReturnsVersionedFile)); var createScript = new ProjectCreateScript(version, query); // Call IVersionedFile versionedFile = createScript.CreateEmptyVersionedFile(filePath); // Assert Assert.IsTrue(File.Exists(versionedFile.Location)); File.Delete(filePath); }
public void CreateEmptyVersionedFile_QueryFails_ThrowsCriticalMigrationException() { // Setup const string query = "THIS WILL FAIL"; string version = ProjectVersionHelper.GetCurrentDatabaseVersion(); string filePath = TestHelper.GetScratchPadPath(nameof(CreateEmptyVersionedFile_QueryFails_ThrowsCriticalMigrationException)); var createScript = new ProjectCreateScript(version, query); // Call TestDelegate call = () => createScript.CreateEmptyVersionedFile(filePath); // Assert using (new FileDisposeHelper(filePath)) { var exception = Assert.Throws <CriticalMigrationException>(call); Assert.AreEqual($"Het aanmaken van het Riskeer projectbestand met versie '{version}' is mislukt.", exception.Message); Assert.IsInstanceOf <SQLiteException>(exception.InnerException); } }
public void CreateEmptyVersionedFile_FileExistsButNotWritable_ThrowsArgumentException() { // Setup const string query = ";"; string version = ProjectVersionHelper.GetCurrentDatabaseVersion(); string filePath = TestHelper.GetScratchPadPath(nameof(CreateEmptyVersionedFile_FileExistsButNotWritable_ThrowsArgumentException)); var createScript = new ProjectCreateScript(version, query); using (new FileDisposeHelper(filePath)) { FileAttributes attributes = File.GetAttributes(filePath); File.SetAttributes(filePath, attributes | FileAttributes.ReadOnly); // Call TestDelegate call = () => createScript.CreateEmptyVersionedFile(filePath); // Assert var exception = Assert.Throws <ArgumentException>(call); Assert.AreEqual("path", exception.ParamName); File.SetAttributes(filePath, attributes); } }