Skip to content

Commit

Permalink
Forced styling with editorconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Tapanila committed Oct 25, 2024
1 parent 86928f0 commit aca82c1
Show file tree
Hide file tree
Showing 57 changed files with 309 additions and 224 deletions.
5 changes: 0 additions & 5 deletions Sharpcaster.Test/ChromecastApplicationTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace Sharpcaster.Test
[Collection("SingleCollection")]
public class ChromecastApplicationTester : IClassFixture<ChromecastDevicesFixture>
{

private ITestOutputHelper output;
public ChromecastApplicationTester(ITestOutputHelper outputHelper, ChromecastDevicesFixture fixture)
{
Expand Down Expand Up @@ -48,7 +47,6 @@ public async Task ConnectToChromecastAndLaunchApplicationTwice(ChromecastReceive
Assert.Equal(firstLaunchTransportId, status.Application.TransportId);
}


[Theory(Skip = "This does not pass any more. Now my JBL reacts as the other device - not changing the Transport ID !?")]
[MemberData(nameof(ChromecastReceiversFilter.GetJblSpeaker), MemberType = typeof(ChromecastReceiversFilter))]
public async Task ConnectToChromecastAndLaunchApplicationTwiceWithoutJoining1(ChromecastReceiver receiver)
Expand All @@ -63,7 +61,6 @@ public async Task ConnectToChromecastAndLaunchApplicationTwiceWithoutJoining1(Ch
_ = await client.ConnectChromecast(receiver);
status = await client.LaunchApplicationAsync("B3419EF5", false);


// My JBL Device (almost every time - but not always ) makes a new ID here!!!! (The other device - ChromecastAudio DOES NOT!?)
Assert.NotEqual(firstLaunchTransportId, status.Application.TransportId);
}
Expand All @@ -86,7 +83,6 @@ public async Task ConnectToChromecastAndLaunchApplicationTwiceWithoutJoining2(Ch
Assert.Equal(firstLaunchTransportId, status.Application.TransportId);
}


[Theory]
[MemberData(nameof(ChromecastReceiversFilter.GetAll), MemberType = typeof(ChromecastReceiversFilter))]
public async Task ConnectToChromecastAndLaunchApplicationAThenLaunchApplicationB(ChromecastReceiver receiver)
Expand Down Expand Up @@ -133,7 +129,6 @@ public async Task ConnectToChromecastAndLaunchWebPage(ChromecastReceiver receive
SessionId = client.GetChromecastStatus().Application.SessionId
};


await client.SendAsync(null, "urn:x-cast:com.boombatower.chromecast-dashboard", req, client.GetChromecastStatus().Application.SessionId);
await Task.Delay(5000);
}
Expand Down
5 changes: 2 additions & 3 deletions Sharpcaster.Test/ChromecastConnectionTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task SearchChromecastsAndConnectToItThenWaitForItToShutdown(Chromec
var client = await TestHelper.CreateConnectAndLoadAppClient(output, receiver);

Assert.NotNull(client.GetChromecastStatus());
AutoResetEvent _autoResetEvent = new AutoResetEvent(false);
AutoResetEvent _autoResetEvent = new(false);

client.Disconnected += (sender, args) =>
{
Expand All @@ -58,7 +58,7 @@ public async Task TestingHeartBeat(ChromecastReceiver receiver)
{
var TestHelper = new TestHelper();
ChromecastClient client = await TestHelper.CreateConnectAndLoadAppClient(output, receiver);
AutoResetEvent _autoResetEvent = new AutoResetEvent(false);
AutoResetEvent _autoResetEvent = new(false);

//We are going to load video & start playing it
//Then we are going to pause and play it quite many times
Expand Down Expand Up @@ -107,6 +107,5 @@ public async Task TestingHeartBeat(ChromecastReceiver receiver)

Assert.Equal(expectedSequence, runSequence);
}

}
}
14 changes: 4 additions & 10 deletions Sharpcaster.Test/LoggingTester.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Sharpcaster.Models;
using Sharpcaster.Models.Media;
using Sharpcaster.Test.helper;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xunit;
Expand All @@ -8,13 +9,9 @@
namespace Sharpcaster.Test
{
[Collection("SingleCollection")]
public class LoggingTester
public class LoggingTester(ITestOutputHelper outputHelper)
{
ITestOutputHelper output;
public LoggingTester(ITestOutputHelper outputHelper)
{
output = outputHelper;
}
readonly ITestOutputHelper output = outputHelper;

[Fact]
public void TestLogging()
Expand All @@ -30,7 +27,7 @@ public void TestLogging()
[MemberData(nameof(ChromecastReceiversFilter.GetAll), MemberType = typeof(ChromecastReceiversFilter))]
public async Task TestPlayMediaWorksWithoutLogging(ChromecastReceiver receiver)
{
ChromecastClient client = new ChromecastClient();
ChromecastClient client = new();
await client.ConnectChromecast(receiver);
await client.LaunchApplicationAsync("B3419EF5", false);

Expand All @@ -44,9 +41,6 @@ public async Task TestPlayMediaWorksWithoutLogging(ChromecastReceiver receiver)
Assert.Equal(PlayerStateType.Playing, status.PlayerState);
Assert.Single(status.Items);
Assert.Equal(status.CurrentItemId, status.Items[0].ItemId);

}


}
}
3 changes: 1 addition & 2 deletions Sharpcaster.Test/MdnsChromecastLocatorTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ public async Task SearchChromecastsTrickerEvent()
public async Task SearchChromecastsWithTooShortTimeout()
{
IChromecastLocator locator = new MdnsChromecastLocator();
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromMilliseconds(0));
CancellationTokenSource cancellationTokenSource = new(TimeSpan.FromMilliseconds(0));
var chromecasts = await locator.FindReceiversAsync(cancellationTokenSource.Token);
Assert.Empty(chromecasts);
}


