diff --git a/SoundSwitch.Tests/PlaybackDevices.cs b/SoundSwitch.Tests/PlaybackDevices.cs index 4ecdf350ab..d71b7c2ec3 100644 --- a/SoundSwitch.Tests/PlaybackDevices.cs +++ b/SoundSwitch.Tests/PlaybackDevices.cs @@ -194,8 +194,8 @@ public void TestCycleConsoleAudioDevice() audioMoqI.VerifyGet(a => a.Id); audioMoqII.VerifyGet(a => a.Id); listerMoq.Verify(l => l.GetPlaybackDevices()); - audioMoqII.Verify(a => a.SetAsDefault(It.Is(role => role == Role.Console))); - audioMoqII.Verify(a => a.SetAsDefault(It.Is(role => role == Role.Multimedia))); + audioMoqI.Verify(a => a.SetAsDefault(It.Is(role => role == Role.Console))); + audioMoqI.Verify(a => a.SetAsDefault(It.Is(role => role == Role.Multimedia))); } [Test] @@ -234,7 +234,7 @@ public void TestCycleCommunicationsAudioDevice() audioMoqI.VerifyGet(a => a.Id); audioMoqII.VerifyGet(a => a.Id); listerMoq.Verify(l => l.GetPlaybackDevices()); - audioMoqI.Verify(a => a.SetAsDefault(It.Is(role => role == Role.All))); + audioMoqII.Verify(a => a.SetAsDefault(It.Is(role => role == Role.All))); } [Test] diff --git a/SoundSwitch.Tests/RecordingDevices.cs b/SoundSwitch.Tests/RecordingDevices.cs index e59f25564f..68cc44b386 100644 --- a/SoundSwitch.Tests/RecordingDevices.cs +++ b/SoundSwitch.Tests/RecordingDevices.cs @@ -235,7 +235,7 @@ public void TestCycleCommunicationsAudioDevice() audioMoqI.VerifyGet(a => a.Id); audioMoqII.VerifyGet(a => a.Id); listerMoq.Verify(l => l.GetRecordingDevices()); - audioMoqII.Verify(a => a.SetAsDefault(It.Is(role => role == Role.All))); + audioMoqI.Verify(a => a.SetAsDefault(It.Is(role => role == Role.All))); } [Test] diff --git a/SoundSwitch/Framework/DeviceCyclerManager/DeviceCycler/ADeviceCycler.cs b/SoundSwitch/Framework/DeviceCyclerManager/DeviceCycler/ADeviceCycler.cs index 5d46a925ef..ba619c9289 100644 --- a/SoundSwitch/Framework/DeviceCyclerManager/DeviceCycler/ADeviceCycler.cs +++ b/SoundSwitch/Framework/DeviceCyclerManager/DeviceCycler/ADeviceCycler.cs @@ -24,17 +24,13 @@ public abstract class ADeviceCycler : IDeviceCycler /// /// /// - /// /// protected IAudioDevice GetNextDevice(ICollection audioDevices, AudioDeviceType type) { IAudioDevice lastDevice; - if (!_lastDevices.TryGetValue(type, out lastDevice)) - { - return audioDevices.First(); - } + _lastDevices.TryGetValue(type, out lastDevice); - var defaultDev = audioDevices.FirstOrDefault(device => device.Id == lastDevice.Id) ?? + var defaultDev = lastDevice ?? audioDevices.FirstOrDefault(device => device.IsDefault(Role.Console)) ?? audioDevices.Last(); var next = audioDevices.SkipWhile((device, i) => !Equals(device, defaultDev)).Skip(1).FirstOrDefault() ??