BrandingServiceTests.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Text.Json;
  3. using System.Threading.Tasks;
  4. using Jellyfin.Server;
  5. using MediaBrowser.Model.Branding;
  6. using Microsoft.AspNetCore.Mvc.Testing;
  7. using Xunit;
  8. namespace MediaBrowser.Api.Tests
  9. {
  10. public sealed class BrandingServiceTests : IClassFixture<JellyfinApplicationFactory>
  11. {
  12. private readonly JellyfinApplicationFactory _factory;
  13. public BrandingServiceTests(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. response.EnsureSuccessStatusCode();
  26. Assert.Equal("application/json; charset=utf-8", response.Content.Headers.ContentType.ToString());
  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. response.EnsureSuccessStatusCode();
  41. Assert.Equal("text/css", response.Content.Headers.ContentType.ToString());
  42. }
  43. }
  44. }