BrandingControllerTests.cs 1.8 KB

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