jellyfin/tests/Jellyfin.Api.Tests/Controllers/BrandingControllerTests.cs

51 lines
1.6 KiB
C#
Raw Normal View History

using System.Text.Json;
using System.Threading.Tasks;
using MediaBrowser.Model.Branding;
using Xunit;
namespace Jellyfin.Api.Tests
{
2021-02-22 13:15:29 +01:00
public sealed class BrandingControllerTests : IClassFixture<JellyfinApplicationFactory>
{
private readonly JellyfinApplicationFactory _factory;
2021-02-22 13:15:29 +01:00
public BrandingControllerTests(JellyfinApplicationFactory factory)
{
_factory = factory;
}
[Fact]
public async Task GetConfiguration_ReturnsCorrectResponse()
{
// Arrange
var client = _factory.CreateClient();
// Act
var response = await client.GetAsync("/Branding/Configuration");
// Assert
2021-02-22 13:15:29 +01:00
Assert.True(response.IsSuccessStatusCode);
Assert.Equal("application/json", response.Content.Headers.ContentType?.MediaType);
Assert.Equal("utf-8", response.Content.Headers.ContentType?.CharSet);
var responseBody = await response.Content.ReadAsStreamAsync();
_ = await JsonSerializer.DeserializeAsync<BrandingOptions>(responseBody);
}
[Theory]
[InlineData("/Branding/Css")]
[InlineData("/Branding/Css.css")]
public async Task GetCss_ReturnsCorrectResponse(string url)
{
// Arrange
var client = _factory.CreateClient();
// Act
var response = await client.GetAsync(url);
// Assert
2021-02-22 13:15:29 +01:00
Assert.True(response.IsSuccessStatusCode);
Assert.Equal("text/css; charset=utf-8", response.Content.Headers.ContentType?.ToString());
}
}
}