diff --git a/RefreshTests.GameServer/Tests/Levels/LevelListOverrideTests.cs b/RefreshTests.GameServer/Tests/Levels/LevelListOverrideTests.cs index dc7fb467..f4c69096 100644 --- a/RefreshTests.GameServer/Tests/Levels/LevelListOverrideTests.cs +++ b/RefreshTests.GameServer/Tests/Levels/LevelListOverrideTests.cs @@ -3,7 +3,9 @@ using Refresh.GameServer.Authentication; using Refresh.GameServer.Services; using Refresh.GameServer.Types.Levels; +using Refresh.GameServer.Types.Lists; using Refresh.GameServer.Types.UserData; +using RefreshTests.GameServer.Extensions; using RefreshTests.GameServer.Logging; namespace RefreshTests.GameServer.Tests.Levels; @@ -39,15 +41,39 @@ public void CanGetOverriddenLevels() GameUser user = context.CreateUser(); GameLevel level = context.CreateLevel(user, "dingus 2B47430C-70F1-4A21-A1D0-EC3011A62239"); - using HttpClient client = context.GetAuthenticatedClient(TokenType.Game); + using HttpClient client = context.GetAuthenticatedClient(TokenType.Game, user); // Verify that the endpoint isn't already attempting to return anything // This can be any endpoint that doesnt return all levels but I chose mmpicks HttpResponseMessage message = client.GetAsync("/lbp/slots/mmpicks").Result; Assert.That(message.StatusCode, Is.EqualTo(OK)); - Assert.That(message.Content.ReadAsStringAsync().Result, Does.Not.Contain(level.Title)); + SerializedMinimalLevelList levelList = message.Content.ReadAsXML(); + Assert.That(levelList.Items, Is.Empty); + //Make sure we dont have an override set LevelListOverrideService overrideService = context.GetService(); Assert.That(overrideService.UserHasOverrides(user), Is.False); + + //Set a level as the override + message = client.PostAsync($"/api/v3/levels/id/{level.LevelId}/setAsOverride", new ByteArrayContent(Array.Empty())).Result; + Assert.That(message.StatusCode, Is.EqualTo(OK)); + + context.Database.Refresh(); + + //Assert that the override was set in the database properly + Assert.That(overrideService.UserHasOverrides(user), Is.True); + + //Get the slots, and make sure it contains the level we set as the override + message = client.GetAsync("/lbp/slots/mmpicks").Result; + Assert.That(message.StatusCode, Is.EqualTo(OK)); + levelList = message.Content.ReadAsXML(); + Assert.That(levelList.Items, Has.Count.EqualTo(1)); + Assert.That(levelList.Items[0].LevelId, Is.EqualTo(level.LevelId)); + + //Verify the team picks slot list has stopped pointing to the user override + message = client.GetAsync("/lbp/slots/mmpicks").Result; + Assert.That(message.StatusCode, Is.EqualTo(OK)); + levelList = message.Content.ReadAsXML(); + Assert.That(levelList.Items, Is.Empty); } } \ No newline at end of file