diff --git a/AudioCuesheetEditor/AudioCuesheetEditor.csproj b/AudioCuesheetEditor/AudioCuesheetEditor.csproj index 46b61905..9fe666d8 100644 --- a/AudioCuesheetEditor/AudioCuesheetEditor.csproj +++ b/AudioCuesheetEditor/AudioCuesheetEditor.csproj @@ -22,8 +22,8 @@ - - + + @@ -61,8 +61,8 @@ - - + + diff --git a/AudioCuesheetEditor/Model/AudioCuesheet/Cuesheet.cs b/AudioCuesheetEditor/Model/AudioCuesheet/Cuesheet.cs index 5c868473..b2eb9594 100644 --- a/AudioCuesheetEditor/Model/AudioCuesheet/Cuesheet.cs +++ b/AudioCuesheetEditor/Model/AudioCuesheet/Cuesheet.cs @@ -29,64 +29,46 @@ public enum MoveDirection Down } - public class TrackAddRemoveEventArgs : EventArgs + public class TrackAddRemoveEventArgs(Track track) : EventArgs { - public TrackAddRemoveEventArgs(Track track) - { - Track = track; - } - - public Track Track { get; } + public Track Track { get; } = track; } - public class SplitPointAddRemoveEventArgs : EventArgs + public class CuesheetSectionAddRemoveEventArgs(CuesheetSection section) : EventArgs { - public SplitPointAddRemoveEventArgs(SplitPoint splitPoint) - { - SplitPoint = splitPoint; - } - - public SplitPoint SplitPoint { get; } + public CuesheetSection Section { get; } = section; } - public class Cuesheet : Validateable, ICuesheetEntity, ITraceable + public class Cuesheet(TraceChangeManager? traceChangeManager = null) : Validateable, ICuesheetEntity, ITraceable { public const String MimeType = "text/*"; public const String FileExtension = ".cue"; private readonly object syncLock = new(); - private List tracks; + private List tracks = []; private String? artist; private String? title; private Audiofile? audiofile; private CDTextfile? cDTextfile; - private Cataloguenumber catalogueNumber; + private Cataloguenumber catalogueNumber = new(); private DateTime? recordingStart; - private readonly List> currentlyHandlingLinkedTrackPropertyChange = new(); - private List splitPoints; + private readonly List> currentlyHandlingLinkedTrackPropertyChange = []; + private List sections = []; public event EventHandler? AudioFileChanged; public event EventHandler? TraceablePropertyChanged; public event EventHandler? TrackAdded; public event EventHandler? TrackRemoved; - public event EventHandler? SplitPointAdded; - public event EventHandler? SplitPointRemoved; + public event EventHandler? SectionAdded; + public event EventHandler? SectionRemoved; public event EventHandler? CuesheetImported; - public Cuesheet(TraceChangeManager? traceChangeManager = null) - { - tracks = new(); - catalogueNumber = new(); - splitPoints = new(); - TraceChangeManager = traceChangeManager; - } - [JsonInclude] public IReadOnlyCollection Tracks { - get { return tracks.AsReadOnly(); } - private set + get => tracks.AsReadOnly(); + private set { foreach (var track in tracks) { @@ -94,7 +76,7 @@ private set track.IsLinkedToPreviousTrackChanged -= Track_IsLinkedToPreviousTrackChanged; track.Cuesheet = null; } - tracks = value.ToList(); + tracks = [.. value]; foreach (var track in tracks) { track.Cuesheet = this; @@ -103,7 +85,7 @@ private set } } } - + public String? Artist { get => artist; @@ -197,46 +179,45 @@ public TimeSpan? RecordingTime public Boolean IsImporting { get; private set; } [JsonInclude] - public IReadOnlyCollection SplitPoints + public IReadOnlyCollection Sections { - get => splitPoints; + get => sections; private set { - foreach(var splitpoint in value.Where(x => x.Cuesheet != this)) + foreach(var section in value.Where(x => x.Cuesheet != this)) { - splitpoint.Cuesheet = this; + section.Cuesheet = this; } - splitPoints = value.ToList(); + sections = [.. value]; } } [JsonIgnore] - public TraceChangeManager? TraceChangeManager { get; } + public TraceChangeManager? TraceChangeManager { get; } = traceChangeManager; - public SplitPoint AddSplitPoint() + public CuesheetSection AddSection() { - var previousValue = new List(splitPoints); - var splitPoint = new SplitPoint(this); - splitPoints.Add(splitPoint); - SplitPointAdded?.Invoke(this, new SplitPointAddRemoveEventArgs(splitPoint)); - OnTraceablePropertyChanged(previousValue, nameof(SplitPoints)); - return splitPoint; + var previousValue = new List(sections); + var section = new CuesheetSection(this); + sections.Add(section); + SectionAdded?.Invoke(this, new CuesheetSectionAddRemoveEventArgs(section)); + OnTraceablePropertyChanged(previousValue, nameof(Sections)); + return section; } - public void RemoveSplitPoint(SplitPoint splitPoint) + public void RemoveSection(CuesheetSection section) { - var previousValue = new List(splitPoints); - if (splitPoints.Remove(splitPoint)) + var previousValue = new List(sections); + if (sections.Remove(section)) { - OnTraceablePropertyChanged(previousValue, nameof(SplitPoints)); - SplitPointRemoved?.Invoke(this, new SplitPointAddRemoveEventArgs(splitPoint)); + OnTraceablePropertyChanged(previousValue, nameof(Sections)); + SectionRemoved?.Invoke(this, new CuesheetSectionAddRemoveEventArgs(section)); } } - public SplitPoint? GetSplitPointAtTrack(Track track) + public CuesheetSection? GetSectionAtTrack(Track track) { - SplitPoint? splitPointAtTrack = SplitPoints?.FirstOrDefault(x => track.Begin < x.Moment && track.End >= x.Moment); - return splitPointAtTrack; + return Sections?.FirstOrDefault(x => track.Begin < x.Begin && track.End >= x.Begin); } /// @@ -247,10 +228,6 @@ public void RemoveSplitPoint(SplitPoint splitPoint) public Track? GetPreviousLinkedTrack(Track track) { Track? previousLinkedTrack = null; - if (track == null) - { - throw new ArgumentNullException(nameof(track)); - } if (track.IsLinkedToPreviousTrack) { var index = tracks.IndexOf(track); @@ -462,7 +439,7 @@ protected override ValidationResult Validate(string property) validationStatus = ValidationStatus.Success; if (Tracks.Count <= 0) { - validationMessages ??= new(); + validationMessages ??= []; validationMessages.Add(new ValidationMessage("{0} has invalid Count ({1})!", nameof(Tracks), 0)); } else @@ -473,7 +450,7 @@ protected override ValidationResult Validate(string property) .Where(grp => grp.Count() > 1); if (tracksWithSamePosition.Any()) { - validationMessages ??= new(); + validationMessages ??= []; foreach (var track in tracksWithSamePosition) { foreach (var trackWithSamePosition in track) @@ -489,7 +466,7 @@ protected override ValidationResult Validate(string property) && (x.Equals(track) == false)); if (tracksBetween.Any()) { - validationMessages ??= new(); + validationMessages ??= []; foreach (var trackBetween in tracksBetween) { validationMessages.Add(new ValidationMessage("{0}({1},{2},{3},{4},{5}) is overlapping with {0}({6},{7},{8},{9},{10}). Please make shure the timeinterval is only used once!", nameof(Track), track.Position != null ? track.Position : String.Empty, track.Artist ?? String.Empty, track.Title ?? String.Empty, track.Begin != null ? track.Begin : String.Empty, track.End != null ? track.End : String.Empty, trackBetween.Position != null ? trackBetween.Position : String.Empty, trackBetween.Artist ?? String.Empty, trackBetween.Title ?? String.Empty, trackBetween.Begin != null ? trackBetween.Begin : String.Empty, trackBetween.End != null ? trackBetween.End : String.Empty)); @@ -502,7 +479,7 @@ protected override ValidationResult Validate(string property) validationStatus = ValidationStatus.Success; if (Audiofile == null) { - validationMessages ??= new(); + validationMessages ??= []; validationMessages.Add(new ValidationMessage("{0} has no value!", nameof(Audiofile))); } break; @@ -510,7 +487,7 @@ protected override ValidationResult Validate(string property) validationStatus = ValidationStatus.Success; if (String.IsNullOrEmpty(Artist)) { - validationMessages ??= new(); + validationMessages ??= []; validationMessages.Add(new ValidationMessage("{0} has no value!", nameof(Artist))); } break; @@ -518,7 +495,7 @@ protected override ValidationResult Validate(string property) validationStatus = ValidationStatus.Success; if (String.IsNullOrEmpty(Title)) { - validationMessages ??= new(); + validationMessages ??= []; validationMessages.Add(new ValidationMessage("{0} has no value!", nameof(Title))); } break; @@ -594,10 +571,10 @@ private void CopyValues(Cuesheet cuesheet, ApplicationOptions applicationOptions var track = new Track(importTrack, false); AddTrack(track, applicationOptions); } - // Copy splitpoints - foreach (var splitPoint in cuesheet.SplitPoints) + // Copy sections + foreach (var splitPoint in cuesheet.Sections) { - var newSplitPoint = AddSplitPoint(); + var newSplitPoint = AddSection(); newSplitPoint.CopyValues(splitPoint); } } @@ -701,14 +678,6 @@ private void Audiofile_ContentStreamLoaded(object? sender, EventArgs e) private void SwitchTracks(Track track1, Track track2) { - if (track1 == null) - { - throw new ArgumentNullException(nameof(track1)); - } - if (track2 == null) - { - throw new ArgumentNullException(nameof(track2)); - } var indexTrack1 = tracks.IndexOf(track1); var indexTrack2 = tracks.IndexOf(track2); //Switch track positions in array diff --git a/AudioCuesheetEditor/Model/AudioCuesheet/Track.cs b/AudioCuesheetEditor/Model/AudioCuesheet/Track.cs index e34dd1d3..eadd50f1 100644 --- a/AudioCuesheetEditor/Model/AudioCuesheet/Track.cs +++ b/AudioCuesheetEditor/Model/AudioCuesheet/Track.cs @@ -27,7 +27,7 @@ public enum SetFlagMode public class Track : Validateable, ICuesheetEntity, ITraceable { - public static readonly List AllPropertyNames = new() { nameof(IsLinkedToPreviousTrack), nameof(Position), nameof(Artist), nameof(Title), nameof(Begin), nameof(End), nameof(Flags), nameof(PreGap), nameof(PostGap), nameof(Length) }; + public static readonly List AllPropertyNames = [nameof(IsLinkedToPreviousTrack), nameof(Position), nameof(Artist), nameof(Title), nameof(Begin), nameof(End), nameof(Flags), nameof(PreGap), nameof(PostGap), nameof(Length)]; private uint? position; private String? artist; @@ -35,7 +35,7 @@ public class Track : Validateable, ICuesheetEntity, ITraceable private TimeSpan? begin; private TimeSpan? end; private TimeSpan? _length; - private List flags = new(); + private List flags = []; private Boolean isLinkedToPreviousTrack; private Cuesheet? cuesheet; private TimeSpan? preGap; @@ -161,11 +161,7 @@ public IReadOnlyCollection Flags get { return flags.AsReadOnly(); } private set { - if (value == null) - { - throw new ArgumentNullException(nameof(Flags)); - } - flags = value.ToList(); + flags = [.. value]; } } [JsonIgnore] @@ -368,16 +364,12 @@ public void CopyValues(Track track, Boolean setCuesheet = true, Boolean setIsLin /// public void SetFlag(Flag flag, SetFlagMode flagMode) { - if (flag == null) - { - throw new ArgumentNullException(nameof(flag)); - } var previousValue = flags; if ((flagMode == SetFlagMode.Add) && (Flags.Contains(flag) == false)) { flags.Add(flag); } - if ((flagMode == SetFlagMode.Remove) && (Flags.Contains(flag))) + if ((flagMode == SetFlagMode.Remove) && Flags.Contains(flag)) { flags.Remove(flag); } @@ -401,14 +393,14 @@ protected override ValidationResult Validate(string property) validationStatus = ValidationStatus.Success; if (Position == null) { - validationMessages ??= new(); + validationMessages ??= []; validationMessages.Add(new ValidationMessage("{0} has no value!", nameof(Position))); } else { if (Position == 0) { - validationMessages ??= new(); + validationMessages ??= []; validationMessages.Add(new ValidationMessage("{0} may not be 0!", nameof(Position))); } else @@ -419,7 +411,7 @@ protected override ValidationResult Validate(string property) var positionTrackShouldHave = Cuesheet.Tracks.OrderBy(x => x.Begin ?? TimeSpan.MaxValue).ThenBy(x => x.Position).ToList().IndexOf(this) + 1; if (positionTrackShouldHave != Position) { - validationMessages ??= new(); + validationMessages ??= []; validationMessages.Add(new ValidationMessage("Track({0},{1},{2},{3},{4}) does not have the correct position '{5}'!", Position, Artist ?? String.Empty, Title ?? String.Empty, Begin != null ? Begin : String.Empty, End != null ? End : String.Empty, positionTrackShouldHave)); } } @@ -430,14 +422,14 @@ protected override ValidationResult Validate(string property) validationStatus = ValidationStatus.Success; if (Begin == null) { - validationMessages ??= new(); + validationMessages ??= []; validationMessages.Add(new ValidationMessage("{0} has no value!", nameof(Begin))); } else { if (Begin < TimeSpan.Zero) { - validationMessages ??= new(); + validationMessages ??= []; validationMessages.Add(new ValidationMessage("{0} must be equal or greater zero!", nameof(Begin))); } } @@ -446,14 +438,14 @@ protected override ValidationResult Validate(string property) validationStatus = ValidationStatus.Success; if (End == null) { - validationMessages ??= new(); + validationMessages ??= []; validationMessages.Add(new ValidationMessage("{0} has no value!", nameof(End))); } else { if (End < TimeSpan.Zero) { - validationMessages ??= new(); + validationMessages ??= []; validationMessages.Add(new ValidationMessage("{0} must be equal or greater zero!", nameof(End))); } } @@ -462,7 +454,7 @@ protected override ValidationResult Validate(string property) validationStatus = ValidationStatus.Success; if (Length == null) { - validationMessages ??= new(); + validationMessages ??= []; validationMessages.Add(new ValidationMessage("{0} has no value!", nameof(Length))); } break; diff --git a/AudioCuesheetEditor/Model/IO/Export/SplitPoint.cs b/AudioCuesheetEditor/Model/IO/Export/CuesheetSection.cs similarity index 63% rename from AudioCuesheetEditor/Model/IO/Export/SplitPoint.cs rename to AudioCuesheetEditor/Model/IO/Export/CuesheetSection.cs index 78e782c7..8fc38bc7 100644 --- a/AudioCuesheetEditor/Model/IO/Export/SplitPoint.cs +++ b/AudioCuesheetEditor/Model/IO/Export/CuesheetSection.cs @@ -20,26 +20,34 @@ namespace AudioCuesheetEditor.Model.IO.Export { - public class SplitPoint : Validateable, ITraceable + public class CuesheetSection : Validateable, ITraceable { private Cuesheet? cuesheet; - private TimeSpan? moment; + private TimeSpan? begin; + private TimeSpan? end; private String? artist; private String? title; private String? audiofileName; public event EventHandler? TraceablePropertyChanged; - public SplitPoint(Cuesheet cuesheet) + public CuesheetSection(Cuesheet cuesheet) { Cuesheet = cuesheet; artist = Cuesheet.Artist; title = Cuesheet.Title; audiofileName = Cuesheet.Audiofile?.Name; + //Try to set begin + begin = Cuesheet.Sections?.FirstOrDefault()?.End; + if (Begin.HasValue == false) + { + begin = Cuesheet.Tracks.Min(x => x.Begin); + } + end = Cuesheet.Tracks.Max(x => x.End); } [JsonConstructor] - public SplitPoint() { } + public CuesheetSection() { } public Cuesheet? Cuesheet { get => cuesheet; @@ -80,15 +88,27 @@ public String? Title } } - public TimeSpan? Moment + public TimeSpan? Begin { - get => moment; + get => begin; set { - var previousValue = moment; - moment = value; - OnValidateablePropertyChanged(nameof(Moment)); - OnTraceablePropertyChanged(previousValue, nameof(Moment)); + var previousValue = begin; + begin = value; + OnValidateablePropertyChanged(nameof(Begin)); + OnTraceablePropertyChanged(previousValue, nameof(Begin)); + } + } + + public TimeSpan? End + { + get => end; + set + { + var previousValue = end; + end = value; + OnValidateablePropertyChanged(nameof(End)); + OnTraceablePropertyChanged(previousValue, nameof(End)); } } @@ -104,11 +124,11 @@ public String? AudiofileName } } - public void CopyValues(SplitPoint splitPoint) + public void CopyValues(CuesheetSection splitPoint) { Artist = splitPoint.Artist; Title = splitPoint.Title; - Moment = splitPoint.Moment; + Begin = splitPoint.Begin; } protected override ValidationResult Validate(string property) @@ -117,20 +137,47 @@ protected override ValidationResult Validate(string property) List? validationMessages = null; switch (property) { - case nameof(Moment): + case nameof(Begin): validationStatus = ValidationStatus.Success; - if (Moment == null) + if (Begin == null) { - validationMessages ??= new(); - validationMessages.Add(new ValidationMessage("{0} has no value!", nameof(Moment))); + validationMessages ??= []; + validationMessages.Add(new ValidationMessage("{0} has no value!", nameof(Begin))); + } + else + { + var minBegin = Cuesheet?.Tracks.Min(x => x.Begin); + if (Begin < minBegin) + { + validationMessages ??= []; + validationMessages.Add(new ValidationMessage("{0} should be greater than or equal '{1}'!", nameof(Begin), minBegin)); + } + if (Begin > End) + { + validationMessages ??= []; + validationMessages.Add(new ValidationMessage("{0} should be less than or equal '{1}'!", nameof(Begin), End)); + } + } + break; + case nameof(End): + validationStatus = ValidationStatus.Success; + if (End == null) + { + validationMessages ??= []; + validationMessages.Add(new ValidationMessage("{0} has no value!", nameof(End))); } else { var maxEnd = Cuesheet?.Tracks.Max(x => x.End); - if (Moment > maxEnd) + if (End > maxEnd) + { + validationMessages ??= []; + validationMessages.Add(new ValidationMessage("{0} should be less than or equal '{1}'!", nameof(End), maxEnd)); + } + if (End < Begin) { - validationMessages ??= new(); - validationMessages.Add(new ValidationMessage("{0} should be equal or less to '{1}'!", nameof(Moment), maxEnd)); + validationMessages ??= []; + validationMessages.Add(new ValidationMessage("{0} should be greater than or equal '{1}'!", nameof(End), Begin)); } } break; @@ -138,7 +185,7 @@ protected override ValidationResult Validate(string property) validationStatus = ValidationStatus.Success; if (String.IsNullOrEmpty(Artist)) { - validationMessages ??= new(); + validationMessages ??= []; validationMessages.Add(new ValidationMessage("{0} has no value!", nameof(Artist))); } break; @@ -146,7 +193,7 @@ protected override ValidationResult Validate(string property) validationStatus = ValidationStatus.Success; if (String.IsNullOrEmpty(Title)) { - validationMessages ??= new(); + validationMessages ??= []; validationMessages.Add(new ValidationMessage("{0} has no value!", nameof(Title))); } break; @@ -154,7 +201,7 @@ protected override ValidationResult Validate(string property) validationStatus = ValidationStatus.Success; if (String.IsNullOrEmpty(AudiofileName)) { - validationMessages ??= new(); + validationMessages ??= []; validationMessages.Add(new ValidationMessage("{0} has no value!", nameof(AudiofileName))); } break; diff --git a/AudioCuesheetEditor/Model/IO/Export/ExportfileGenerator.cs b/AudioCuesheetEditor/Model/IO/Export/ExportfileGenerator.cs index ac448d0d..a587558e 100644 --- a/AudioCuesheetEditor/Model/IO/Export/ExportfileGenerator.cs +++ b/AudioCuesheetEditor/Model/IO/Export/ExportfileGenerator.cs @@ -30,86 +30,50 @@ public enum ExportType Exportprofile } - public class ExportfileGenerator : Validateable + public class ExportfileGenerator(ExportType exportType, Cuesheet cuesheet, Exportprofile? exportprofile = null, ApplicationOptions? applicationOptions = null) : Validateable { - public Cuesheet Cuesheet { get; } - public Exportprofile? Exportprofile { get; set; } - public ApplicationOptions? ApplicationOptions { get; set; } - public ExportType ExportType { get; set; } - - public ExportfileGenerator(ExportType exportType, Cuesheet cuesheet, Exportprofile? exportprofile = null, ApplicationOptions? applicationOptions = null) - { - ExportType = exportType; - Cuesheet = cuesheet; - Exportprofile = exportprofile; - ApplicationOptions = applicationOptions; - } + public Cuesheet Cuesheet { get; } = cuesheet; + public Exportprofile? Exportprofile { get; set; } = exportprofile; + public ApplicationOptions? ApplicationOptions { get; set; } = applicationOptions; + public ExportType ExportType { get; set; } = exportType; public IReadOnlyCollection GenerateExportfiles() { - List exportfiles = new(); + List exportfiles = []; if (Validate().Status != ValidationStatus.Error) { - if (Cuesheet.SplitPoints.Count != 0) + if (Cuesheet.Sections.Count != 0) { - TimeSpan? previousSplitPointMoment = null; - var begin = Cuesheet.Tracks.Min(x => x.Begin); var counter = 1; String? content = null; String filename = String.Empty; String? audioFileName = null; - foreach (var splitPoint in Cuesheet.SplitPoints.OrderBy(x => x.Moment)) + foreach (var section in Cuesheet.Sections.OrderBy(x => x.Begin)) { - audioFileName = splitPoint.AudiofileName; - if (splitPoint.Validate().Status == ValidationStatus.Success) + audioFileName = section.AudiofileName; + if (section.Validate().Status == ValidationStatus.Success) { switch (ExportType) { case ExportType.Cuesheet: - content = WriteCuesheet(audioFileName, previousSplitPointMoment, splitPoint); + content = WriteCuesheet(audioFileName, section); filename = String.Format("{0}({1}){2}", Path.GetFileNameWithoutExtension(ApplicationOptions?.CuesheetFilename), counter, Cuesheet.FileExtension); break; case ExportType.Exportprofile: if (Exportprofile != null) { - content = WriteExport(audioFileName, previousSplitPointMoment, splitPoint); + content = WriteExport(audioFileName, section); filename = String.Format("{0}({1}){2}", Path.GetFileNameWithoutExtension(Exportprofile.Filename), counter, Path.GetExtension(Exportprofile.Filename)); } break; } if (content != null) { - if (previousSplitPointMoment != null) - { - begin = previousSplitPointMoment; - } - exportfiles.Add(new Exportfile() { Name = filename, Content = Encoding.UTF8.GetBytes(content), Begin = begin, End = splitPoint.Moment }); + exportfiles.Add(new Exportfile() { Name = filename, Content = Encoding.UTF8.GetBytes(content), Begin = section.Begin, End = section.End }); } - previousSplitPointMoment = splitPoint.Moment; counter++; } } - //After a split point attach the last part - audioFileName = String.Format("{0}({1}){2}", Path.GetFileNameWithoutExtension(Cuesheet.Audiofile?.Name), counter, Path.GetExtension(Cuesheet.Audiofile?.Name)); - switch (ExportType) - { - case ExportType.Cuesheet: - content = WriteCuesheet(audioFileName, previousSplitPointMoment); - filename = String.Format("{0}({1}){2}", Path.GetFileNameWithoutExtension(ApplicationOptions?.CuesheetFilename), counter, Cuesheet.FileExtension); - break; - case ExportType.Exportprofile: - if (Exportprofile != null) - { - content = WriteExport(audioFileName, previousSplitPointMoment); - filename = String.Format("{0}({1}){2}", Path.GetFileNameWithoutExtension(Exportprofile.Filename), counter, Path.GetExtension(Exportprofile.Filename)); - } - break; - } - if (content != null) - { - var end = Cuesheet.Tracks.Max(x => x.End); - exportfiles.Add(new Exportfile() { Name = filename, Content = Encoding.UTF8.GetBytes(content), Begin = previousSplitPointMoment, End = end }); - } } else { @@ -154,7 +118,7 @@ public IReadOnlyCollection GenerateExportfiles() return exportfiles; } - private string WriteCuesheet(String? audiofileName, TimeSpan? from = null, SplitPoint? splitPoint = null) + private string WriteCuesheet(String? audiofileName, CuesheetSection? section = null) { var builder = new StringBuilder(); if (Cuesheet.Cataloguenumber != null && string.IsNullOrEmpty(Cuesheet.Cataloguenumber.Value) == false && Cuesheet.Cataloguenumber.Validate().Status != ValidationStatus.Error) @@ -165,24 +129,13 @@ private string WriteCuesheet(String? audiofileName, TimeSpan? from = null, Split { builder.AppendLine(string.Format("{0} \"{1}\"", CuesheetConstants.CuesheetCDTextfile, Cuesheet.CDTextfile.Name)); } - builder.AppendLine(string.Format("{0} \"{1}\"", CuesheetConstants.CuesheetTitle, splitPoint != null ? splitPoint.Title : Cuesheet.Title)); - builder.AppendLine(string.Format("{0} \"{1}\"", CuesheetConstants.CuesheetArtist, splitPoint != null ? splitPoint.Artist : Cuesheet.Artist)); + builder.AppendLine(string.Format("{0} \"{1}\"", CuesheetConstants.CuesheetTitle, section != null ? section.Title : Cuesheet.Title)); + builder.AppendLine(string.Format("{0} \"{1}\"", CuesheetConstants.CuesheetArtist, section != null ? section.Artist : Cuesheet.Artist)); builder.AppendLine(string.Format("{0} \"{1}\" {2}", CuesheetConstants.CuesheetFileName, audiofileName, Cuesheet.Audiofile?.AudioFileType)); IEnumerable tracks = Cuesheet.Tracks.OrderBy(x => x.Position); - if (from != null && splitPoint != null) - { - tracks = Cuesheet.Tracks.Where(x => x.Begin <= splitPoint.Moment && x.End >= from).OrderBy(x => x.Position); - } - else + if (section != null) { - if (from != null) - { - tracks = Cuesheet.Tracks.Where(x => x.End >= from).OrderBy(x => x.Position); - } - if (splitPoint != null) - { - tracks = Cuesheet.Tracks.Where(x => x.Begin <= splitPoint.Moment).OrderBy(x => x.Position); - } + tracks = Cuesheet.Tracks.Where(x => x.Begin <= section.End && x.End >= section.Begin).OrderBy(x => x.Position); } if (tracks.Any()) { @@ -204,15 +157,15 @@ private string WriteCuesheet(String? audiofileName, TimeSpan? from = null, Split if (track.Begin.HasValue) { var begin = track.Begin.Value; - if (from != null) + if ((section != null) && (section.Begin.HasValue)) { - if (from >= track.Begin) + if (section.Begin >= track.Begin) { begin = TimeSpan.Zero; } else { - begin = track.Begin.Value - from.Value; + begin = track.Begin.Value - section.Begin.Value; } } builder.AppendLine(string.Format("{0}{1}{2} {3:00}:{4:00}:{5:00}", CuesheetConstants.Tab, CuesheetConstants.Tab, CuesheetConstants.TrackIndex01, Math.Floor(begin.TotalMinutes), begin.Seconds, begin.Milliseconds * 75 / 1000)); @@ -230,14 +183,14 @@ private string WriteCuesheet(String? audiofileName, TimeSpan? from = null, Split return builder.ToString(); } - private String WriteExport(String? audiofileName, TimeSpan? from = null, SplitPoint? splitPoint = null) + private String WriteExport(String? audiofileName, CuesheetSection? section = null) { var builder = new StringBuilder(); if (Exportprofile != null) { var header = Exportprofile.SchemeHead - .Replace(Exportprofile.SchemeCuesheetArtist, splitPoint != null ? splitPoint.Artist : Cuesheet.Artist) - .Replace(Exportprofile.SchemeCuesheetTitle, splitPoint != null ? splitPoint.Title : Cuesheet.Title) + .Replace(Exportprofile.SchemeCuesheetArtist, section != null ? section.Artist : Cuesheet.Artist) + .Replace(Exportprofile.SchemeCuesheetTitle, section != null ? section.Title : Cuesheet.Title) .Replace(Exportprofile.SchemeCuesheetAudiofile, audiofileName) .Replace(Exportprofile.SchemeCuesheetCDTextfile, Cuesheet.CDTextfile?.Name) .Replace(Exportprofile.SchemeCuesheetCatalogueNumber, Cuesheet.Cataloguenumber?.Value) @@ -246,20 +199,9 @@ private String WriteExport(String? audiofileName, TimeSpan? from = null, SplitPo .Replace(Exportprofile.SchemeTime, DateTime.Now.ToLongTimeString()); builder.AppendLine(header); IEnumerable tracks = Cuesheet.Tracks.OrderBy(x => x.Position); - if (from != null && splitPoint != null) - { - tracks = Cuesheet.Tracks.Where(x => x.Begin <= splitPoint.Moment && x.End >= from).OrderBy(x => x.Position); - } - else + if (section != null) { - if (from != null) - { - tracks = Cuesheet.Tracks.Where(x => x.End >= from).OrderBy(x => x.Position); - } - if (splitPoint != null) - { - tracks = Cuesheet.Tracks.Where(x => x.Begin <= splitPoint.Moment).OrderBy(x => x.Position); - } + tracks = Cuesheet.Tracks.Where(x => x.Begin <= section.End && x.End >= section.Begin).OrderBy(x => x.Position); } if (tracks.Any()) { @@ -272,17 +214,17 @@ private String WriteExport(String? audiofileName, TimeSpan? from = null, SplitPo if (track.Begin.HasValue) { begin = track.Begin.Value; - if (from != null) + if (section?.Begin != null) { - if (from >= track.Begin) + if (section.Begin >= track.Begin) { begin = TimeSpan.Zero; } else { - begin = track.Begin.Value - from.Value; + begin = track.Begin.Value - section.Begin.Value; } - end = track.End - from.Value; + end = track.End - section.Begin.Value; } } else @@ -306,8 +248,8 @@ private String WriteExport(String? audiofileName, TimeSpan? from = null, SplitPo } } var footer = Exportprofile.SchemeFooter - .Replace(Exportprofile.SchemeCuesheetArtist, splitPoint != null ? splitPoint.Artist : Cuesheet.Artist) - .Replace(Exportprofile.SchemeCuesheetTitle, splitPoint != null ? splitPoint.Title : Cuesheet.Title) + .Replace(Exportprofile.SchemeCuesheetArtist, section != null ? section.Artist : Cuesheet.Artist) + .Replace(Exportprofile.SchemeCuesheetTitle, section != null ? section.Title : Cuesheet.Title) .Replace(Exportprofile.SchemeCuesheetAudiofile, audiofileName) .Replace(Exportprofile.SchemeCuesheetCDTextfile, Cuesheet.CDTextfile?.Name) .Replace(Exportprofile.SchemeCuesheetCatalogueNumber, Cuesheet.Cataloguenumber?.Value) diff --git a/AudioCuesheetEditor/Model/IO/Import/TextImportfile.cs b/AudioCuesheetEditor/Model/IO/Import/TextImportfile.cs index 87829dcd..9cacc17f 100644 --- a/AudioCuesheetEditor/Model/IO/Import/TextImportfile.cs +++ b/AudioCuesheetEditor/Model/IO/Import/TextImportfile.cs @@ -44,7 +44,7 @@ public TextImportfile(MemoryStream fileContent, ImportOptions? importOptions = n textImportScheme = new TextImportScheme(); fileContent.Position = 0; using var reader = new StreamReader(fileContent); - List lines = new(); + List lines = []; while (reader.EndOfStream == false) { lines.Add(reader.ReadLine()); @@ -132,7 +132,7 @@ private void Analyse() FileContentRecognized = null; AnalyseException = null; Boolean cuesheetRecognized = false; - List recognizedFileContent = new(); + List recognizedFileContent = []; foreach (var line in FileContent) { var recognizedLine = line; diff --git a/AudioCuesheetEditor/Pages/EditSplitpoints.razor b/AudioCuesheetEditor/Pages/EditSections.razor similarity index 77% rename from AudioCuesheetEditor/Pages/EditSplitpoints.razor rename to AudioCuesheetEditor/Pages/EditSections.razor index c551484b..4f9c19ea 100644 --- a/AudioCuesheetEditor/Pages/EditSplitpoints.razor +++ b/AudioCuesheetEditor/Pages/EditSections.razor @@ -17,7 +17,7 @@ along with Foobar. If not, see --> @implements IDisposable -@inject ITextLocalizer _localizer +@inject ITextLocalizer _localizer @inject SessionStateContainer _sessionStateContainer @inject ITextLocalizer _validationMessageLocalizer @inject DateTimeUtility _dateTimeUtility @@ -32,13 +32,13 @@ along with Foobar. If not, see { - @@ -49,22 +49,23 @@ along with Foobar. If not, see @_localizer["Controls"] - @_localizer["Moment"] + @_localizer["Begin"] + @_localizer["End"] @_localizer["CD artist"] @_localizer["CD title"] @_localizer["Audiofile name"] - @foreach (var splitPoint in Cuesheet.SplitPoints) + @foreach (var cuesheetSection in Cuesheet.Sections) {
- - + } @@ -141,7 +151,7 @@ along with Foobar. If not, see Validations? validations; ModalDialog? modalDialog; Validation? audiofileValidation; - Dictionary fileEditAudiofileIds = new(); + Dictionary fileEditAudiofileIds = new(); public Cuesheet? Cuesheet { @@ -200,22 +210,22 @@ along with Foobar. If not, see validations?.ValidateAll(); } - Task AddSplitPointClicked() + Task AddSectionClicked() { if (Cuesheet != null) { - var splitPoint = Cuesheet.AddSplitPoint(); - _traceChangeManager.TraceChanges(splitPoint); - fileEditAudiofileIds.Add(splitPoint, Guid.NewGuid()); + var section = Cuesheet.AddSection(); + _traceChangeManager.TraceChanges(section); + fileEditAudiofileIds.Add(section, Guid.NewGuid()); } return Task.CompletedTask; } - Task DeleteSplitPointClicked(SplitPoint splitPoint) + Task DeleteSectionClicked(CuesheetSection section) { if (Cuesheet != null) { - Cuesheet.RemoveSplitPoint(splitPoint); + Cuesheet.RemoveSection(section); } return Task.CompletedTask; } @@ -265,15 +275,15 @@ along with Foobar. If not, see StateHasChanged(); } - async Task OnSplitpointAudiofileChangedCliccked(SplitPoint splitPoint) + async Task OnSectionAudiofileChangedClicked(CuesheetSection section) { - splitPoint.AudiofileName = null; + section.AudiofileName = null; StateHasChanged(); await Task.Delay(1); - await _jsRuntime.InvokeVoidAsync("triggerClick", fileEditAudiofileIds[splitPoint]); + await _jsRuntime.InvokeVoidAsync("triggerClick", fileEditAudiofileIds[section]); } - async Task OnSplitpointAudiofileChanged(FileChangedEventArgs e, SplitPoint splitPoint) + async Task OnSectionAudiofileChanged(FileChangedEventArgs e, CuesheetSection section) { if (e.Files.FirstOrDefault() != null) { @@ -282,7 +292,7 @@ along with Foobar. If not, see var file = e.Files.First(); if (IOUtility.CheckFileMimeTypeForAudioCodec(file) == true) { - splitPoint.AudiofileName = file.Name; + section.AudiofileName = file.Name; } else { diff --git a/AudioCuesheetEditor/Pages/Index.razor b/AudioCuesheetEditor/Pages/Index.razor index 887d2a1e..7eb0dbd9 100644 --- a/AudioCuesheetEditor/Pages/Index.razor +++ b/AudioCuesheetEditor/Pages/Index.razor @@ -41,10 +41,10 @@ along with Foobar. If not, see - + - + diff --git a/AudioCuesheetEditor/Pages/ViewModeImport.razor b/AudioCuesheetEditor/Pages/ViewModeImport.razor index 1a952e17..54005a68 100644 --- a/AudioCuesheetEditor/Pages/ViewModeImport.razor +++ b/AudioCuesheetEditor/Pages/ViewModeImport.razor @@ -274,10 +274,10 @@ along with Foobar. If not, see { - + - + } diff --git a/AudioCuesheetEditor/Resources/Localization/EditSplitpoints/de.json b/AudioCuesheetEditor/Resources/Localization/EditSections/de.json similarity index 75% rename from AudioCuesheetEditor/Resources/Localization/EditSplitpoints/de.json rename to AudioCuesheetEditor/Resources/Localization/EditSections/de.json index 1ade6c3a..2c343c56 100644 --- a/AudioCuesheetEditor/Resources/Localization/EditSplitpoints/de.json +++ b/AudioCuesheetEditor/Resources/Localization/EditSections/de.json @@ -1,10 +1,11 @@ { "culture": "de", "translations": { - "Add new split point": "Neuen Aufteilungspunkt hinzufügen", + "Add new section": "Neuen Abschnitt hinzufügen", "Controls": "Steuerung", - "Moment": "Zeitpunkt", - "Delete split tooltip": "Löscht diesen Aufteilungspunkt", + "Begin": "Anfang", + "End": "Ende", + "Delete section tooltip": "Löscht diesen Abschnitt", "CD artist": "CD Künstler", "CD title": "CD Titel", "Audiofile name": "Audiodatei", diff --git a/AudioCuesheetEditor/Resources/Localization/EditSplitpoints/en.json b/AudioCuesheetEditor/Resources/Localization/EditSections/en.json similarity index 76% rename from AudioCuesheetEditor/Resources/Localization/EditSplitpoints/en.json rename to AudioCuesheetEditor/Resources/Localization/EditSections/en.json index 7256528d..f6bb71d4 100644 --- a/AudioCuesheetEditor/Resources/Localization/EditSplitpoints/en.json +++ b/AudioCuesheetEditor/Resources/Localization/EditSections/en.json @@ -1,10 +1,11 @@ { "culture": "en", "translations": { - "Add new split point": "Add new split point", + "Add new section": "Add new section", "Controls": "Controls", - "Moment": "Moment", - "Delete split tooltip": "Deletes this split point", + "Begin": "Begin", + "End": "End", + "Delete section tooltip": "Deletes this section", "CD artist": "CD artist", "CD title": "CD title", "Audiofile name": "Audiofile", diff --git a/AudioCuesheetEditor/Resources/Localization/Index/de.json b/AudioCuesheetEditor/Resources/Localization/Index/de.json index 32530bad..65c4083c 100644 --- a/AudioCuesheetEditor/Resources/Localization/Index/de.json +++ b/AudioCuesheetEditor/Resources/Localization/Index/de.json @@ -44,6 +44,6 @@ "DateTime": "Datum und Uhrzeit", "Time": "Uhrzeit", "Save changes": "Änderungen speichern", - "Cuesheet split points": "Cuesheet Aufteilungspunkte" + "Cuesheet sections": "Cuesheet Abschnitte" } } \ No newline at end of file diff --git a/AudioCuesheetEditor/Resources/Localization/Index/en.json b/AudioCuesheetEditor/Resources/Localization/Index/en.json index 494ed278..2e8bd0f6 100644 --- a/AudioCuesheetEditor/Resources/Localization/Index/en.json +++ b/AudioCuesheetEditor/Resources/Localization/Index/en.json @@ -44,6 +44,6 @@ "DateTime": "Date and Time", "Time": "Time", "Save changes": "Save changes", - "Cuesheet split points": "Cuesheet split points" + "Cuesheet sections": "Cuesheet sections" } } \ No newline at end of file diff --git a/AudioCuesheetEditor/Resources/Localization/ValidationMessage/de.json b/AudioCuesheetEditor/Resources/Localization/ValidationMessage/de.json index afdb290e..5d513fa6 100644 --- a/AudioCuesheetEditor/Resources/Localization/ValidationMessage/de.json +++ b/AudioCuesheetEditor/Resources/Localization/ValidationMessage/de.json @@ -34,12 +34,13 @@ "CuesheetFilename": "Cuesheet Dateiname", "RecordedAudiofilename": "Dateiname für aufgenommenes Audio", "ProjectFilename": "Projektdateiname", - "{0} should be equal or less to '{1}'!": "{0} sollte kleiner oder gleich '{1}' sein!", "Filename": "Dateiname", "Artist": "Künstler", "Title": "Titel", "Exportprofile": "Exportprofil", "ApplicationOptions": "Applikationsoptionen", - "AudiofileName": "Audiodatei" + "AudiofileName": "Audiodatei", + "{0} should be greater than or equal '{1}'!": "{0} sollte größer oder gleich '{1}' sein!", + "{0} should be less than or equal '{1}'!": "{0} sollte kleiner oder gleich '{1}' sein!" } } \ No newline at end of file diff --git a/AudioCuesheetEditor/Resources/Localization/ValidationMessage/en.json b/AudioCuesheetEditor/Resources/Localization/ValidationMessage/en.json index 309d5fe4..588a2cc6 100644 --- a/AudioCuesheetEditor/Resources/Localization/ValidationMessage/en.json +++ b/AudioCuesheetEditor/Resources/Localization/ValidationMessage/en.json @@ -34,12 +34,13 @@ "CuesheetFilename": "Cuesheet filename", "RecordedAudiofilename": "Filename for recorded audio", "ProjectFilename": "Project filename", - "{0} should be equal or less to '{1}'!": "{0} should be equal or less to '{1}'!", "Filename": "Filename", "Artist": "Artist", "Title": "Title", "Exportprofile": "Exportprofile", "ApplicationOptions": "Application options", - "AudiofileName": "Audiofile" + "AudiofileName": "Audiofile", + "{0} should be greater than or equal '{1}'!": "{0} should be greater than or equal '{1}'!", + "{0} should be less than or equal '{1}'!": "{0} should be less than or equal '{1}'!" } } \ No newline at end of file diff --git a/AudioCuesheetEditor/Resources/Localization/ViewModeImport/de.json b/AudioCuesheetEditor/Resources/Localization/ViewModeImport/de.json index 2e2bd675..4d8539a4 100644 --- a/AudioCuesheetEditor/Resources/Localization/ViewModeImport/de.json +++ b/AudioCuesheetEditor/Resources/Localization/ViewModeImport/de.json @@ -61,6 +61,6 @@ "Please confirm": "Bestätigung erforderlich", "Do you really want to reset the import options to default? This can not be undone!": "Möchten Sie wirklich die Import Optionen zurücksetzen? Dies kann nicht rückgängig gemacht werden!", "Abort import of displayed data": "Import der angezeigten Daten abbrechen", - "Cuesheet split points": "Cuesheet Aufteilungspunkte" + "Cuesheet sections": "Cuesheet Abschnitte" } } \ No newline at end of file diff --git a/AudioCuesheetEditor/Resources/Localization/ViewModeImport/en.json b/AudioCuesheetEditor/Resources/Localization/ViewModeImport/en.json index 39c0634f..960cb5a1 100644 --- a/AudioCuesheetEditor/Resources/Localization/ViewModeImport/en.json +++ b/AudioCuesheetEditor/Resources/Localization/ViewModeImport/en.json @@ -60,6 +60,6 @@ "Please confirm": "Please confirm", "Do you really want to reset the import options to default? This can not be undone!": "Do you really want to reset the import options to default? This can not be undone!", "Abort import of displayed data": "Abort import of displayed data", - "Cuesheet split points": "Cuesheet split points" + "Cuesheet sections": "Cuesheet sections" } } \ No newline at end of file diff --git a/AudioCuesheetEditor/Shared/TracksTable.razor b/AudioCuesheetEditor/Shared/TracksTable.razor index 8c97bc92..6252e512 100644 --- a/AudioCuesheetEditor/Shared/TracksTable.razor +++ b/AudioCuesheetEditor/Shared/TracksTable.razor @@ -329,7 +329,7 @@ along with Foobar. If not, see case ViewMode.ViewModeImport:
- @if (Cuesheet?.GetSplitPointAtTrack(track) != null) + @if (Cuesheet?.GetSectionAtTrack(track) != null) { @@ -768,8 +768,8 @@ along with Foobar. If not, see { if (Cuesheet != null) { - Cuesheet.SplitPointAdded += Cuesheet_SplitPointAdded; - Cuesheet.SplitPointRemoved += Cuesheet_SplitPointRemoved; + Cuesheet.SectionAdded += Cuesheet_SectionAdded; + Cuesheet.SectionRemoved += Cuesheet_SectionRemoved; } } @@ -777,26 +777,27 @@ along with Foobar. If not, see { if (Cuesheet != null) { - Cuesheet.SplitPointAdded -= Cuesheet_SplitPointAdded; - Cuesheet.SplitPointRemoved -= Cuesheet_SplitPointRemoved; + Cuesheet.SectionAdded -= Cuesheet_SectionAdded; + Cuesheet.SectionRemoved -= Cuesheet_SectionRemoved; } } - void Cuesheet_SplitPointAdded(object? sender, SplitPointAddRemoveEventArgs args) + void Cuesheet_SectionAdded(object? sender, CuesheetSectionAddRemoveEventArgs args) { - args.SplitPoint.ValidateablePropertyChanged += SplitPoint_ValidateablePropertyChanged; + args.Section.ValidateablePropertyChanged += Section_ValidateablePropertyChanged; } - void Cuesheet_SplitPointRemoved(object? sender, SplitPointAddRemoveEventArgs args) + void Cuesheet_SectionRemoved(object? sender, CuesheetSectionAddRemoveEventArgs args) { - args.SplitPoint.ValidateablePropertyChanged -= SplitPoint_ValidateablePropertyChanged; + args.Section.ValidateablePropertyChanged -= Section_ValidateablePropertyChanged; } - void SplitPoint_ValidateablePropertyChanged(object? sender, string property) + void Section_ValidateablePropertyChanged(object? sender, string property) { switch (property) { - case nameof(SplitPoint.Moment): + case nameof(CuesheetSection.Begin): + case nameof(CuesheetSection.End): StateHasChanged(); break; } diff --git a/AudioCuesheetEditorTests/Model/AudioCuesheet/CuesheetTests.cs b/AudioCuesheetEditorTests/Model/AudioCuesheet/CuesheetTests.cs index 8eb7f310..115a2395 100644 --- a/AudioCuesheetEditorTests/Model/AudioCuesheet/CuesheetTests.cs +++ b/AudioCuesheetEditorTests/Model/AudioCuesheet/CuesheetTests.cs @@ -604,19 +604,5 @@ public void ValidateTest() cuesheet.Title = "Testtitle"; Assert.AreEqual(ValidationStatus.Success, cuesheet.Validate(x => x.Title).Status); } - - [TestMethod()] - public void ImportProjectfileTest() - { - var fileContent = Encoding.UTF8.GetBytes("{\"Tracks\":[{\"Position\":1,\"Artist\":\"Artist 1\",\"Title\":\"Title 1\",\"Begin\":\"00:00:00\",\"End\":\"00:01:01\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":2,\"Artist\":\"Artist 2\",\"Title\":\"Title 2\",\"Begin\":\"00:01:01\",\"End\":\"00:03:03\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":3,\"Artist\":\"Artist 3\",\"Title\":\"Title 3\",\"Begin\":\"00:03:03\",\"End\":\"00:06:06\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":4,\"Artist\":\"Artist 4\",\"Title\":\"Title 4\",\"Begin\":\"00:06:06\",\"End\":\"00:10:10\",\"Flags\":[\"4CH\",\"DCP\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":5,\"Artist\":\"Artist 5\",\"Title\":\"Title 5\",\"Begin\":\"00:10:10\",\"End\":\"00:15:15\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":6,\"Artist\":\"Artist 6\",\"Title\":\"Title 6\",\"Begin\":\"00:15:15\",\"End\":\"00:21:21\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":7,\"Artist\":\"Artist 7\",\"Title\":\"Title 7\",\"Begin\":\"00:21:21\",\"End\":\"00:28:28\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":8,\"Artist\":\"Artist 8\",\"Title\":\"Title 8\",\"Begin\":\"00:28:28\",\"End\":\"00:36:36\",\"Flags\":[\"4CH\",\"DCP\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":9,\"Artist\":\"Artist 9\",\"Title\":\"Title 9\",\"Begin\":\"00:36:36\",\"End\":\"00:45:45\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":10,\"Artist\":\"Artist 10\",\"Title\":\"Title 10\",\"Begin\":\"00:45:45\",\"End\":\"00:55:55\",\"Flags\":[\"4CH\",\"DCP\"],\"IsLinkedToPreviousTrack\":true}],\"Artist\":\"CuesheetArtist\",\"Title\":\"CuesheetTitle\",\"Audiofile\":{\"Name\":\"AudioFile.mp3\"},\"CDTextfile\":{\"Name\":\"CDTextfile.cdt\"},\"Cataloguenumber\":{\"Value\":\"A123\"},\"SplitPoints\":[{\"Artist\":\"CuesheetArtist\",\"Title\":\"CuesheetTitle\",\"Moment\":\"00:30:00\"},{\"Artist\":\"CuesheetArtist\",\"Title\":\"CuesheetTitle\",\"Moment\":\"01:00:00\"}]}"); - var projectFileCuesheet = Projectfile.ImportFile(fileContent); - Assert.IsNotNull(projectFileCuesheet); - Assert.AreEqual(2, projectFileCuesheet.SplitPoints.Count); - var cuesheet = new Cuesheet(); - var testHelper = new TestHelper(); - cuesheet.Import(projectFileCuesheet, testHelper.ApplicationOptions); - Assert.AreEqual(2, cuesheet.SplitPoints.Count); - Assert.IsTrue(cuesheet.SplitPoints.All(x => x.Cuesheet == cuesheet)); - } } } \ No newline at end of file diff --git a/AudioCuesheetEditorTests/Model/IO/Export/CuesheetSectionTests.cs b/AudioCuesheetEditorTests/Model/IO/Export/CuesheetSectionTests.cs new file mode 100644 index 00000000..e9810a3c --- /dev/null +++ b/AudioCuesheetEditorTests/Model/IO/Export/CuesheetSectionTests.cs @@ -0,0 +1,56 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using AudioCuesheetEditor.Model.IO.Export; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using AudioCuesheetEditor.Model.Entity; +using AudioCuesheetEditor.Model.AudioCuesheet; + +namespace AudioCuesheetEditor.Model.IO.Export.Tests +{ + [TestClass()] + public class CuesheetSectionTests + { + [TestMethod()] + public void ValidationTest() + { + var cuesheet = new Cuesheet(); + var section = new CuesheetSection(cuesheet); + Assert.IsNull(section.Begin); + var beginValidationResult = section.Validate(x => x.Begin); + var endValidationResult = section.Validate(x => x.End); + Assert.AreEqual(ValidationStatus.Error, beginValidationResult.Status); + Assert.AreEqual(ValidationStatus.Error, endValidationResult.Status); + section.Begin = new TimeSpan(0, 0, 0); + beginValidationResult = section.Validate(x => x.Begin); + endValidationResult = section.Validate(x => x.End); + Assert.AreEqual(ValidationStatus.Success, beginValidationResult.Status); + Assert.AreEqual(ValidationStatus.Error, endValidationResult.Status); + cuesheet.AddTrack(new Track() { Position = 1, Begin = new TimeSpan(0, 0, 10) }); + cuesheet.AddTrack(new Track() { Position = 2, Begin = new TimeSpan(0, 8, 43), End = new TimeSpan(0, 15, 43) }); + beginValidationResult = section.Validate(x => x.Begin); + endValidationResult = section.Validate(x => x.End); + Assert.AreEqual(ValidationStatus.Error, beginValidationResult.Status); + Assert.AreEqual(ValidationStatus.Error, endValidationResult.Status); + section.Begin = new TimeSpan(0, 0, 10); + beginValidationResult = section.Validate(x => x.Begin); + endValidationResult = section.Validate(x => x.End); + Assert.AreEqual(ValidationStatus.Success, beginValidationResult.Status); + Assert.AreEqual(ValidationStatus.Error, endValidationResult.Status); + section.Begin = new TimeSpan(0, 10, 0); + section.End = new TimeSpan(0, 5, 0); + beginValidationResult = section.Validate(x => x.Begin); + endValidationResult = section.Validate(x => x.End); + Assert.AreEqual(ValidationStatus.Error, beginValidationResult.Status); + Assert.AreEqual(ValidationStatus.Error, endValidationResult.Status); + section.Begin = new TimeSpan(0, 10, 0); + section.End = new TimeSpan(0, 15, 0); + beginValidationResult = section.Validate(x => x.Begin); + endValidationResult = section.Validate(x => x.End); + Assert.AreEqual(ValidationStatus.Success, beginValidationResult.Status); + Assert.AreEqual(ValidationStatus.Success, endValidationResult.Status); + } + } +} \ No newline at end of file diff --git a/AudioCuesheetEditorTests/Model/IO/Export/ExportfileGeneratorTests.cs b/AudioCuesheetEditorTests/Model/IO/Export/ExportfileGeneratorTests.cs index a06551f6..97653e63 100644 --- a/AudioCuesheetEditorTests/Model/IO/Export/ExportfileGeneratorTests.cs +++ b/AudioCuesheetEditorTests/Model/IO/Export/ExportfileGeneratorTests.cs @@ -280,7 +280,7 @@ public void GenerateCuesheetFilesWithIncorrectTrackPositionsTest() } [TestMethod()] - public void GenerateCuesheetFilesWithSplitPointsTest() + public void GenerateCuesheetFilesWithSectionsTest() { var testHelper = new TestHelper(); Cuesheet cuesheet = new() @@ -302,39 +302,40 @@ public void GenerateCuesheetFilesWithSplitPointsTest() track.End = begin; cuesheet.AddTrack(track, testHelper.ApplicationOptions); } - var splitPoint = cuesheet.AddSplitPoint(); - splitPoint.Moment = new TimeSpan(2, 0, 0); - splitPoint.Title = "Last part"; - splitPoint.AudiofileName = "Last part.mp3"; - splitPoint = cuesheet.AddSplitPoint(); - splitPoint.Moment = new TimeSpan(0, 30, 0); - splitPoint.AudiofileName = "First part.mp3"; - splitPoint = cuesheet.AddSplitPoint(); - splitPoint.Moment = new TimeSpan(1, 0, 0); - splitPoint.Artist = "Demo Artist Part2"; - splitPoint = cuesheet.AddSplitPoint(); - splitPoint.Artist = "Artist 3"; - splitPoint.Title = "Title 3"; - splitPoint.AudiofileName = "Part 3.mp3"; - splitPoint.Moment = new TimeSpan(1, 30, 0); + var section = cuesheet.AddSection(); + section.Begin = new TimeSpan(1, 30, 0); + section.End = new TimeSpan(2, 0, 0); + section.Title = "Last part"; + section.AudiofileName = "Last part.mp3"; + section = cuesheet.AddSection(); + section.Begin = new TimeSpan(0, 0, 0); + section.End = new TimeSpan(0, 30, 0); + section.AudiofileName = "First part.mp3"; + section = cuesheet.AddSection(); + section.Begin = new TimeSpan(0, 30, 0); + section.End = new TimeSpan(1, 0, 0); + section.Artist = "Demo Artist Part2"; + section = cuesheet.AddSection(); + section.Artist = "Artist 3"; + section.Title = "Title 3"; + section.AudiofileName = "Part 3.mp3"; + section.Begin = new TimeSpan(1, 0, 0); + section.End = new TimeSpan(1, 30, 0); testHelper.ApplicationOptions.CuesheetFilename = "Unit test.cue"; var generator = new ExportfileGenerator(ExportType.Cuesheet, cuesheet, applicationOptions: testHelper.ApplicationOptions); Assert.AreEqual(ValidationStatus.Success, generator.Validate().Status); var generatedFiles = generator.GenerateExportfiles(); - Assert.AreEqual(5, generatedFiles.Count); + Assert.AreEqual(4, generatedFiles.Count); var position = 1; var counter = 1; - //Check split according to split points - Assert.AreEqual(cuesheet.Tracks.Min(x => x.Begin), generatedFiles.First().Begin); + //Check split according to sections + Assert.AreEqual(new TimeSpan(0, 0, 0), generatedFiles.First().Begin); Assert.AreEqual(new TimeSpan(0, 30, 0), generatedFiles.First().End); - Assert.AreEqual(new TimeSpan(0, 30, 0), generatedFiles.ElementAt(1).Begin); Assert.AreEqual(new TimeSpan(1, 0, 0), generatedFiles.ElementAt(1).End); Assert.AreEqual(new TimeSpan(1, 0, 0), generatedFiles.ElementAt(2).Begin); Assert.AreEqual(new TimeSpan(1, 30, 0), generatedFiles.ElementAt(2).End); - Assert.AreEqual(new TimeSpan(1, 30, 0), generatedFiles.ElementAt(3).Begin); - Assert.AreEqual(new TimeSpan(2, 0, 0), generatedFiles.ElementAt(3).End); - Assert.AreEqual(new TimeSpan(2, 0, 0), generatedFiles.ElementAt(4).Begin); - Assert.AreEqual(cuesheet.Tracks.Max(x => x.End), generatedFiles.Last().End); + Assert.AreEqual(new TimeSpan(1, 30, 0), generatedFiles.Last().Begin); + Assert.AreEqual(new TimeSpan(2, 0, 0), generatedFiles.Last().End); foreach (var generatedFile in generatedFiles) { Assert.AreEqual(String.Format("Unit test({0}).cue", counter), generatedFile.Name); @@ -346,13 +347,13 @@ public void GenerateCuesheetFilesWithSplitPointsTest() var fileContent = File.ReadAllLines(fileName); File.Delete(fileName); int positionDifference = 1 - position; - // Check cuesheet header for splitpoint artist and title - var splitPointForThisFile = cuesheet.SplitPoints.FirstOrDefault(x => x.Moment == generatedFile.End); - if (splitPointForThisFile != null) + // Check cuesheet header for artist and title + var sectionForThisFile = cuesheet.Sections.FirstOrDefault(x => x.Begin == generatedFile.Begin); + if (sectionForThisFile != null) { - Assert.AreEqual(String.Format("{0} \"{1}\"", CuesheetConstants.CuesheetTitle, splitPointForThisFile.Title), fileContent.First()); - Assert.AreEqual(String.Format("{0} \"{1}\"", CuesheetConstants.CuesheetArtist, splitPointForThisFile.Artist), fileContent[1]); - Assert.AreEqual(String.Format("{0} \"{1}\" {2}", CuesheetConstants.CuesheetFileName, splitPointForThisFile.AudiofileName, cuesheet.Audiofile?.AudioFileType), fileContent[2]); + Assert.AreEqual(String.Format("{0} \"{1}\"", CuesheetConstants.CuesheetTitle, sectionForThisFile.Title), fileContent.First()); + Assert.AreEqual(String.Format("{0} \"{1}\"", CuesheetConstants.CuesheetArtist, sectionForThisFile.Artist), fileContent[1]); + Assert.AreEqual(String.Format("{0} \"{1}\" {2}", CuesheetConstants.CuesheetFileName, sectionForThisFile.AudiofileName, cuesheet.Audiofile?.AudioFileType), fileContent[2]); } else { @@ -592,7 +593,7 @@ public void GenerateExportfilesWithPregapAndPostgapTest() } [TestMethod()] - public void GenerateExportfilesWithSplitPointsTest() + public void GenerateExportfilesWithSectionsTest() { var testHelper = new TestHelper(); //Prepare cuesheet @@ -627,21 +628,25 @@ public void GenerateExportfilesWithSplitPointsTest() cuesheet.Cataloguenumber.Value = "0123456789123"; cuesheet.CDTextfile = new CDTextfile("Testfile.cdt"); - var splitPoint = cuesheet.AddSplitPoint(); - splitPoint.Moment = new TimeSpan(2, 0, 0); - splitPoint.Title = "Last part"; - splitPoint.AudiofileName = "Last part.mp3"; - splitPoint = cuesheet.AddSplitPoint(); - splitPoint.Moment = new TimeSpan(0, 30, 0); - splitPoint.AudiofileName = "First part.mp3"; - splitPoint = cuesheet.AddSplitPoint(); - splitPoint.Moment = new TimeSpan(1, 0, 0); - splitPoint.Artist = "Demo Artist Part2"; - splitPoint = cuesheet.AddSplitPoint(); - splitPoint.Artist = "Artist 3"; - splitPoint.Title = "Title 3"; - splitPoint.AudiofileName = "Part 3.mp3"; - splitPoint.Moment = new TimeSpan(1, 30, 0); + var section = cuesheet.AddSection(); + section.Begin = new TimeSpan(1, 30, 0); + section.End = new TimeSpan(2, 0, 0); + section.Title = "Last part"; + section.AudiofileName = "Last part.mp3"; + section = cuesheet.AddSection(); + section.Begin = new TimeSpan(0, 0, 0); + section.End = new TimeSpan(0, 30, 0); + section.AudiofileName = "First part.mp3"; + section = cuesheet.AddSection(); + section.Begin = new TimeSpan(0, 30, 0); + section.End = new TimeSpan(1, 0, 0); + section.Artist = "Demo Artist Part2"; + section = cuesheet.AddSection(); + section.Artist = "Artist 3"; + section.Title = "Title 3"; + section.AudiofileName = "Part 3.mp3"; + section.Begin = new TimeSpan(1, 0, 0); + section.End = new TimeSpan(1, 30, 0); //Test export var exportProfile = new Exportprofile { @@ -652,19 +657,16 @@ public void GenerateExportfilesWithSplitPointsTest() var generator = new ExportfileGenerator(ExportType.Exportprofile, cuesheet, exportProfile); Assert.AreEqual(ValidationStatus.Success, generator.Validate().Status); var generatedFiles = generator.GenerateExportfiles(); - Assert.AreEqual(5, generatedFiles.Count); + Assert.AreEqual(4, generatedFiles.Count); - //Check split according to split points - Assert.AreEqual(cuesheet.Tracks.Min(x => x.Begin), generatedFiles.First().Begin); + //Check split according to sections + Assert.AreEqual(new TimeSpan(0, 0, 0), generatedFiles.First().Begin); Assert.AreEqual(new TimeSpan(0, 30, 0), generatedFiles.First().End); - Assert.AreEqual(new TimeSpan(0, 30, 0), generatedFiles.ElementAt(1).Begin); Assert.AreEqual(new TimeSpan(1, 0, 0), generatedFiles.ElementAt(1).End); Assert.AreEqual(new TimeSpan(1, 0, 0), generatedFiles.ElementAt(2).Begin); Assert.AreEqual(new TimeSpan(1, 30, 0), generatedFiles.ElementAt(2).End); - Assert.AreEqual(new TimeSpan(1, 30, 0), generatedFiles.ElementAt(3).Begin); - Assert.AreEqual(new TimeSpan(2, 0, 0), generatedFiles.ElementAt(3).End); - Assert.AreEqual(new TimeSpan(2, 0, 0), generatedFiles.ElementAt(4).Begin); - Assert.AreEqual(cuesheet.Tracks.Max(x => x.End), generatedFiles.Last().End); + Assert.AreEqual(new TimeSpan(1, 30, 0), generatedFiles.Last().Begin); + Assert.AreEqual(new TimeSpan(2, 0, 0), generatedFiles.Last().End); var counter = 1; var position = 1; foreach (var generatedFile in generatedFiles) @@ -678,11 +680,11 @@ public void GenerateExportfilesWithSplitPointsTest() var fileContent = File.ReadAllLines(fileName); File.Delete(fileName); int positionDifference = 1 - position; - //Check cuesheet header for splitpoint artist and title - var splitPointForThisFile = cuesheet.SplitPoints.FirstOrDefault(x => x.Moment == generatedFile.End); - if (splitPointForThisFile != null) + //Check cuesheet header for artist and title + var sectionForThisFile = cuesheet.Sections.FirstOrDefault(x => x.Begin == generatedFile.Begin); + if (sectionForThisFile != null) { - Assert.AreEqual(String.Format("{0};{1};{2};0123456789123;Testfile.cdt", splitPointForThisFile.Artist, splitPointForThisFile.Title, splitPointForThisFile.AudiofileName), fileContent[0]); + Assert.AreEqual(String.Format("{0};{1};{2};0123456789123;Testfile.cdt", sectionForThisFile.Artist, sectionForThisFile.Title, sectionForThisFile.AudiofileName), fileContent[0]); } else { @@ -710,9 +712,9 @@ public void GenerateExportfilesWithSplitPointsTest() } Assert.AreEqual(String.Format("{0};{1};{2};{3};{4};{5}", track.Position + positionDifference, track.Artist, track.Title, trackBegin, trackEnd, trackEnd - trackBegin), fileContent[i]); } - if (splitPointForThisFile != null) + if (sectionForThisFile != null) { - Assert.AreEqual(String.Format("Exported {0} from {1} using AudioCuesheetEditor", splitPointForThisFile.Title, splitPointForThisFile.Artist), fileContent.Last()); + Assert.AreEqual(String.Format("Exported {0} from {1} using AudioCuesheetEditor", sectionForThisFile.Title, sectionForThisFile.Artist), fileContent.Last()); } else { diff --git a/AudioCuesheetEditorTests/Model/IO/Export/SplitPointTests.cs b/AudioCuesheetEditorTests/Model/IO/Export/SplitPointTests.cs deleted file mode 100644 index d4dc78e2..00000000 --- a/AudioCuesheetEditorTests/Model/IO/Export/SplitPointTests.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using AudioCuesheetEditor.Model.IO.Export; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using AudioCuesheetEditor.Model.Entity; -using AudioCuesheetEditor.Model.AudioCuesheet; - -namespace AudioCuesheetEditor.Model.IO.Export.Tests -{ - [TestClass()] - public class SplitPointTests - { - [TestMethod()] - public void ValidationTest() - { - var cuesheet = new Cuesheet(); - var splitPoint = new SplitPoint(cuesheet); - Assert.IsNull(splitPoint.Moment); - var validationResult = splitPoint.Validate(x => x.Moment); - Assert.AreEqual(ValidationStatus.Error, validationResult.Status); - splitPoint.Moment = new TimeSpan(0, 30, 0); - validationResult = splitPoint.Validate(x => x.Moment); - Assert.AreEqual(ValidationStatus.Success, validationResult.Status); - cuesheet.AddTrack(new Track() { Position = 1}); - cuesheet.AddTrack(new Track() { Position = 2, Begin = new TimeSpan(0, 8, 43), End = new TimeSpan(0, 15, 43) }); - validationResult = splitPoint.Validate(x => x.Moment); - Assert.AreEqual(ValidationStatus.Error, validationResult.Status); - splitPoint.Moment = new TimeSpan(0, 15, 43); - validationResult = splitPoint.Validate(x => x.Moment); - Assert.AreEqual(ValidationStatus.Success, validationResult.Status); - } - } -} \ No newline at end of file diff --git a/AudioCuesheetEditorTests/Model/IO/ProjectfileTests.cs b/AudioCuesheetEditorTests/Model/IO/ProjectfileTests.cs index 022cec94..1f8fde61 100644 --- a/AudioCuesheetEditorTests/Model/IO/ProjectfileTests.cs +++ b/AudioCuesheetEditorTests/Model/IO/ProjectfileTests.cs @@ -70,7 +70,7 @@ public void GenerateFileTest() } [TestMethod()] - public void GenerateFileWithSplitPointsTest() + public void GenerateFileWithSectionsTest() { var cuesheet = new Cuesheet { @@ -100,10 +100,10 @@ public void GenerateFileWithSplitPointsTest() track.End = begin; cuesheet.AddTrack(track, new Options.ApplicationOptions() { LinkTracksWithPreviousOne = true }); } - var splitPoint = cuesheet.AddSplitPoint(); - splitPoint.Moment = new TimeSpan(0, 30, 0); - splitPoint = cuesheet.AddSplitPoint(); - splitPoint.Moment = new TimeSpan(1, 0, 0); + var section = cuesheet.AddSection(); + section.Begin = new TimeSpan(0, 30, 0); + section = cuesheet.AddSection(); + section.Begin = new TimeSpan(1, 0, 0); var projectFile = new Projectfile(cuesheet); var generatedFile = projectFile.GenerateFile(); Assert.IsNotNull(generatedFile); @@ -139,9 +139,9 @@ public void ImportFileTest() } [TestMethod()] - public void ImportFileWithSplitPointsTest() + public void ImportFileWithSectionsTest() { - var fileContent = Encoding.UTF8.GetBytes("{\"Tracks\":[{\"Position\":1,\"Artist\":\"Artist 1\",\"Title\":\"Title 1\",\"Begin\":\"00:00:00\",\"End\":\"00:01:01\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":2,\"Artist\":\"Artist 2\",\"Title\":\"Title 2\",\"Begin\":\"00:01:01\",\"End\":\"00:03:03\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":3,\"Artist\":\"Artist 3\",\"Title\":\"Title 3\",\"Begin\":\"00:03:03\",\"End\":\"00:06:06\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":4,\"Artist\":\"Artist 4\",\"Title\":\"Title 4\",\"Begin\":\"00:06:06\",\"End\":\"00:10:10\",\"Flags\":[\"4CH\",\"DCP\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":5,\"Artist\":\"Artist 5\",\"Title\":\"Title 5\",\"Begin\":\"00:10:10\",\"End\":\"00:15:15\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":6,\"Artist\":\"Artist 6\",\"Title\":\"Title 6\",\"Begin\":\"00:15:15\",\"End\":\"00:21:21\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":7,\"Artist\":\"Artist 7\",\"Title\":\"Title 7\",\"Begin\":\"00:21:21\",\"End\":\"00:28:28\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":8,\"Artist\":\"Artist 8\",\"Title\":\"Title 8\",\"Begin\":\"00:28:28\",\"End\":\"00:36:36\",\"Flags\":[\"4CH\",\"DCP\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":9,\"Artist\":\"Artist 9\",\"Title\":\"Title 9\",\"Begin\":\"00:36:36\",\"End\":\"00:45:45\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":10,\"Artist\":\"Artist 10\",\"Title\":\"Title 10\",\"Begin\":\"00:45:45\",\"End\":\"00:55:55\",\"Flags\":[\"4CH\",\"DCP\"],\"IsLinkedToPreviousTrack\":true}],\"Artist\":\"CuesheetArtist\",\"Title\":\"CuesheetTitle\",\"Audiofile\":{\"Name\":\"AudioFile.mp3\"},\"CDTextfile\":{\"Name\":\"CDTextfile.cdt\"},\"Cataloguenumber\":{\"Value\":\"A123\"},\"SplitPoints\":[{\"Artist\":\"CuesheetArtist\",\"Title\":\"CuesheetTitle\",\"Moment\":\"00:30:00\"},{\"Artist\":\"CuesheetArtist\",\"Title\":\"CuesheetTitle\",\"Moment\":\"01:00:00\"}]}"); + var fileContent = Encoding.UTF8.GetBytes("{\"Tracks\":[{\"Position\":1,\"Artist\":\"Artist 1\",\"Title\":\"Title 1\",\"Begin\":\"00:00:00\",\"End\":\"00:01:01\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":2,\"Artist\":\"Artist 2\",\"Title\":\"Title 2\",\"Begin\":\"00:01:01\",\"End\":\"00:03:03\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":3,\"Artist\":\"Artist 3\",\"Title\":\"Title 3\",\"Begin\":\"00:03:03\",\"End\":\"00:06:06\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":4,\"Artist\":\"Artist 4\",\"Title\":\"Title 4\",\"Begin\":\"00:06:06\",\"End\":\"00:10:10\",\"Flags\":[\"4CH\",\"DCP\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":5,\"Artist\":\"Artist 5\",\"Title\":\"Title 5\",\"Begin\":\"00:10:10\",\"End\":\"00:15:15\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":6,\"Artist\":\"Artist 6\",\"Title\":\"Title 6\",\"Begin\":\"00:15:15\",\"End\":\"00:21:21\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":7,\"Artist\":\"Artist 7\",\"Title\":\"Title 7\",\"Begin\":\"00:21:21\",\"End\":\"00:28:28\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":8,\"Artist\":\"Artist 8\",\"Title\":\"Title 8\",\"Begin\":\"00:28:28\",\"End\":\"00:36:36\",\"Flags\":[\"4CH\",\"DCP\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":9,\"Artist\":\"Artist 9\",\"Title\":\"Title 9\",\"Begin\":\"00:36:36\",\"End\":\"00:45:45\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":10,\"Artist\":\"Artist 10\",\"Title\":\"Title 10\",\"Begin\":\"00:45:45\",\"End\":\"00:55:55\",\"Flags\":[\"4CH\",\"DCP\"],\"IsLinkedToPreviousTrack\":true}],\"Artist\":\"CuesheetArtist\",\"Title\":\"CuesheetTitle\",\"Audiofile\":{\"Name\":\"AudioFile.mp3\"},\"CDTextfile\":{\"Name\":\"CDTextfile.cdt\"},\"Cataloguenumber\":{\"Value\":\"A123\"},\"Sections\":[{\"Artist\":\"CuesheetArtist\",\"Title\":\"CuesheetTitle\",\"Begin\":\"00:30:00\"},{\"Artist\":\"CuesheetArtist\",\"Title\":\"CuesheetTitle\",\"Begin\":\"01:00:00\"}]}"); var cuesheet = Projectfile.ImportFile(fileContent); Assert.IsNotNull(cuesheet); Assert.IsTrue(cuesheet.Tracks.All(x => x.Cuesheet == cuesheet)); @@ -159,9 +159,9 @@ public void ImportFileWithSplitPointsTest() Assert.IsTrue(Object.ReferenceEquals(cuesheet.Tracks.First(), cuesheet.GetPreviousLinkedTrack(cuesheet.Tracks.ElementAt(1)))); Assert.AreEqual(cuesheet.Tracks.First(), cuesheet.GetPreviousLinkedTrack(cuesheet.Tracks.ElementAt(1))); Assert.AreEqual((uint)10, cuesheet.Tracks.Last().Position); - Assert.AreEqual(2, cuesheet.SplitPoints.Count); - Assert.AreEqual(new TimeSpan(0, 30, 0), cuesheet.SplitPoints.First().Moment); - Assert.AreEqual(new TimeSpan(1, 0, 0), cuesheet.SplitPoints.Last().Moment); + Assert.AreEqual(2, cuesheet.Sections.Count); + Assert.AreEqual(new TimeSpan(0, 30, 0), cuesheet.Sections.First().Begin); + Assert.AreEqual(new TimeSpan(1, 0, 0), cuesheet.Sections.Last().Begin); } } } \ No newline at end of file