public async Task GetLengthTest() { var res1 = await Tracklist.Clear(); Assert.True(res1); var res2 = await Tracklist.GetLength(); Assert.True(res2.Succeeded); Assert.Equal(0, res2.Result); var res3 = await Library.Search( queryArtist : "Air Supply", queryAlbum : "Strangers In Love" ); Assert.True(res3.Succeeded); Assert.True(1 <= res3.Result.Length); Assert.True(1 <= res3.Result.First().Tracks.Length); var uris = res3.Result.First().Tracks .OrderBy(e => e.TrackNo) .Select(e => e.Uri) .ToArray(); var res4 = await Tracklist.Add(uris); Assert.True(res4.Succeeded); var res5 = await Tracklist.GetLength(); Assert.True(res5.Succeeded); Assert.Equal(uris.Length, res5.Result); }
public async Task AddTest() { var res1 = await Tracklist.Clear(); Assert.True(res1); var res2 = await Library.Search( queryArtist : "Air Supply", queryAlbum : "Strangers In Love" ); Assert.True(res2.Succeeded); Assert.True(1 <= res2.Result.Length); var tracks1 = res2.Result.First().Tracks; Assert.True(1 <= tracks1.Length); var uris1 = tracks1 .OrderBy(e => e.TrackNo) .Select(e => e.Uri) .ToArray(); var res3 = await Tracklist.Add(uris1); Assert.True(res3.Succeeded); Assert.Equal(tracks1.Length, res3.Result.Length); for (var i = 0; i < tracks1.Length; i++) { var track = tracks1[i]; var result = res3.Result[i]; Assert.Equal(track.Uri, result.Track.Uri); } var res4 = await Library.Search( queryArtist : "Abba", queryAlbum : "Waterloo" ); Assert.True(res4.Succeeded); Assert.True(1 <= res4.Result.Length); var tracks2 = res4.Result.First().Tracks; Assert.True(1 <= tracks2.Length); var uris2 = tracks2 .OrderBy(e => e.TrackNo) .Select(e => e.Uri) .ToArray(); var res5 = await Tracklist.Add(uris2, 0); Assert.True(res5.Succeeded); Assert.Equal(tracks2.Length, res5.Result.Length); for (var i = 0; i < tracks2.Length; i++) { var track = tracks2[i]; var result = res5.Result[i]; Assert.Equal(track.Uri, result.Track.Uri); } var res6 = await Library.Search( queryArtist : "Air Supply", queryAlbum : "The Whole Thing's Started", queryTrackName : "Do It Again" ); Assert.True(res6.Succeeded); Assert.True(1 <= res6.Result.Length); var tracks3 = res6.Result.First().Tracks; Assert.True(1 == tracks3.Length); var insertUri = tracks3[0].Uri; var res7 = await Tracklist.Add(insertUri, 3); Assert.True(res7.Succeeded); var res8 = await Tracklist.GetLength(); Assert.Equal(tracks1.Length + tracks2.Length + 1, res8.Result); var allTracks = new List <Track>(); allTracks.AddRange(tracks2); allTracks.AddRange(tracks1); allTracks.Insert(3, tracks3[0]); var res9 = await Tracklist.GetTlTracks(); Assert.True(res9.Succeeded); Assert.Equal(allTracks.Count, res9.Result.Length); for (var i = 0; i < allTracks.Count; i++) { var track = allTracks[i]; var tlTrack = res9.Result[i]; Assert.Equal(track.Uri, tlTrack.Track.Uri); } }
public async Task RemoveTest() { var res1 = await Tracklist.Clear(); Assert.True(res1); var res2 = await Library.Search( queryArtist : "Air Supply", queryAlbum : "Strangers In Love" ); Assert.True(res2.Succeeded); Assert.True(1 <= res2.Result.Length); var tracks1 = res2.Result.First().Tracks; Assert.True(1 <= tracks1.Length); var uris1 = tracks1 .OrderBy(e => e.TrackNo) .Select(e => e.Uri) .ToArray(); var res3 = await Tracklist.Add(uris1); Assert.True(res3.Succeeded); var tlIds = res3.Result .Select(e => e.TlId) .ToArray(); var uris = res3.Result .Select(e => e.Track.Uri) .ToArray(); var res4 = await Tracklist.GetTlTracks(); Assert.True(res4.Succeeded); Assert.Contains(res4.Result, e => e.TlId == tlIds[0]); Assert.Contains(res4.Result, e => e.TlId == tlIds[1]); Assert.Contains(res4.Result, e => e.TlId == tlIds[2]); Assert.Contains(res4.Result, e => e.TlId == tlIds[3]); var res5 = await Tracklist.Remove(new int[] { tlIds[0], tlIds[1], tlIds[2], tlIds[3] }); Assert.True(res5.Succeeded); Assert.Equal(4, res5.Result.Length); var res6 = await Tracklist.GetLength(); Assert.True(res6.Succeeded); Assert.Equal(tracks1.Length - 4, res6.Result); var res7 = await Tracklist.GetTlTracks(); Assert.True(res7.Succeeded); Assert.DoesNotContain(res7.Result, e => e.TlId == tlIds[0]); Assert.DoesNotContain(res7.Result, e => e.TlId == tlIds[1]); Assert.DoesNotContain(res7.Result, e => e.TlId == tlIds[2]); Assert.DoesNotContain(res7.Result, e => e.TlId == tlIds[3]); Assert.Contains(res7.Result, e => e.Track.Uri == uris[4]); Assert.Contains(res7.Result, e => e.Track.Uri == uris[5]); Assert.Contains(res7.Result, e => e.Track.Uri == uris[6]); var res8 = await Tracklist.Remove(new string[] { uris[4], uris[5], uris[6] }); Assert.True(res8.Succeeded); Assert.Equal(3, res8.Result.Length); var res9 = await Tracklist.GetLength(); Assert.True(res9.Succeeded); Assert.Equal(tracks1.Length - 7, res9.Result); var res10 = await Tracklist.GetTlTracks(); Assert.True(res10.Succeeded); Assert.DoesNotContain(res10.Result, e => e.Track.Uri == uris[4]); Assert.DoesNotContain(res10.Result, e => e.Track.Uri == uris[5]); Assert.DoesNotContain(res10.Result, e => e.Track.Uri == uris[6]); Assert.Contains(res10.Result, e => e.TlId == tlIds[7]); Assert.Contains(res10.Result, e => e.Track.Uri == uris[8]); var res11 = await Tracklist.Remove(tlIds[7]); Assert.True(res11.Succeeded); #pragma warning disable xUnit2013 // Do not use equality check to check for collection size. Assert.Equal(1, res11.Result.Length); #pragma warning restore xUnit2013 // Do not use equality check to check for collection size. var res12 = await Tracklist.Remove(uris[8]); Assert.True(res12.Succeeded); #pragma warning disable xUnit2013 // Do not use equality check to check for collection size. Assert.Equal(1, res12.Result.Length); #pragma warning restore xUnit2013 // Do not use equality check to check for collection size. var res13 = await Tracklist.GetLength(); Assert.True(res13.Succeeded); Assert.Equal(tracks1.Length - 9, res13.Result); var res14 = await Tracklist.GetTlTracks(); Assert.True(res14.Succeeded); Assert.DoesNotContain(res14.Result, e => e.TlId == tlIds[7]); Assert.DoesNotContain(res14.Result, e => e.Track.Uri == uris[8]); }