[Fact]
public async Task SearchChromecastsCancellationToken()
{
Expand Down
34 changes: 9 additions & 25 deletions Sharpcaster.Test/MediaChannelTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,20 @@

namespace Sharpcaster.Test
{

[Collection("SingleCollection")]
public class MediaChannelTester : IClassFixture<ChromecastDevicesFixture>
{

private ITestOutputHelper output;
public MediaChannelTester(ITestOutputHelper outputHelper, ChromecastDevicesFixture fixture)
{
output = outputHelper;
output.WriteLine("Fixture has found " + ChromecastDevicesFixture.Receivers?.Count + " receivers with " + fixture.GetSearchesCnt() + " searche(s).");
}


[Theory(Skip = "Skipped for autotesting because manual intervention on device is needed for this test!")]
[MemberData(nameof(ChromecastReceiversFilter.GetJblSpeaker), MemberType = typeof(ChromecastReceiversFilter))]
public async Task TestWaitForDeviceStopDuringPlayback(ChromecastReceiver receiver)
{

// To get this test Passing, you have to manually operate the used Chromecast device!
// I use it with a JBL speaker device. This device has 5 buttons. (ON/OFF, Vol-, Vol+, Play/Pause, (and WLAN-Connect))
// Vol+/- and Play/Pause do operate and trigger 'unasked' MediaStatusChanged events which work as designed.
Expand All @@ -46,13 +42,12 @@ public async Task TestWaitForDeviceStopDuringPlayback(ChromecastReceiver receive
ChromecastClient client = await TestHelper.CreateConnectAndLoadAppClient(output, receiver);
if (receiver.Model == "JBL Playlist")
{

var media = new Media
{
ContentUrl = "https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/DesigningForGoogleCast.mp4"
};

AutoResetEvent _disconnectReceived = new AutoResetEvent(false);
AutoResetEvent _disconnectReceived = new(false);
IMediaChannel mediaChannel = client.MediaChannel;

mediaChannel.StatusChanged += (object sender, EventArgs e) =>
Expand Down Expand Up @@ -96,18 +91,16 @@ public async Task TestWaitForDeviceStopDuringPlayback(ChromecastReceiver receive
await client.DisconnectAsync();
}


[Theory]
[MemberData(nameof(ChromecastReceiversFilter.GetChromecastUltra), MemberType = typeof(ChromecastReceiversFilter))]
public async Task TestLoadingMediaQueueAndNavigateNextPrev(ChromecastReceiver receiver)
{

var TestHelper = new TestHelper();
ChromecastClient client = await TestHelper.CreateConnectAndLoadAppClient(output, receiver);

AutoResetEvent _autoResetEvent = new AutoResetEvent(false);
AutoResetEvent _autoResetEvent = new(false);
IMediaChannel mediaChannel = client.MediaChannel;
QueueItem[] MyCd = TestHelper.CreateTestCd();
QueueItem[] MyCd = helper.TestHelper.CreateTestCd;

int testSequenceCount = 0;
var mediaStatusChanged = 0;
Expand All @@ -123,7 +116,6 @@ public async Task TestLoadingMediaQueueAndNavigateNextPrev(ChromecastReceiver re

if (currentItemId != -1 && status.PlayerState == PlayerStateType.Playing)
{

if (status?.Items?.ToList()?.Where(i => i.ItemId == currentItemId).FirstOrDefault()?.Media?.ContentUrl?.Equals(MyCd[0].Media.ContentUrl) ?? false)
{
if (testSequenceCount == 0)
Expand All @@ -145,7 +137,6 @@ public async Task TestLoadingMediaQueueAndNavigateNextPrev(ChromecastReceiver re
output.WriteLine("test Sequence finished");
_autoResetEvent.Set();
}

}
else if (status?.Items?.ToList()?.Where(i => i.ItemId == currentItemId).FirstOrDefault()?.Media?.ContentUrl?.Equals(MyCd[1].Media.ContentUrl) ?? false)
{
Expand All @@ -155,7 +146,6 @@ public async Task TestLoadingMediaQueueAndNavigateNextPrev(ChromecastReceiver re
output.WriteLine("Lets goto back to first one");
status = await mediaChannel.QueuePrevAsync();
}

}
}
catch (Exception ex)
Expand All @@ -165,8 +155,6 @@ public async Task TestLoadingMediaQueueAndNavigateNextPrev(ChromecastReceiver re
}
};



MediaStatus status = await client.MediaChannel.QueueLoadAsync(MyCd);

Assert.Equal(PlayerStateType.Playing, status.PlayerState);
Expand All @@ -187,7 +175,7 @@ public async Task TestLoadMediaQueueAndCheckContent(ChromecastReceiver receiver)
var TestHelper = new TestHelper();
ChromecastClient client = await TestHelper.CreateConnectAndLoadAppClient(output, receiver);

QueueItem[] MyCd = TestHelper.CreateTestCd();
QueueItem[] MyCd = helper.TestHelper.CreateTestCd;

MediaStatus status = await client.MediaChannel.QueueLoadAsync(MyCd);

Expand All @@ -203,7 +191,7 @@ public async Task TestLoadMediaQueueAndCheckContent(ChromecastReceiver receiver)

foreach (int id in ids)
{
QueueItem[] items = await client.MediaChannel.QueueGetItemsAsync(new int[] { id });
QueueItem[] items = await client.MediaChannel.QueueGetItemsAsync([id]);
Assert.Single(items);
}

Expand All @@ -212,16 +200,14 @@ public async Task TestLoadMediaQueueAndCheckContent(ChromecastReceiver receiver)
await client.DisconnectAsync();
}



[Theory]
[MemberData(nameof(ChromecastReceiversFilter.GetAll), MemberType = typeof(ChromecastReceiversFilter))]
public async Task TestLoadingMediaQueue(ChromecastReceiver receiver)
{
var TestHelper = new TestHelper();
ChromecastClient client = await TestHelper.CreateConnectAndLoadAppClient(output, receiver);

QueueItem[] MyCd = TestHelper.CreateTestCd();
QueueItem[] MyCd = helper.TestHelper.CreateTestCd;

MediaStatus status = await client.MediaChannel.QueueLoadAsync(MyCd);

Expand Down Expand Up @@ -251,7 +237,6 @@ public async Task TestLoadingMedia(ChromecastReceiver receiver)
await client.DisconnectAsync();
}


[Theory]
[MemberData(nameof(ChromecastReceiversFilter.GetAll), MemberType = typeof(ChromecastReceiversFilter))]
public async Task StartApplicationAThenStartBAndLoadMedia(ChromecastReceiver receiver)
Expand All @@ -278,7 +263,7 @@ public async Task TestLoadingAndPausingMedia(ChromecastReceiver receiver)
{
var TestHelper = new TestHelper();
ChromecastClient client = await TestHelper.CreateConnectAndLoadAppClient(output, receiver);
AutoResetEvent _autoResetEvent = new AutoResetEvent(false);
AutoResetEvent _autoResetEvent = new(false);

var media = new Media
{
Expand Down Expand Up @@ -325,7 +310,7 @@ public async Task TestLoadingAndStoppingMedia(ChromecastReceiver receiver)
{
var TestHelper = new TestHelper();
ChromecastClient client = await TestHelper.CreateConnectAndLoadAppClient(output, receiver);
AutoResetEvent _autoResetEvent = new AutoResetEvent(false);
AutoResetEvent _autoResetEvent = new(false);

var media = new Media
{
Expand Down Expand Up @@ -512,12 +497,11 @@ public async Task TestRepeatingAllAndShuffleQueueMedia(ChromecastReceiver receiv
[MemberData(nameof(ChromecastReceiversFilter.GetChromecastUltra), MemberType = typeof(ChromecastReceiversFilter))]
public async Task TestFailingQueue(ChromecastReceiver receiver)
{

var TestHelper = new TestHelper();
ChromecastClient client = await TestHelper.CreateConnectAndLoadAppClient(output, receiver);
bool errorHappened = false;

QueueItem[] MyCd = TestHelper.CreateFailingQueu();
QueueItem[] MyCd = helper.TestHelper.CreateFailingQueu;

client.MediaChannel.ErrorHappened += (object sender, ErrorMessage e) =>
{
Expand Down
3 changes: 1 addition & 2 deletions Sharpcaster.Test/MultiZoneChannelTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public async Task TestingMultiZone(ChromecastReceiver receiver)
{
var TestHelper = new TestHelper();
ChromecastClient client = await TestHelper.CreateConnectAndLoadAppClient(output, receiver);
AutoResetEvent _autoResetEvent = new AutoResetEvent(false);
AutoResetEvent _autoResetEvent = new(false);

//We are going to load video & start playing it
//Then we are going to change the volume few times
Expand Down Expand Up @@ -68,6 +68,5 @@ public async Task TestingMultiZone(ChromecastReceiver receiver)

Assert.True(_autoResetEvent.WaitOne(1000));
}

}
}
9 changes: 3 additions & 6 deletions Sharpcaster.Test/MultipleClientTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ public MultipleClientTester(ITestOutputHelper outputHelper, ChromecastDevicesFix
output.WriteLine("Fixture has found " + ChromecastDevicesFixture.Receivers?.Count + " receivers with " + fixture.GetSearchesCnt() + " searche(s).");
}


[Theory]
[MemberData(nameof(ChromecastReceiversFilter.GetChromecastUltra), MemberType = typeof(ChromecastReceiversFilter))]
public async Task TestTwoClients(ChromecastReceiver receiver)
{
var TestHelper = new TestHelper();
AutoResetEvent _autoResetEvent = new AutoResetEvent(false);
AutoResetEvent _autoResetEvent = new(false);
var client1 = await TestHelper.CreateConnectAndLoadAppClient(output, receiver);
var client2 = await TestHelper.CreateAndConnectClient(output, receiver);
await client2.LaunchApplicationAsync("B3419EF5", true);
Expand All @@ -40,7 +39,6 @@ public async Task TestTwoClients(ChromecastReceiver receiver)
ContentUrl = "https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/DesigningForGoogleCast.mp4"
};


var mediaStatus = await client1.MediaChannel.LoadAsync(media);
await client1.MediaChannel.PlayAsync();

Expand All @@ -52,8 +50,8 @@ public async Task TestTwoClients(ChromecastReceiver receiver)
public async Task TestThreeClients(ChromecastReceiver receiver)
{
var TestHelper = new TestHelper();
AutoResetEvent _autoResetEvent2 = new AutoResetEvent(false);
AutoResetEvent _autoResetEvent3 = new AutoResetEvent(false);
AutoResetEvent _autoResetEvent2 = new(false);
AutoResetEvent _autoResetEvent3 = new(false);
var client1 = await TestHelper.CreateConnectAndLoadAppClient(output, receiver);
var client2 = await TestHelper.CreateAndConnectClient(output, receiver);
var client3 = await TestHelper.CreateAndConnectClient(output, receiver);
Expand All @@ -75,7 +73,6 @@ public async Task TestThreeClients(ChromecastReceiver receiver)
ContentUrl = "https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/DesigningForGoogleCast.mp4"
};


var mediaStatus = await client1.MediaChannel.LoadAsync(media);
await client1.MediaChannel.PlayAsync();

Expand Down
1 change: 0 additions & 1 deletion Sharpcaster.Test/ReceiverChannelTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public ReceiverChannelTester(ITestOutputHelper outputHelper, ChromecastDevicesFi
output.WriteLine("Fixture has found " + ChromecastDevicesFixture.Receivers?.Count + " receivers with " + fixture.GetSearchesCnt() + " searche(s).");
}


[Theory]
[MemberData(nameof(ChromecastReceiversFilter.GetAll), MemberType = typeof(ChromecastReceiversFilter))]
public async Task TestMute(ChromecastReceiver receiver)
Expand Down
3 changes: 1 addition & 2 deletions Sharpcaster.Test/SpotifyTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Sharpcaster.Test
{
public class SpotifyTester : IClassFixture<ChromecastDevicesFixture>
{
private ITestOutputHelper output;
private readonly ITestOutputHelper output;

public SpotifyTester(ITestOutputHelper outputHelper, ChromecastDevicesFixture fixture)
{
Expand Down Expand Up @@ -121,7 +121,6 @@ public async Task<string> GetSpotifyAccessTokenForChromecast(string originalAcce
deviceId
});


var result = await client.PostAsync("/device-auth/v1/refresh", jsonContent);
result.EnsureSuccessStatusCode();
var resultString = await result.Content.ReadAsStringAsync();
Expand Down
Loading

0 comments on commit aca82c1

Please sign in to comment.