Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions .github/workflows/build_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@ on:
push:
branches:
- development
- master
- main
workflow_dispatch:

jobs:
run-tests:
uses: ./.github/workflows/run_tests.yml
build:
needs: run-tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7

# version can be found here https://dotnet.microsoft.com/en-us/download/dotnet/10.0
- name: Setup .NET
uses: actions/setup-dotnet@v5
uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x

Expand All @@ -30,7 +27,7 @@ jobs:
run: dotnet publish AudioCuesheetEditor --configuration Release --output release

- name: Upload Build Artifact
uses: actions/upload-artifact@v6
uses: actions/upload-artifact@v7
with:
name: AudioCuesheetEditor-Release
path: ./release
Expand All @@ -40,16 +37,16 @@ jobs:
runs-on: ubuntu-latest
environment: |-
${{
github.ref_name == 'master' && 'Production'
github.ref_name == 'main' && 'Production'
|| 'Preview'
}}
steps:
- name: Download Build Artifact
uses: actions/download-artifact@v7
uses: actions/download-artifact@v8
with:
name: AudioCuesheetEditor-Release
- name: Deploy to Netlify
uses: nwtgck/actions-netlify@v3
uses: nwtgck/actions-netlify@v4
with:
publish-dir: './wwwroot'
production-deploy: true
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7

- name: Set timestamp variable
id: timestamp
run: echo "datetime=$(date +'%Y-%m-%d_%H-%M-%S')" >> $GITHUB_OUTPUT

# version can be found here https://dotnet.microsoft.com/en-us/download/dotnet/10.0
- name: Setup .NET
uses: actions/setup-dotnet@v5
uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x

Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:

- name: Upload traces
if: always()
uses: actions/upload-artifact@v6
uses: actions/upload-artifact@v7
with:
name: playwright-traces-${{ steps.timestamp.outputs.datetime }}
path: AudioCuesheetEditor.End2EndTests/bin/Debug/net10.0/playwright-traces/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Playwright.MSTest.v4" Version="1.62.0" />
<PackageReference Include="MSTest" Version="4.4.0" />
<PackageReference Include="MSTest" Version="4.4.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion AudioCuesheetEditor.Tests/AudioCuesheetEditor.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MSTest" Version="4.4.0" />
<PackageReference Include="MSTest" Version="4.4.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ public async Task SetPropertiesAsync_EmptyBrowserFile_ShouldClearPropertiesAsync
ObjectURL = "Just a test",
Duration = TimeSpan.FromSeconds(120)
};
var audiofileChangedFired = false;
_audiofileManager.AudiofileChanged += delegate(object? sender, Audiofile e)
{
if (e == audiofile)
{
audiofileChangedFired = true;
}
};
var expectedUrl = audiofile.ObjectURL;
// Act
await _audiofileManager.SetPropertiesAsync(audiofile, null, string.Empty);
Expand All @@ -96,6 +104,7 @@ public async Task SetPropertiesAsync_EmptyBrowserFile_ShouldClearPropertiesAsync
Assert.IsNull(audiofile.Name);
Assert.IsNull(audiofile.ObjectURL);
Assert.IsNull(audiofile.Duration);
Assert.IsTrue(audiofileChangedFired);
_jsRuntime.Verify(js => js.InvokeAsync<object>("revokeAudioObjectURL", It.Is<object?[]>(args => args != null && args.Length > 0 && (args[0] as string) == expectedUrl)), Times.Once);
}

Expand All @@ -116,7 +125,14 @@ public async Task SetPropertiesAsync_WithBrowserFile_ShouldSetPropertiesAsync()
_jsRuntime.Setup(js => js.InvokeAsync<double>("getAudioDurationFromFile", It.IsAny<object?[]>())).Returns(new ValueTask<double>(90.0));

var audiofile = new Audiofile();

var audiofileChangedFired = false;
_audiofileManager.AudiofileChanged += delegate (object? sender, Audiofile e)
{
if (e == audiofile)
{
audiofileChangedFired = true;
}
};
// Act
await _audiofileManager.SetPropertiesAsync(audiofile, browserFile.Object, inputId);

