BrandingControllerTests.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System.Net;
  2. using System.Net.Http.Json;
  3. using System.Net.Mime;
  4. using System.Text;
  5. using System.Text.Json;
  6. using System.Threading.Tasks;
  7. using MediaBrowser.Model.Branding;
  8. using Xunit;
  9. namespace Jellyfin.Server.Integration.Tests
  10. {
  11. public sealed class BrandingControllerTests : IClassFixture<JellyfinApplicationFactory>
  12. {
  13. private readonly JellyfinApplicationFactory _factory;
  14. public BrandingControllerTests(JellyfinApplicationFactory factory)
  15. {
  16. _factory = factory;
  17. }
  18. [Fact]
  19. public async Task GetConfiguration_ReturnsCorrectResponse()
  20. {
  21. // Arrange
  22. var client = _factory.CreateClient();
  23. // Act
  24. var response = await client.GetAsync("/Branding/Configuration");
  25. // Assert
  26. Assert.Equal(HttpStatusCode.OK, response.StatusCode);
  27. Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);
  28. Assert.Equal(Encoding.UTF8.BodyName, response.Content.Headers.ContentType?.CharSet);
  29. await response.Content.ReadFromJsonAsync<BrandingOptions>();
  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. }