aboutsummaryrefslogtreecommitdiff
path: root/tests/Jellyfin.Api.Tests/GetPathValueTests.cs
blob: b01d1af1f0b82e13abf4c34f2434839253489e89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using MediaBrowser.Api;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Services;
using Microsoft.Extensions.Logging.Abstractions;
using Moq;
using Xunit;

namespace Jellyfin.Api.Tests
{
    public class GetPathValueTests
    {
        [Theory]
        [InlineData("https://localhost:8096/ScheduledTasks/1234/Triggers", "", 1, "1234")]
        [InlineData("https://localhost:8096/emby/ScheduledTasks/1234/Triggers", "", 1, "1234")]
        [InlineData("https://localhost:8096/mediabrowser/ScheduledTasks/1234/Triggers", "", 1, "1234")]
        [InlineData("https://localhost:8096/jellyfin/2/ScheduledTasks/1234/Triggers", "jellyfin/2", 1, "1234")]
        [InlineData("https://localhost:8096/jellyfin/2/emby/ScheduledTasks/1234/Triggers", "jellyfin/2", 1, "1234")]
        [InlineData("https://localhost:8096/jellyfin/2/mediabrowser/ScheduledTasks/1234/Triggers", "jellyfin/2", 1, "1234")]
        [InlineData("https://localhost:8096/JELLYFIN/2/ScheduledTasks/1234/Triggers", "jellyfin/2", 1, "1234")]
        [InlineData("https://localhost:8096/JELLYFIN/2/Emby/ScheduledTasks/1234/Triggers", "jellyfin/2", 1, "1234")]
        [InlineData("https://localhost:8096/JELLYFIN/2/MediaBrowser/ScheduledTasks/1234/Triggers", "jellyfin/2", 1, "1234")]
        public void GetPathValueTest(string path, string baseUrl, int index, string value)
        {
            var reqMock = Mock.Of<IRequest>(x => x.PathInfo == path);
            var conf = new ServerConfiguration()
            {
                BaseUrl = baseUrl
            };

            var confManagerMock = Mock.Of<IServerConfigurationManager>(x => x.Configuration == conf);

            var service = new BrandingService(
                new NullLogger<BrandingService>(),
                confManagerMock,
                Mock.Of<IHttpResultFactory>())
            {
                Request = reqMock
            };

            Assert.Equal(value, service.GetPathValue(index).ToString());
        }
    }
}