Expand All @@ -125,7 +141,7 @@ public async Task SetPropertiesAsync_WithBrowserFile_ShouldSetPropertiesAsync()
Assert.AreEqual(filename, audiofile.Name);
Assert.AreEqual(objectUrl, audiofile.ObjectURL);
Assert.AreEqual(TimeSpan.FromSeconds(90), audiofile.Duration);

Assert.IsTrue(audiofileChangedFired);
_fileInputManager.Verify(f => f.GetAudioCodec("audio/mpeg", filename), Times.Once);
_fileInputManager.Verify(f => f.GetObjectUrlAsync(inputId), Times.Once);
_jsRuntime.Verify(js => js.InvokeAsync<double>("getAudioDurationFromFile", It.Is<object?[]>(o => o[0] as string == audiofile.ObjectURL)), Times.Once);
Expand Down Expand Up @@ -161,7 +177,14 @@ public async Task SetProperty_AudiofileWithDuration_SetsLastTrackEndAlsoAsync()
{
Tracks = [track1, track2]
};

var audiofileChangedFired = false;
_audiofileManager.AudiofileChanged += delegate (object? sender, Audiofile e)
{
if (e == audiofile)
{
audiofileChangedFired = true;
}
};
// Act
await _audiofileManager.SetPropertiesAsync(audiofile, browserFile.Object, inputId);

Expand All @@ -171,7 +194,7 @@ public async Task SetProperty_AudiofileWithDuration_SetsLastTrackEndAlsoAsync()
Assert.AreEqual(objectUrl, audiofile.ObjectURL);
Assert.AreEqual(TimeSpan.FromSeconds(90), audiofile.Duration);
Assert.AreEqual(TimeSpan.FromSeconds(90), track2.End);

Assert.IsTrue(audiofileChangedFired);
_fileInputManager.Verify(f => f.GetAudioCodec("audio/mpeg", filename), Times.Once);
_fileInputManager.Verify(f => f.GetObjectUrlAsync(inputId), Times.Once);
_jsRuntime.Verify(js => js.InvokeAsync<double>("getAudioDurationFromFile", It.Is<object?[]>(o => o[0] as string == audiofile.ObjectURL)), Times.Once);
Expand All @@ -186,11 +209,19 @@ public async Task SetPropertiesAsync_NullBrowserFile_WithExistingObjectUrl_Shoul
ObjectURL = "just a test"
};
var expectedUrl = audiofile.ObjectURL;

var audiofileChangedFired = false;
_audiofileManager.AudiofileChanged += delegate (object? sender, Audiofile e)
{
if (e == audiofile)
{
audiofileChangedFired = true;
}
};
// Act
await _audiofileManager.SetPropertiesAsync(audiofile, null, string.Empty);

// Assert
Assert.IsTrue(audiofileChangedFired);
_jsRuntime.Verify(js =>js.InvokeAsync<object>("revokeAudioObjectURL", It.Is<object?[]>(args => args != null && args.Length > 0 && (args[0] as string) == expectedUrl)),Times.Once);
Assert.IsNull(audiofile.ObjectURL);
}
Expand All @@ -203,12 +234,20 @@ public void SetProperty_ChangedName_UpdatesPropertyAndAddsTrace()
{
Name = "oldname.mp3"
};

var audiofileChangedFired = false;
_audiofileManager.AudiofileChanged += delegate (object? sender, Audiofile e)
{
if (e == audiofile)
{
audiofileChangedFired = true;
}
};
// Act
_audiofileManager.SetProperty(audiofile, x => x.Name, "newname.mp3");

// Assert
Assert.AreEqual("newname.mp3", audiofile.Name);
Assert.IsTrue(audiofileChangedFired);
_traceChangeManager.Verify(x => x.AddChange(It.Is<TracedChange>(y => y.TraceableObject == audiofile && y.TraceableChange.PreviousValue!.Equals("oldname.mp3") && y.TraceableChange.PropertyName == nameof(Audiofile.Name))), Times.Once);
}

