Skip to content

Commit

Permalink
fix: Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
angelobreuer committed Sep 21, 2023
1 parent dd5ed3a commit 75318cd
Showing 1 changed file with 98 additions and 14 deletions.
112 changes: 98 additions & 14 deletions src/Lavalink4NET.Tests/Players/PlayerManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ public void TestPlayerManagerHasNoPlayersInitially()
public async Task TestPlayerManagerCreatesPlayer()
{
// Arrange
var model = new PlayerInformationModel(GuildId: 0, CurrentTrack: null, Volume: 1F, IsPaused: false, VoiceState: null!, Filters: null!);
var model = new PlayerInformationModel(
GuildId: 0,
CurrentTrack: null,
Volume: 1F,
IsPaused: false,
VoiceState: new VoiceStateModel("abc", "abc", "abc"),
Filters: null!);

var apiClient = Mock.Of<ILavalinkApiClient>(x
=> x.UpdatePlayerAsync(It.IsAny<string>(), It.IsAny<ulong>(), It.IsAny<PlayerUpdateProperties>(), It.IsAny<CancellationToken>())
Expand Down Expand Up @@ -92,7 +98,13 @@ public async Task TestPlayerManagerCreatesPlayer()
public async Task TestPlayerManagerDoesNotReturnDestroyedPlayers()
{
// Arrange
var model = new PlayerInformationModel(GuildId: 0, CurrentTrack: null, Volume: 1F, IsPaused: false, VoiceState: null!, Filters: null!);
var model = new PlayerInformationModel(
GuildId: 0,
CurrentTrack: null,
Volume: 1F,
IsPaused: false,
VoiceState: new VoiceStateModel("abc", "abc", "abc"),
Filters: null!);

var apiClient = Mock.Of<ILavalinkApiClient>(x
=> x.UpdatePlayerAsync(It.IsAny<string>(), It.IsAny<ulong>(), It.IsAny<PlayerUpdateProperties>(), It.IsAny<CancellationToken>())
Expand Down Expand Up @@ -126,7 +138,13 @@ public async Task TestPlayerManagerDoesNotReturnDestroyedPlayers()
public async Task TestGetPlayerReturnsPlayerFromJoinAsync()
{
// Arrange
var model = new PlayerInformationModel(GuildId: 0, CurrentTrack: null, Volume: 1F, IsPaused: false, VoiceState: null!, Filters: null!);
var model = new PlayerInformationModel(
GuildId: 0,
CurrentTrack: null,
Volume: 1F,
IsPaused: false,
VoiceState: new VoiceStateModel("abc", "abc", "abc"),
Filters: null!);

var apiClient = Mock.Of<ILavalinkApiClient>(x
=> x.UpdatePlayerAsync(It.IsAny<string>(), It.IsAny<ulong>(), It.IsAny<PlayerUpdateProperties>(), It.IsAny<CancellationToken>())
Expand Down Expand Up @@ -160,7 +178,13 @@ public async Task TestGetPlayerReturnsPlayerFromJoinAsync()
public async Task TestGetPlayerThrowsIfPlayerTypeDoesNotMatchAsync()
{
// Arrange
var model = new PlayerInformationModel(GuildId: 0, CurrentTrack: null, Volume: 1F, IsPaused: false, VoiceState: null!, Filters: null!);
var model = new PlayerInformationModel(
GuildId: 0,
CurrentTrack: null,
Volume: 1F,
IsPaused: false,
VoiceState: new VoiceStateModel("abc", "abc", "abc"),
Filters: null!);

var apiClient = Mock.Of<ILavalinkApiClient>(x
=> x.UpdatePlayerAsync(It.IsAny<string>(), It.IsAny<ulong>(), It.IsAny<PlayerUpdateProperties>(), It.IsAny<CancellationToken>())
Expand Down Expand Up @@ -198,7 +222,13 @@ await Assert
public async Task TestGetPlayerReturnsTypedPlayerAsync()
{
// Arrange
var model = new PlayerInformationModel(GuildId: 0, CurrentTrack: null, Volume: 1F, IsPaused: false, VoiceState: null!, Filters: null!);
var model = new PlayerInformationModel(
GuildId: 0,
CurrentTrack: null,
Volume: 1F,
IsPaused: false,
VoiceState: new VoiceStateModel("abc", "abc", "abc"),
Filters: null!);

var apiClient = Mock.Of<ILavalinkApiClient>(x
=> x.UpdatePlayerAsync(It.IsAny<string>(), It.IsAny<ulong>(), It.IsAny<PlayerUpdateProperties>(), It.IsAny<CancellationToken>())
Expand Down Expand Up @@ -234,7 +264,13 @@ public async Task TestGetPlayerReturnsTypedPlayerAsync()
public async Task TestGetPlayersReturnsTypedPlayersAsync()
{
// Arrange
var model = new PlayerInformationModel(GuildId: 0, CurrentTrack: null, Volume: 1F, IsPaused: false, VoiceState: null!, Filters: null!);
var model = new PlayerInformationModel(
GuildId: 0,
CurrentTrack: null,
Volume: 1F,
IsPaused: false,
VoiceState: new VoiceStateModel("abc", "abc", "abc"),
Filters: null!);

var apiClient = Mock.Of<ILavalinkApiClient>(x
=> x.UpdatePlayerAsync(It.IsAny<string>(), It.IsAny<ulong>(), It.IsAny<PlayerUpdateProperties>(), It.IsAny<CancellationToken>())
Expand Down Expand Up @@ -317,7 +353,13 @@ public void TestHasPlayerFalseIfGuildHasNoPlayer()
public async Task TestHasPlayerTrueIfGuildHasPlayerAsync()
{
// Arrange
var model = new PlayerInformationModel(GuildId: 0, CurrentTrack: null, Volume: 1F, IsPaused: false, VoiceState: null!, Filters: null!);
var model = new PlayerInformationModel(
GuildId: 0,
CurrentTrack: null,
Volume: 1F,
IsPaused: false,
VoiceState: new VoiceStateModel("abc", "abc", "abc"),
Filters: null!);

var apiClient = Mock.Of<ILavalinkApiClient>(x
=> x.UpdatePlayerAsync(It.IsAny<string>(), It.IsAny<ulong>(), It.IsAny<PlayerUpdateProperties>(), It.IsAny<CancellationToken>())
Expand Down Expand Up @@ -351,7 +393,13 @@ await playerManager.JoinAsync(
public async Task TestHasPlayerFalseIfGuildHasPlayerButPlayerIsDestroyedAsync()
{
// Arrange
var model = new PlayerInformationModel(GuildId: 0, CurrentTrack: null, Volume: 1F, IsPaused: false, VoiceState: null!, Filters: null!);
var model = new PlayerInformationModel(
GuildId: 0,
CurrentTrack: null,
Volume: 1F,
IsPaused: false,
VoiceState: new VoiceStateModel("abc", "abc", "abc"),
Filters: null!);

var apiClient = Mock.Of<ILavalinkApiClient>(x
=> x.UpdatePlayerAsync(It.IsAny<string>(), It.IsAny<ulong>(), It.IsAny<PlayerUpdateProperties>(), It.IsAny<CancellationToken>())
Expand Down Expand Up @@ -387,7 +435,13 @@ public async Task TestHasPlayerFalseIfGuildHasPlayerButPlayerIsDestroyedAsync()
public async Task TestSimpleRetrieveAsync()
{
// Arrange
var model = new PlayerInformationModel(GuildId: 0, CurrentTrack: null, Volume: 1F, IsPaused: false, VoiceState: null!, Filters: null!);
var model = new PlayerInformationModel(
GuildId: 0,
CurrentTrack: null,
Volume: 1F,
IsPaused: false,
VoiceState: new VoiceStateModel("abc", "abc", "abc"),
Filters: null!);

var apiClient = Mock.Of<ILavalinkApiClient>(x
=> x.UpdatePlayerAsync(It.IsAny<string>(), It.IsAny<ulong>(), It.IsAny<PlayerUpdateProperties>(), It.IsAny<CancellationToken>())
Expand Down Expand Up @@ -424,7 +478,13 @@ public async Task TestSimpleRetrieveAsync()
public async Task TestSimpleRetrieveWithoutJoinFailsWithBotNotConnectedAsync()
{
// Arrange
var model = new PlayerInformationModel(GuildId: 0, CurrentTrack: null, Volume: 1F, IsPaused: false, VoiceState: null!, Filters: null!);
var model = new PlayerInformationModel(
GuildId: 0,
CurrentTrack: null,
Volume: 1F,
IsPaused: false,
VoiceState: new VoiceStateModel("abc", "abc", "abc"),
Filters: null!);

var apiClient = Mock.Of<ILavalinkApiClient>(x
=> x.UpdatePlayerAsync(It.IsAny<string>(), It.IsAny<ulong>(), It.IsAny<PlayerUpdateProperties>(), It.IsAny<CancellationToken>())
Expand Down Expand Up @@ -461,7 +521,13 @@ public async Task TestSimpleRetrieveWithoutJoinFailsWithBotNotConnectedAsync()
public async Task TestRetrieveWithFailingPreconditionAsync()
{
// Arrange
var model = new PlayerInformationModel(GuildId: 0, CurrentTrack: null, Volume: 1F, IsPaused: false, VoiceState: null!, Filters: null!);
var model = new PlayerInformationModel(
GuildId: 0,
CurrentTrack: null,
Volume: 1F,
IsPaused: false,
VoiceState: new VoiceStateModel("abc", "abc", "abc"),
Filters: null!);

var apiClient = Mock.Of<ILavalinkApiClient>(x
=> x.UpdatePlayerAsync(It.IsAny<string>(), It.IsAny<ulong>(), It.IsAny<PlayerUpdateProperties>(), It.IsAny<CancellationToken>())
Expand Down Expand Up @@ -500,7 +566,13 @@ public async Task TestRetrieveWithFailingPreconditionAsync()
public async Task TestRetrieveWithNonFailingPreconditionAsync()
{
// Arrange
var model = new PlayerInformationModel(GuildId: 0, CurrentTrack: null, Volume: 1F, IsPaused: false, VoiceState: null!, Filters: null!);
var model = new PlayerInformationModel(
GuildId: 0,
CurrentTrack: null,
Volume: 1F,
IsPaused: false,
VoiceState: new VoiceStateModel("abc", "abc", "abc"),
Filters: null!);

var apiClient = Mock.Of<ILavalinkApiClient>(x
=> x.UpdatePlayerAsync(It.IsAny<string>(), It.IsAny<ulong>(), It.IsAny<PlayerUpdateProperties>(), It.IsAny<CancellationToken>())
Expand Down Expand Up @@ -537,7 +609,13 @@ public async Task TestRetrieveWithNonFailingPreconditionAsync()
public async Task TestRetrieveWithJoinWithoutMemberChannelAsync()
{
// Arrange
var model = new PlayerInformationModel(GuildId: 0, CurrentTrack: null, Volume: 1F, IsPaused: false, VoiceState: null!, Filters: null!);
var model = new PlayerInformationModel(
GuildId: 0,
CurrentTrack: null,
Volume: 1F,
IsPaused: false,
VoiceState: new VoiceStateModel("abc", "abc", "abc"),
Filters: null!);

var apiClient = Mock.Of<ILavalinkApiClient>(x
=> x.UpdatePlayerAsync(It.IsAny<string>(), It.IsAny<ulong>(), It.IsAny<PlayerUpdateProperties>(), It.IsAny<CancellationToken>())
Expand Down Expand Up @@ -575,7 +653,13 @@ public async Task TestRetrieveWithJoinWithoutMemberChannelAsync()
public async Task TestRetrieveWithMemberVoiceStateAlwaysRequiredFailsAsync()
{
// Arrange
var model = new PlayerInformationModel(GuildId: 0, CurrentTrack: null, Volume: 1F, IsPaused: false, VoiceState: null!, Filters: null!);
var model = new PlayerInformationModel(
GuildId: 0,
CurrentTrack: null,
Volume: 1F,
IsPaused: false,
VoiceState: new VoiceStateModel("abc", "abc", "abc"),
Filters: null!);

var apiClient = Mock.Of<ILavalinkApiClient>(x
=> x.UpdatePlayerAsync(It.IsAny<string>(), It.IsAny<ulong>(), It.IsAny<PlayerUpdateProperties>(), It.IsAny<CancellationToken>())
Expand Down

0 comments on commit 75318cd

Please sign in to comment.