Skip to content

Commit

Permalink
Fixed issue with movement removal
Browse files Browse the repository at this point in the history
  • Loading branch information
sandreas committed Mar 9, 2024
1 parent 7e5699b commit ffcad81
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
25 changes: 17 additions & 8 deletions Sandreas.AudioMetadata.Tests/AudioMetadata/MetadataTrackTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,24 @@ namespace Sandreas.AudioMetadata.Tests.AudioMetadata;
public class MetadataTrackTest
{
[Fact]
public void TestMappedProperties()
public void TestRemoveMovement()
{
var exception = Record.Exception(() =>
var t = new MetadataTrack
{
var track = new MetadataTrack
{
EncodingTool = "testing"
};
});
Assert.Null(exception);
Movement = "1"
};
t.RemoveMetadataPropertyValue(MetadataProperty.Movement);
Assert.Null(t.Movement);
}

[Fact]
public void TestRecordingDate()
{
var t = new MetadataTrack
{
RecordingDate = DateTime.Today
};
t.RemoveMetadataPropertyValue(MetadataProperty.RecordingDate);
Assert.True(t.RecordingDate <= DateTime.MinValue);
}
}
5 changes: 5 additions & 0 deletions Sandreas.AudioMetadata/AudioMetadata/IMetadataExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ public static void SetMetadataPropertyValue(this IMetadata metadata, MetadataPro
/// <returns></returns>
private static object? GetPropertyValueThatLeadsToRemoval(this IMetadata metadata, MetadataProperty property)
{
if (property == MetadataProperty.Movement)
{
return null;
}

if (metadata.GetMetadataPropertyType(property) == typeof(string))
{
return "";
Expand Down
4 changes: 4 additions & 0 deletions Sandreas.AudioMetadata/AudioMetadata/MetadataTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ public string? Movement
set {
// movement MUST contain an integer value, which leads to an exception, if a string like 1.5 is stored
// to store a non-integer value, use Part instead
if (value == "")
{
value = null;
}
if (value == null || int.TryParse(value, out _))
{
SeriesPart = value;
Expand Down

0 comments on commit ffcad81

Please sign in to comment.