Expand All @@ -220,11 +259,19 @@ public void SetProperty_EqualValue_DoesntChangeProperty()
{
Name = "oldname.mp3"
};

var audiofileChangedFired = false;
_audiofileManager.AudiofileChanged += delegate (object? sender, Audiofile e)
{
if (e == audiofile)
{
audiofileChangedFired = true;
}
};
// Act
_audiofileManager.SetProperty(audiofile, x => x.Name, "oldname.mp3");

// Assert
Assert.IsFalse(audiofileChangedFired);
_traceChangeManager.Verify(x => x.AddChange(It.Is<TracedChange>(y => y.TraceableObject == audiofile && y.TraceableChange.PreviousValue!.Equals("oldname.mp3") && y.TraceableChange.PropertyName == nameof(Audiofile.Name))), Times.Never);
}

Expand All @@ -248,13 +295,21 @@ public void SetProperty_DurationChanged_SetsLastTrackEndAlso()
Tracks = [track1, track2],
};
var duration = new TimeSpan(0, 3, 37, 12);

var audiofileChangedFired = false;
_audiofileManager.AudiofileChanged += delegate (object? sender, Audiofile e)
{
if (e == audiofile)
{
audiofileChangedFired = true;
}
};
// Act
_audiofileManager.SetProperty(audiofile, x => x.Duration, duration);

// Assert
Assert.AreEqual(duration, audiofile.Duration);
Assert.AreEqual(duration, track2.End);
Assert.IsTrue(audiofileChangedFired);
}

