BrandingControllerTests.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System.Net.Mime;
  2. using System.Text;
  3. using System.Text.Json;
  4. using System.Threading.Tasks;
  5. using MediaBrowser.Model.Branding;
  6. using Xunit;
  7. namespace Jellyfin.Server.Integration.Tests
  8. {
  9. public sealed class BrandingControllerTests : IClassFixture<JellyfinApplicationFactory>
  10. {
  11. private readonly JellyfinApplicationFactory _factory;
  12. public BrandingControllerTests(JellyfinApplicationFactory factory)
  13. {
  14. _factory = factory;
  15. }
  16. [Fact]
  17. public async Task GetConfiguration_ReturnsCorrectResponse()
  18. {
  19. // Arrange
  20. var client = _factory.CreateClient();
  21. // Act
  22. var response = await client.GetAsync("/Branding/Configuration");
  23. // Assert
  24. Assert.True(response.IsSuccessStatusCode);
  25. Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);
  26. Assert.Equal(Encoding.UTF8.BodyName, response.Content.Headers.ContentType?.CharSet);
  27. var responseBody = await response.Content.ReadAsStreamAsync();
  28. _ = await JsonSerializer.DeserializeAsync<BrandingOptions>(responseBody);
  29. }
  30. [Theory]
  31. [InlineData("/Branding/Css")]
  32. [InlineData("/Branding/Css.css")]
  33. public async Task GetCss_ReturnsCorrectResponse(string url)
  34. {
  35. // Arrange
  36. var client = _factory.CreateClient();
  37. // Act
  38. var response = await client.GetAsync(url);
  39. // Assert
  40. Assert.True(response.IsSuccessStatusCode);
  41. Assert.Equal("text/css", response.Content.Headers.ContentType?.MediaType);
  42. Assert.Equal(Encoding.UTF8.BodyName, response.Content.Headers.ContentType?.CharSet);
  43. }
  44. }
  45. }