Skip to content

Commit

Permalink
Fixed import and tracing changes
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoCoderMatrix86 committed Aug 30, 2024
1 parent 9c02366 commit 4935fca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions AudioCuesheetEditor/Services/IO/ImportManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ public async Task ImportCuesheetAsync()
{
if (_sessionStateContainer.ImportCuesheet != null)
{
_traceChangeManager.BulkEdit = true;
await CopyCuesheetAsync(_sessionStateContainer.Cuesheet, _sessionStateContainer.ImportCuesheet);
_traceChangeManager.BulkEdit = false;
}
_sessionStateContainer.ResetImport();
}
Expand All @@ -129,7 +131,6 @@ private static async Task<MemoryStream> ReadFileContentAsync(IFileEntry file)

private async Task CopyCuesheetAsync(Cuesheet target, ICuesheet cuesheetToCopy)
{
_traceChangeManager.BulkEdit = true;
target.IsImporting = true;
target.Artist = cuesheetToCopy.Artist;
target.Title = cuesheetToCopy.Title;
Expand Down Expand Up @@ -178,7 +179,6 @@ private async Task CopyCuesheetAsync(Cuesheet target, ICuesheet cuesheetToCopy)
throw new NullReferenceException();
}
target.IsImporting = false;
_traceChangeManager.BulkEdit = false;
_sessionStateContainer.FireCuesheetImported();
}
}
Expand Down
10 changes: 5 additions & 5 deletions AudioCuesheetEditorTests/Model/UI/TraceChangeManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,12 @@ public async Task Import_ValidTextfile_IsUndoable()
// Act
await importManager.ImportTextAsync(fileContent);
// Assert
Assert.IsTrue(traceChangeManager.CanUndo);
Assert.IsFalse(traceChangeManager.CanUndo);
Assert.IsFalse(traceChangeManager.CanRedo);
Assert.IsNotNull(sessionStateContainer.ImportCuesheet);
Assert.AreEqual("DJFreezeT", sessionStateContainer.ImportCuesheet.Artist);
Assert.AreEqual("0123456789123", sessionStateContainer.ImportCuesheet.Cataloguenumber.Value);
Assert.AreNotEqual(0, sessionStateContainer.ImportCuesheet.Tracks.Count);
Assert.IsTrue(traceChangeManager.CanUndo);
Assert.IsFalse(eventFired);
}

Expand Down Expand Up @@ -220,12 +219,13 @@ public async Task UndoImport_ValidTextfile_ResetsToEmptyCuesheet()
eventFired = true;
};
await importManager.ImportTextAsync(fileContent);
await importManager.ImportCuesheetAsync();
// Act
traceChangeManager.Undo();
// Assert
Assert.AreEqual(0, sessionStateContainer.ImportCuesheet?.Tracks.Count);
Assert.IsTrue(String.IsNullOrEmpty(sessionStateContainer.ImportCuesheet?.Artist));
Assert.IsTrue(String.IsNullOrEmpty(sessionStateContainer.ImportCuesheet?.Cataloguenumber.Value));
Assert.AreEqual(0, sessionStateContainer.Cuesheet.Tracks.Count);
Assert.IsTrue(String.IsNullOrEmpty(sessionStateContainer.Cuesheet.Artist));
Assert.IsTrue(String.IsNullOrEmpty(sessionStateContainer.Cuesheet.Cataloguenumber.Value));
Assert.IsFalse(traceChangeManager.CanUndo);
Assert.IsTrue(traceChangeManager.CanRedo);
Assert.IsFalse(eventFired);
Expand Down

0 comments on commit 4935fca

Please sign in to comment.