From baadc48f43ec425659d0d7210f1a97416d7d34c5 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Mon, 22 Feb 2021 16:27:02 +0100 Subject: [PATCH] Address comments --- .../Controllers/BrandingControllerTests.cs | 9 ++++++--- .../Controllers/DashboardControllerTests.cs | 13 ++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/Jellyfin.Api.Tests/Controllers/BrandingControllerTests.cs b/tests/Jellyfin.Api.Tests/Controllers/BrandingControllerTests.cs index 3207a0f25..40933562d 100644 --- a/tests/Jellyfin.Api.Tests/Controllers/BrandingControllerTests.cs +++ b/tests/Jellyfin.Api.Tests/Controllers/BrandingControllerTests.cs @@ -1,3 +1,5 @@ +using System.Net.Mime; +using System.Text; using System.Text.Json; using System.Threading.Tasks; using MediaBrowser.Model.Branding; @@ -25,8 +27,8 @@ namespace Jellyfin.Api.Tests // Assert Assert.True(response.IsSuccessStatusCode); - Assert.Equal("application/json", response.Content.Headers.ContentType?.MediaType); - Assert.Equal("utf-8", response.Content.Headers.ContentType?.CharSet); + Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType); + Assert.Equal(Encoding.UTF8.BodyName, response.Content.Headers.ContentType?.CharSet); var responseBody = await response.Content.ReadAsStreamAsync(); _ = await JsonSerializer.DeserializeAsync(responseBody); } @@ -44,7 +46,8 @@ namespace Jellyfin.Api.Tests // Assert Assert.True(response.IsSuccessStatusCode); - Assert.Equal("text/css; charset=utf-8", response.Content.Headers.ContentType?.ToString()); + Assert.Equal("text/css", response.Content.Headers.ContentType?.MediaType); + Assert.Equal(Encoding.UTF8.BodyName, response.Content.Headers.ContentType?.CharSet); } } } diff --git a/tests/Jellyfin.Api.Tests/Controllers/DashboardControllerTests.cs b/tests/Jellyfin.Api.Tests/Controllers/DashboardControllerTests.cs index 84d362a39..300b2697f 100644 --- a/tests/Jellyfin.Api.Tests/Controllers/DashboardControllerTests.cs +++ b/tests/Jellyfin.Api.Tests/Controllers/DashboardControllerTests.cs @@ -1,5 +1,7 @@ using System.IO; using System.Net; +using System.Net.Mime; +using System.Text; using System.Text.Json; using System.Threading.Tasks; using Jellyfin.Api.Models; @@ -23,7 +25,7 @@ namespace Jellyfin.Api.Tests.Controllers { var client = _factory.CreateClient(); - var response = await client.GetAsync("web/ConfigurationPage/ThisPageTotally/Doesnt/Exists.html").ConfigureAwait(false); + var response = await client.GetAsync("web/ConfigurationPage?name=ThisPageDoesntExists").ConfigureAwait(false); Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); } @@ -36,7 +38,7 @@ namespace Jellyfin.Api.Tests.Controllers var response = await client.GetAsync("/web/ConfigurationPage?name=TestPlugin").ConfigureAwait(false); Assert.True(response.IsSuccessStatusCode); - Assert.Equal("text/html", response.Content.Headers.ContentType?.MediaType); + Assert.Equal(MediaTypeNames.Text.Html, response.Content.Headers.ContentType?.MediaType); StreamReader reader = new StreamReader(typeof(TestPlugin).Assembly.GetManifestResourceStream("Jellyfin.Api.Tests.TestPage.html")!); Assert.Equal(await response.Content.ReadAsStringAsync(), reader.ReadToEnd()); } @@ -59,6 +61,9 @@ namespace Jellyfin.Api.Tests.Controllers var response = await client.GetAsync("/web/ConfigurationPages").ConfigureAwait(false); Assert.True(response.IsSuccessStatusCode); + + var res = await response.Content.ReadAsStreamAsync(); + _ = await JsonSerializer.DeserializeAsync(res, _jsonOpions); // TODO: check content } @@ -70,8 +75,10 @@ namespace Jellyfin.Api.Tests.Controllers var response = await client.GetAsync("/web/ConfigurationPages?enableInMainMenu=true").ConfigureAwait(false); Assert.True(response.IsSuccessStatusCode); + Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType); + Assert.Equal(Encoding.UTF8.BodyName, response.Content.Headers.ContentType?.CharSet); + var res = await response.Content.ReadAsStreamAsync(); - System.Console.WriteLine(res); var data = await JsonSerializer.DeserializeAsync(res, _jsonOpions); Assert.Empty(data); }