mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 20:11:10 +00:00
Adds music stack test coverage and fixes playlist cache and stream error handling
This commit is contained in:
1 parent
394f6b510c
commit
aba803b106
197 files changed
+29081
-34
No files matched your search
+69
@@ -0,0 +1,69 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.SharedKernel.UnitTests.Common.Enums.Playback;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="PlaybackDeliveryMode"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaybackDeliveryModeTests
|
||||
{
|
||||
[Fact]
|
||||
public void PlaybackDeliveryMode_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
PlaybackDeliveryMode[] values = Enum.GetValues<PlaybackDeliveryMode>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(values.Length, values.Distinct().Count());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlaybackDeliveryMode_WhenEnumeratingNames_ShouldHaveTheThreeDocumentedMembersInOrder()
|
||||
{
|
||||
// Act
|
||||
string[] names = Enum.GetNames<PlaybackDeliveryMode>();
|
||||
|
||||
// Assert
|
||||
string[] expectedNames =
|
||||
[
|
||||
nameof(PlaybackDeliveryMode.DirectPlay),
|
||||
nameof(PlaybackDeliveryMode.Remux),
|
||||
nameof(PlaybackDeliveryMode.Transcode)
|
||||
];
|
||||
Assert.Equal(expectedNames, names);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlaybackDeliveryMode_WhenEnumeratingValues_ShouldHaveTheDocumentedUnderlyingValues()
|
||||
{
|
||||
// Act
|
||||
PlaybackDeliveryMode[] values = Enum.GetValues<PlaybackDeliveryMode>();
|
||||
|
||||
// Assert
|
||||
PlaybackDeliveryMode[] expectedValues =
|
||||
[
|
||||
PlaybackDeliveryMode.DirectPlay,
|
||||
PlaybackDeliveryMode.Remux,
|
||||
PlaybackDeliveryMode.Transcode
|
||||
];
|
||||
int[] expectedUnderlyingValues = [0, 1, 2];
|
||||
Assert.Equal(expectedValues, values);
|
||||
Assert.Equal(expectedUnderlyingValues, values.Select(value => (int)value));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlaybackDeliveryMode_WhenDefaulted_ShouldBeDirectPlay()
|
||||
{
|
||||
// Act
|
||||
PlaybackDeliveryMode deliveryMode = default;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(PlaybackDeliveryMode.DirectPlay, deliveryMode);
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.SharedKernel.UnitTests.Common.Enums.Playback;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="PlaybackDeliveryShapeExtensions"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaybackDeliveryShapeExtensionsTests
|
||||
{
|
||||
[Fact]
|
||||
public void IsSeekable_WhenShapeIsByteRangeSeekable_ShouldReturnTrue()
|
||||
{
|
||||
// Act
|
||||
bool isSeekable = PlaybackDeliveryShape.ByteRangeSeekable.IsSeekable();
|
||||
|
||||
// Assert
|
||||
Assert.True(isSeekable);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsSeekable_WhenShapeIsTimeAddressedSegments_ShouldReturnTrue()
|
||||
{
|
||||
// Act
|
||||
bool isSeekable = PlaybackDeliveryShape.TimeAddressedSegments.IsSeekable();
|
||||
|
||||
// Assert
|
||||
Assert.True(isSeekable);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsSeekable_WhenShapeIsUndefined_ShouldReturnFalse()
|
||||
{
|
||||
// Arrange
|
||||
PlaybackDeliveryShape undefinedShape = (PlaybackDeliveryShape)99;
|
||||
|
||||
// Act
|
||||
bool isSeekable = undefinedShape.IsSeekable();
|
||||
|
||||
// Assert
|
||||
Assert.False(isSeekable);
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.SharedKernel.UnitTests.Common.Enums.Playback;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="PlaybackDeliveryShape"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaybackDeliveryShapeTests
|
||||
{
|
||||
[Fact]
|
||||
public void PlaybackDeliveryShape_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
PlaybackDeliveryShape[] values = Enum.GetValues<PlaybackDeliveryShape>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(values.Length, values.Distinct().Count());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlaybackDeliveryShape_WhenEnumeratingNames_ShouldHaveTheTwoDocumentedMembersInOrder()
|
||||
{
|
||||
// Act
|
||||
string[] names = Enum.GetNames<PlaybackDeliveryShape>();
|
||||
|
||||
// Assert
|
||||
string[] expectedNames =
|
||||
[
|
||||
nameof(PlaybackDeliveryShape.ByteRangeSeekable),
|
||||
nameof(PlaybackDeliveryShape.TimeAddressedSegments)
|
||||
];
|
||||
Assert.Equal(expectedNames, names);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlaybackDeliveryShape_WhenEnumeratingValues_ShouldHaveTheDocumentedUnderlyingValues()
|
||||
{
|
||||
// Act
|
||||
PlaybackDeliveryShape[] values = Enum.GetValues<PlaybackDeliveryShape>();
|
||||
|
||||
// Assert
|
||||
PlaybackDeliveryShape[] expectedValues =
|
||||
[
|
||||
PlaybackDeliveryShape.ByteRangeSeekable,
|
||||
PlaybackDeliveryShape.TimeAddressedSegments
|
||||
];
|
||||
int[] expectedUnderlyingValues = [0, 1];
|
||||
Assert.Equal(expectedValues, values);
|
||||
Assert.Equal(expectedUnderlyingValues, values.Select(value => (int)value));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlaybackDeliveryShape_WhenDefaulted_ShouldBeByteRangeSeekable()
|
||||
{
|
||||
// Act
|
||||
PlaybackDeliveryShape deliveryShape = default;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(PlaybackDeliveryShape.ByteRangeSeekable, deliveryShape);
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.SharedKernel.UnitTests.Common.Enums.Playback;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="PlaybackStreamingQuality"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaybackStreamingQualityTests
|
||||
{
|
||||
[Fact]
|
||||
public void PlaybackStreamingQuality_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
PlaybackStreamingQuality[] values = Enum.GetValues<PlaybackStreamingQuality>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(values.Length, values.Distinct().Count());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlaybackStreamingQuality_WhenEnumeratingNames_ShouldHaveTheFourDocumentedMembersInOrder()
|
||||
{
|
||||
// Act
|
||||
string[] names = Enum.GetNames<PlaybackStreamingQuality>();
|
||||
|
||||
// Assert
|
||||
string[] expectedNames =
|
||||
[
|
||||
nameof(PlaybackStreamingQuality.Auto),
|
||||
nameof(PlaybackStreamingQuality.Low),
|
||||
nameof(PlaybackStreamingQuality.Medium),
|
||||
nameof(PlaybackStreamingQuality.High)
|
||||
];
|
||||
Assert.Equal(expectedNames, names);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlaybackStreamingQuality_WhenEnumeratingValues_ShouldHaveTheDocumentedUnderlyingValues()
|
||||
{
|
||||
// Act
|
||||
PlaybackStreamingQuality[] values = Enum.GetValues<PlaybackStreamingQuality>();
|
||||
|
||||
// Assert
|
||||
PlaybackStreamingQuality[] expectedValues =
|
||||
[
|
||||
PlaybackStreamingQuality.Auto,
|
||||
PlaybackStreamingQuality.Low,
|
||||
PlaybackStreamingQuality.Medium,
|
||||
PlaybackStreamingQuality.High
|
||||
];
|
||||
int[] expectedUnderlyingValues = [0, 1, 2, 3];
|
||||
Assert.Equal(expectedValues, values);
|
||||
Assert.Equal(expectedUnderlyingValues, values.Select(value => (int)value));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlaybackStreamingQuality_WhenDefaulted_ShouldBeAuto()
|
||||
{
|
||||
// Act
|
||||
PlaybackStreamingQuality streamingQuality = default;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(PlaybackStreamingQuality.Auto, streamingQuality);
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.SharedKernel.UnitTests.Common.Enums.Playback;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="ReplayGainMode"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReplayGainModeTests
|
||||
{
|
||||
[Fact]
|
||||
public void ReplayGainMode_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
ReplayGainMode[] values = Enum.GetValues<ReplayGainMode>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(values.Length, values.Distinct().Count());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReplayGainMode_WhenEnumeratingNames_ShouldHaveTheThreeDocumentedMembersInOrder()
|
||||
{
|
||||
// Act
|
||||
string[] names = Enum.GetNames<ReplayGainMode>();
|
||||
|
||||
// Assert
|
||||
string[] expectedNames =
|
||||
[
|
||||
nameof(ReplayGainMode.Off),
|
||||
nameof(ReplayGainMode.Track),
|
||||
nameof(ReplayGainMode.Album)
|
||||
];
|
||||
Assert.Equal(expectedNames, names);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReplayGainMode_WhenEnumeratingValues_ShouldHaveTheDocumentedUnderlyingValues()
|
||||
{
|
||||
// Act
|
||||
ReplayGainMode[] values = Enum.GetValues<ReplayGainMode>();
|
||||
|
||||
// Assert
|
||||
ReplayGainMode[] expectedValues =
|
||||
[
|
||||
ReplayGainMode.Off,
|
||||
ReplayGainMode.Track,
|
||||
ReplayGainMode.Album
|
||||
];
|
||||
int[] expectedUnderlyingValues = [0, 1, 2];
|
||||
Assert.Equal(expectedValues, values);
|
||||
Assert.Equal(expectedUnderlyingValues, values.Select(value => (int)value));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReplayGainMode_WhenDefaulted_ShouldBeOff()
|
||||
{
|
||||
// Act
|
||||
ReplayGainMode replayGainMode = default;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(ReplayGainMode.Off, replayGainMode);
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playback;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.SharedKernel.UnitTests.Common.Enums.Playback;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="VuMeterOrientation"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class VuMeterOrientationTests
|
||||
{
|
||||
[Fact]
|
||||
public void VuMeterOrientation_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
VuMeterOrientation[] values = Enum.GetValues<VuMeterOrientation>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(values.Length, values.Distinct().Count());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VuMeterOrientation_WhenEnumeratingNames_ShouldHaveTheTwoDocumentedMembersInOrder()
|
||||
{
|
||||
// Act
|
||||
string[] names = Enum.GetNames<VuMeterOrientation>();
|
||||
|
||||
// Assert
|
||||
string[] expectedNames =
|
||||
[
|
||||
nameof(VuMeterOrientation.Vertical),
|
||||
nameof(VuMeterOrientation.Horizontal)
|
||||
];
|
||||
Assert.Equal(expectedNames, names);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VuMeterOrientation_WhenEnumeratingValues_ShouldHaveTheDocumentedUnderlyingValues()
|
||||
{
|
||||
// Act
|
||||
VuMeterOrientation[] values = Enum.GetValues<VuMeterOrientation>();
|
||||
|
||||
// Assert
|
||||
VuMeterOrientation[] expectedValues =
|
||||
[
|
||||
VuMeterOrientation.Vertical,
|
||||
VuMeterOrientation.Horizontal
|
||||
];
|
||||
int[] expectedUnderlyingValues = [0, 1];
|
||||
Assert.Equal(expectedValues, values);
|
||||
Assert.Equal(expectedUnderlyingValues, values.Select(value => (int)value));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void VuMeterOrientation_WhenDefaulted_ShouldBeVertical()
|
||||
{
|
||||
// Act
|
||||
VuMeterOrientation orientation = default;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(VuMeterOrientation.Vertical, orientation);
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.SharedKernel.UnitTests.Common.Enums.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="PlaylistMediaItemType"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistMediaItemTypeTests
|
||||
{
|
||||
[Fact]
|
||||
public void PlaylistMediaItemType_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
PlaylistMediaItemType[] values = Enum.GetValues<PlaylistMediaItemType>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(values.Length, values.Distinct().Count());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlaylistMediaItemType_WhenEnumeratingNames_ShouldHaveTheTwoDocumentedMembersInOrder()
|
||||
{
|
||||
// Act
|
||||
string[] names = Enum.GetNames<PlaylistMediaItemType>();
|
||||
|
||||
// Assert
|
||||
string[] expectedNames =
|
||||
[
|
||||
nameof(PlaylistMediaItemType.MusicTrack),
|
||||
nameof(PlaylistMediaItemType.VideoFile)
|
||||
];
|
||||
Assert.Equal(expectedNames, names);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlaylistMediaItemType_WhenEnumeratingValues_ShouldHaveTheDocumentedUnderlyingValues()
|
||||
{
|
||||
// Act
|
||||
PlaylistMediaItemType[] values = Enum.GetValues<PlaylistMediaItemType>();
|
||||
|
||||
// Assert
|
||||
PlaylistMediaItemType[] expectedValues =
|
||||
[
|
||||
PlaylistMediaItemType.MusicTrack,
|
||||
PlaylistMediaItemType.VideoFile
|
||||
];
|
||||
int[] expectedUnderlyingValues = [0, 1];
|
||||
Assert.Equal(expectedValues, values);
|
||||
Assert.Equal(expectedUnderlyingValues, values.Select(value => (int)value));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlaylistMediaItemType_WhenDefaulted_ShouldBeMusicTrack()
|
||||
{
|
||||
// Act
|
||||
PlaylistMediaItemType mediaItemType = default;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(PlaylistMediaItemType.MusicTrack, mediaItemType);
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.SharedKernel.UnitTests.Common.Enums.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="PlaylistType"/> enumeration.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistTypeTests
|
||||
{
|
||||
[Fact]
|
||||
public void PlaylistType_WhenEnumeratingValues_ShouldHaveNoDuplicateValues()
|
||||
{
|
||||
// Act
|
||||
PlaylistType[] values = Enum.GetValues<PlaylistType>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(values.Length, values.Distinct().Count());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlaylistType_WhenEnumeratingNames_ShouldHaveTheSingleDocumentedMember()
|
||||
{
|
||||
// Act
|
||||
string[] names = Enum.GetNames<PlaylistType>();
|
||||
|
||||
// Assert
|
||||
string[] expectedNames =
|
||||
[
|
||||
nameof(PlaylistType.Music)
|
||||
];
|
||||
Assert.Equal(expectedNames, names);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlaylistType_WhenEnumeratingValues_ShouldHaveTheDocumentedUnderlyingValues()
|
||||
{
|
||||
// Act
|
||||
PlaylistType[] values = Enum.GetValues<PlaylistType>();
|
||||
|
||||
// Assert
|
||||
PlaylistType[] expectedValues =
|
||||
[
|
||||
PlaylistType.Music
|
||||
];
|
||||
int[] expectedUnderlyingValues = [0];
|
||||
Assert.Equal(expectedValues, values);
|
||||
Assert.Equal(expectedUnderlyingValues, values.Select(value => (int)value));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlaylistType_WhenDefaulted_ShouldBeMusic()
|
||||
{
|
||||
// Act
|
||||
PlaylistType playlistType = default;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(PlaylistType.Music, playlistType);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user