2
0

GetPathValueTests.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using MediaBrowser.Api;
  2. using MediaBrowser.Controller.Configuration;
  3. using MediaBrowser.Controller.Net;
  4. using MediaBrowser.Model.Configuration;
  5. using MediaBrowser.Model.Services;
  6. using Microsoft.Extensions.Logging.Abstractions;
  7. using Moq;
  8. using Xunit;
  9. namespace Jellyfin.Api.Tests
  10. {
  11. public class GetPathValueTests
  12. {
  13. [Theory]
  14. [InlineData("https://localhost:8096/ScheduledTasks/1234/Triggers", "", 1, "1234")]
  15. [InlineData("https://localhost:8096/emby/ScheduledTasks/1234/Triggers", "", 1, "1234")]
  16. [InlineData("https://localhost:8096/mediabrowser/ScheduledTasks/1234/Triggers", "", 1, "1234")]
  17. [InlineData("https://localhost:8096/jellyfin/2/ScheduledTasks/1234/Triggers", "jellyfin/2", 1, "1234")]
  18. [InlineData("https://localhost:8096/jellyfin/2/emby/ScheduledTasks/1234/Triggers", "jellyfin/2", 1, "1234")]
  19. [InlineData("https://localhost:8096/jellyfin/2/mediabrowser/ScheduledTasks/1234/Triggers", "jellyfin/2", 1, "1234")]
  20. [InlineData("https://localhost:8096/JELLYFIN/2/ScheduledTasks/1234/Triggers", "jellyfin/2", 1, "1234")]
  21. [InlineData("https://localhost:8096/JELLYFIN/2/Emby/ScheduledTasks/1234/Triggers", "jellyfin/2", 1, "1234")]
  22. [InlineData("https://localhost:8096/JELLYFIN/2/MediaBrowser/ScheduledTasks/1234/Triggers", "jellyfin/2", 1, "1234")]
  23. public void GetPathValueTest(string path, string baseUrl, int index, string value)
  24. {
  25. var reqMock = Mock.Of<IRequest>(x => x.PathInfo == path);
  26. var conf = new ServerConfiguration()
  27. {
  28. BaseUrl = baseUrl
  29. };
  30. var confManagerMock = Mock.Of<IServerConfigurationManager>(x => x.Configuration == conf);
  31. var service = new BrandingService(
  32. new NullLogger<BrandingService>(),
  33. confManagerMock,
  34. Mock.Of<IHttpResultFactory>())
  35. {
  36. Request = reqMock
  37. };
  38. Assert.Equal(value, service.GetPathValue(index).ToString());
  39. }
  40. }
  41. }