[TestMethod]
Expand All @@ -268,11 +323,20 @@ public void AddTrack_FirstTrack_AddsNewTrackWithCalulatedTrackProperties()
Audiofiles = [audiofile]
};
_sessionStateContainer.Setup(x => x.ActiveCuesheet).Returns(cuesheet);
var audiofileChangedFired = false;
_audiofileManager.AudiofileChanged += delegate (object? sender, Audiofile e)
{
if (e == audiofile)
{
audiofileChangedFired = true;
}
};
var track = new Track();
// Act
_audiofileManager.AddTrack(audiofile, track);
// Assert
Assert.HasCount(1, audiofile.Tracks);
Assert.IsTrue(audiofileChangedFired);
Assert.AreEqual((ushort)1, audiofile.Tracks.First().Position);
Assert.AreEqual(TimeSpan.Zero, audiofile.Tracks.First().Begin);
Assert.AreEqual(duration, audiofile.Tracks.First().End);
Expand Down Expand Up @@ -307,6 +371,14 @@ public void AddTrack_AddToPreviousTracks_AddsNewTrackWithCalulatedTrackPropertie
{
IsLinkedToPreviousTrack = true
};
var audiofileChangedFired = false;
_audiofileManager.AudiofileChanged += delegate (object? sender, Audiofile e)
{
if (e == audiofile)
{
audiofileChangedFired = true;
}
};
// Act
_audiofileManager.AddTrack(audiofile, track);
// Assert
Expand All @@ -316,6 +388,7 @@ public void AddTrack_AddToPreviousTracks_AddsNewTrackWithCalulatedTrackPropertie
Assert.AreEqual(duration, audiofile.Tracks.Last().End);
Assert.AreEqual(cuesheet, track.Cuesheet);
Assert.AreEqual(audiofile, track.Audiofile);
Assert.IsTrue(audiofileChangedFired);
_traceChangeManager.Verify(x => x.AddChange(It.Is<TracedChange>(y => y.TraceableObject == audiofile && y.TraceableChange.PreviousValue == tracks && y.TraceableChange.PropertyName == nameof(Audiofile.Tracks))), Times.Once);
_traceChangeManager.VerifySet(t => t.BulkEdit = true, Times.Once);
_traceChangeManager.VerifySet(t => t.BulkEdit = false, Times.Once);
Expand Down Expand Up @@ -348,9 +421,18 @@ public void AddTrack_DuringRecording_AddsNewTrackWithCalulatedTrackProperties()
{
IsLinkedToPreviousTrack = true
};
var audiofileChangedFired = false;
_audiofileManager.AudiofileChanged += delegate (object? sender, Audiofile e)
{
if (e == audiofile)
{
audiofileChangedFired = true;
}
};
// Act
_audiofileManager.AddTrack(audiofile, track);
// Assert
Assert.IsTrue(audiofileChangedFired);
Assert.HasCount(2, audiofile.Tracks);
Assert.AreEqual((ushort)2, audiofile.Tracks.Last().Position);
Assert.IsNotNull(audiofile.Tracks.First().End);
Expand All @@ -374,9 +456,18 @@ public void AddTrack_FirstTrackImporting_AddsNewTrackWithCalulatedTrackPropertie
};
_sessionStateContainer.Setup(x => x.ActiveCuesheet).Returns(importCuesheet);
var track = new Track();
var audiofileChangedFired = false;
_audiofileManager.AudiofileChanged += delegate (object? sender, Audiofile e)
{
if (e == audiofile)
{
audiofileChangedFired = true;
}
};
// Act
_audiofileManager.AddTrack(audiofile, track);
// Assert
Assert.IsTrue(audiofileChangedFired);
Assert.HasCount(1, audiofile.Tracks);
Assert.AreEqual((ushort)1, audiofile.Tracks.First().Position);
Assert.AreEqual(TimeSpan.Zero, audiofile.Tracks.First().Begin);
Expand Down Expand Up @@ -442,13 +533,22 @@ public void RemoveTracks_WithAttachedTracks_RemovesTracksAndRecalculatesRemainin
track4.Cuesheet = cuesheet;
track5.Cuesheet = cuesheet;
_sessionStateContainer.Setup(x => x.ActiveCuesheet).Returns(cuesheet);
var audiofileChangedFired = false;
_audiofileManager.AudiofileChanged += delegate (object? sender, Audiofile e)
{
if (e == audiofile)
{
audiofileChangedFired = true;
}
};
// Act
_audiofileManager.RemoveTracks(audiofile, [track2, track4]);
// Assert
Assert.HasCount(3, audiofile.Tracks);
Assert.Contains(track1, audiofile.Tracks);
Assert.Contains(track3, audiofile.Tracks);
Assert.Contains(track5, audiofile.Tracks);
Assert.IsTrue(audiofileChangedFired);
Assert.AreEqual((ushort)1, track1.Position);
Assert.AreEqual(TimeSpan.Zero, track1.Begin);
Assert.AreEqual(track1.End, track3.Begin);
Expand Down Expand Up @@ -520,6 +620,14 @@ public void RemoveTracks_DuringImport_RemovesTracksAndRecalculatesRemainingTrack
track4.Audiofile = audiofile;
track5.Audiofile = audiofile;
_sessionStateContainer.Setup(x => x.ActiveCuesheet).Returns(importCuesheet);
var audiofileChangedFired = false;
_audiofileManager.AudiofileChanged += delegate (object? sender, Audiofile e)
{
if (e == audiofile)
{
audiofileChangedFired = true;
}
};
// Act
_audiofileManager.RemoveTracks(audiofile, [track2, track4]);
// Assert
Expand All @@ -533,6 +641,7 @@ public void RemoveTracks_DuringImport_RemovesTracksAndRecalculatesRemainingTrack
Assert.AreEqual((ushort)2, track3.Position);
Assert.AreEqual(track5.Begin, track3.End);
Assert.AreEqual((ushort)3, track5.Position);
Assert.IsTrue(audiofileChangedFired);
Assert.AreEqual(duration, track5.End);
_traceChangeManager.Verify(x => x.AddChange(It.Is<TracedChange>(y => y.TraceableObject == audiofile && y.TraceableChange.PreviousValue == previousValue && y.TraceableChange.PropertyName == nameof(Audiofile.Tracks))), Times.Once);
_traceChangeManager.VerifySet(t => t.BulkEdit = true, Times.Once);
Expand Down
Loading
Loading