Skip to content

Commit

Permalink
Merge pull request #399 from NeoCoderMatrix86/203-make-tracks-dragable
Browse files Browse the repository at this point in the history
Make tracks dragable
  • Loading branch information
NeoCoderMatrix86 authored Dec 13, 2024
2 parents c28c788 + 191a51e commit a0f7cbe
Show file tree
Hide file tree
Showing 59 changed files with 1,676 additions and 1,305 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.2" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.4" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.4" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//<http: //www.gnu.org/licenses />.
using AudioCuesheetEditor.Model.AudioCuesheet;
using AudioCuesheetEditor.Model.UI;
using AudioCuesheetEditorTests.Utility;
using AudioCuesheetEditor.Tests.Utility;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace AudioCuesheetEditor.Extensions.Tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,11 @@
//You should have received a copy of the GNU General Public License
//along with Foobar. If not, see
//<http: //www.gnu.org/licenses />.
using Microsoft.VisualStudio.TestTools.UnitTesting;
using AudioCuesheetEditor.Model.AudioCuesheet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AudioCuesheetEditorTests.Utility;
using AudioCuesheetEditor.Model.Entity;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace AudioCuesheetEditor.Model.AudioCuesheet.Tests
namespace AudioCuesheetEditor.Tests.Model.AudioCuesheet
{
[TestClass()]
public class CataloguenumberTests
Expand All @@ -31,13 +26,13 @@ public class CataloguenumberTests
public void CatalogueNumberTest()
{
var catalogueNumber = new Cataloguenumber();
Assert.AreEqual(Entity.ValidationStatus.NoValidation, catalogueNumber.Validate().Status);
Assert.AreEqual(ValidationStatus.NoValidation, catalogueNumber.Validate().Status);
catalogueNumber.Value = "Testvalue";
Assert.AreEqual(Entity.ValidationStatus.Error, catalogueNumber.Validate().Status);
Assert.AreEqual(ValidationStatus.Error, catalogueNumber.Validate().Status);
catalogueNumber.Value = "01234567891234567890";
Assert.AreEqual(Entity.ValidationStatus.Error, catalogueNumber.Validate().Status);
Assert.AreEqual(ValidationStatus.Error, catalogueNumber.Validate().Status);
catalogueNumber.Value = "1234567890123";
Assert.AreEqual(Entity.ValidationStatus.Success, catalogueNumber.Validate().Status);
Assert.AreEqual(ValidationStatus.Success, catalogueNumber.Validate().Status);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,25 @@
//<http: //www.gnu.org/licenses />.
using AudioCuesheetEditor.Data.Options;
using AudioCuesheetEditor.Extensions;
using AudioCuesheetEditor.Model.AudioCuesheet;
using AudioCuesheetEditor.Model.Entity;
using AudioCuesheetEditor.Model.IO.Audio;
using AudioCuesheetEditor.Model.IO.Import;
using AudioCuesheetEditor.Model.Options;
using AudioCuesheetEditor.Model.UI;
using AudioCuesheetEditor.Services.IO;
using AudioCuesheetEditorTests.Properties;
using AudioCuesheetEditorTests.Utility;
using AudioCuesheetEditor.Tests.Properties;
using AudioCuesheetEditor.Tests.Utility;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace AudioCuesheetEditor.Model.AudioCuesheet.Tests
namespace AudioCuesheetEditor.Tests.Model.AudioCuesheet
{
[TestClass()]
public class CuesheetTests
Expand All @@ -41,15 +43,12 @@ public void AddTrackTest()
{
var testHelper = new TestHelper();
var cuesheet = new Cuesheet();
var trackAddedFired = false;
cuesheet.TrackAdded += delegate
{
trackAddedFired = true;
};
AutoResetEvent tracksAddedEvent = new(false);
cuesheet.TracksAdded += (object? sender, TracksAddedRemovedEventArgs args) => tracksAddedEvent.Set();
Assert.AreEqual(cuesheet.Tracks.Count, 0);
cuesheet.AddTrack(new Track(), testHelper.ApplicationOptions);
Assert.AreEqual(cuesheet.Tracks.Count, 1);
Assert.IsTrue(trackAddedFired);
Assert.IsTrue(tracksAddedEvent.WaitOne(1000));
}

[TestMethod()]
Expand Down Expand Up @@ -221,7 +220,7 @@ public void MoveAndDeleteTrackTest()
public async Task ImportTestAsync()
{
// Arrange
var fileContent = new List<String>
var fileContent = new List<string>
{
"CuesheetArtist - CuesheetTitle c:\\tmp\\Testfile.mp3",
"Sample Artist 1 - Sample Title 1 00:05:00",
Expand Down Expand Up @@ -271,7 +270,7 @@ public async Task ImportTestCalculateEndCorrectlyAsync()
// Arrange
var textImportMemoryStream = new MemoryStream(Resources.Textimport_Bug_54);
using var reader = new StreamReader(textImportMemoryStream);
List<String?> lines = [];
List<string?> lines = [];
while (reader.EndOfStream == false)
{
lines.Add(reader.ReadLine());
Expand Down Expand Up @@ -320,11 +319,11 @@ public void RecordTest()
cuesheet = new Cuesheet();
cuesheet.StartRecording();
track = new Track();
testHelper.RecordOptions.RecordTimeSensitivity = Options.TimeSensitivityMode.Seconds;
testHelper.RecordOptions.RecordTimeSensitivity = TimeSensitivityMode.Seconds;
cuesheet.AddTrack(track, testHelper.ApplicationOptions, testHelper.RecordOptions);
Assert.AreEqual(TimeSpan.Zero, track.Begin);
Assert.IsNull(track.End);
System.Threading.Thread.Sleep(3000);
Thread.Sleep(3000);
track2 = new Track();
cuesheet.AddTrack(track2, testHelper.ApplicationOptions, testHelper.RecordOptions);
Assert.IsNotNull(track.End);
Expand Down Expand Up @@ -427,7 +426,9 @@ public void RemoveTrackTest()
{
var testHelper = new TestHelper();
testHelper.ApplicationOptions.LinkTracksWithPreviousOne = true;
AutoResetEvent tracksRemovedEvent = new(false);
var cuesheet = new Cuesheet();
cuesheet.TracksRemoved += (sender, trackAddRemoveEventArgs) => tracksRemovedEvent.Set();
var track1 = new Track() { Artist = "1", Title = "1" };
var track2 = new Track() { Artist = "2", Title = "2" };
var track3 = new Track() { Artist = "3", Title = "3" };
Expand All @@ -445,12 +446,14 @@ public void RemoveTrackTest()
track5.End = new TimeSpan(0, 25, 0);
Assert.AreEqual(5, cuesheet.Tracks.Count);
cuesheet.RemoveTrack(track2);
Assert.AreEqual(true, tracksRemovedEvent.WaitOne(1000));
Assert.AreEqual((uint)2, track3.Position);
Assert.AreEqual((uint)3, track4.Position);
Assert.AreEqual((uint)4, track5.Position);
testHelper = new TestHelper();
testHelper.ApplicationOptions.LinkTracksWithPreviousOne = true;
cuesheet = new Cuesheet();
cuesheet.TracksRemoved += (sender, trackAddRemoveEventArgs) => tracksRemovedEvent.Set();
track1 = new Track
{
Artist = "Track 1",
Expand Down Expand Up @@ -487,6 +490,7 @@ public void RemoveTrackTest()
cuesheet.AddTrack(track5, testHelper.ApplicationOptions);
var list = new List<Track>() { track2, track4 };
cuesheet.RemoveTracks(list.AsReadOnly());
Assert.AreEqual(true, tracksRemovedEvent.WaitOne(1000));
Assert.AreEqual(3, cuesheet.Tracks.Count);
Assert.AreEqual(new TimeSpan(0, 5, 0), track3.Begin);
Assert.AreEqual(new TimeSpan(0, 15, 0), track5.Begin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
//You should have received a copy of the GNU General Public License
//along with Foobar. If not, see
//<http: //www.gnu.org/licenses />.
using AudioCuesheetEditor.Model.AudioCuesheet;
using AudioCuesheetEditor.Model.Entity;
using AudioCuesheetEditorTests.Utility;
using AudioCuesheetEditor.Tests.Utility;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;

namespace AudioCuesheetEditor.Model.AudioCuesheet.Tests
namespace AudioCuesheetEditor.Tests.Model.AudioCuesheet
{
[TestClass()]
public class TrackTests
Expand Down Expand Up @@ -84,7 +85,7 @@ public void LinkTrackTest()
Position = 2
};
Assert.IsFalse(track2.IsLinkedToPreviousTrack);
Boolean eventFired = false;
bool eventFired = false;
track2.IsLinkedToPreviousTrackChanged += delegate
{
eventFired = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@
//You should have received a copy of the GNU General Public License
//along with Foobar. If not, see
//<http: //www.gnu.org/licenses />.
using AudioCuesheetEditorTests.Utility;
using AudioCuesheetEditor.Model.Entity;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;

namespace AudioCuesheetEditor.Model.Entity.Tests
namespace AudioCuesheetEditor.Tests.Model.Entity
{
public class ValidateableTestClass : Validateable<ValidateableTestClass>
{
private String? testProperty;
private string? testProperty;
private int? testProperty2;

public String? TestProperty
public string? TestProperty
{
get => testProperty;
set
Expand All @@ -34,7 +33,7 @@ public String? TestProperty
OnValidateablePropertyChanged();
}
}
public int? TestProperty2
public int? TestProperty2
{
get => testProperty2;
set
Expand All @@ -51,9 +50,9 @@ protected override ValidationResult Validate(string property)
{
case nameof(TestProperty):
validationStatus = ValidationStatus.Success;
if (String.IsNullOrEmpty(TestProperty))
if (string.IsNullOrEmpty(TestProperty))
{
validationMessages ??= new();
validationMessages ??= [];
validationMessages.Add(new ValidationMessage("{0} has no value!", nameof(TestProperty)));
}
break;
Expand All @@ -69,7 +68,7 @@ public void ValidateTest()
{
var testObject = new ValidateableTestClass
{
TestProperty = String.Empty
TestProperty = string.Empty
};
Assert.AreEqual(ValidationStatus.Error, testObject.Validate().Status);
Assert.IsNotNull(testObject.Validate().ValidationMessages);
Expand Down
Loading

0 comments on commit a0f7cbe

Please sign in to comment.