Fixed unit tests

This commit is contained in:
tidusjar 2019-11-05 22:38:59 +00:00
commit 3a82562341
4 changed files with 24 additions and 7 deletions

View file

@ -18,7 +18,7 @@ namespace Ombi.Core.Tests.Rule.Request
{ {
private List<OmbiUser> _users = new List<OmbiUser> private List<OmbiUser> _users = new List<OmbiUser>
{ {
new OmbiUser { Id = Guid.NewGuid().ToString("N"), UserName="abc" } new OmbiUser { Id = Guid.NewGuid().ToString("N"), UserName="abc",UserType = UserType.LocalUser}
}; };
[SetUp] [SetUp]

View file

@ -18,7 +18,7 @@ namespace Ombi.Core.Tests.Rule.Request
{ {
private List<OmbiUser> _users = new List<OmbiUser> private List<OmbiUser> _users = new List<OmbiUser>
{ {
new OmbiUser { Id = Guid.NewGuid().ToString("N"), UserName="abc" } new OmbiUser { Id = Guid.NewGuid().ToString("N"), UserName="abc", UserType = UserType.LocalUser}
}; };
[SetUp] [SetUp]

View file

@ -70,7 +70,7 @@ namespace Ombi.Core.Tests.Rule.Search
var result = await Rule.Execute(search); var result = await Rule.Execute(search);
Assert.True(result.Success); Assert.True(result.Success);
Assert.That(search.EmbyUrl, Is.EqualTo("http://test.com/#!/itemdetails.html?id=1")); Assert.That(search.EmbyUrl, Is.EqualTo("http://test.com/#!/item/item.html?id=1"));
} }
[Test] [Test]
@ -99,7 +99,7 @@ namespace Ombi.Core.Tests.Rule.Search
var result = await Rule.Execute(search); var result = await Rule.Execute(search);
Assert.True(result.Success); Assert.True(result.Success);
Assert.That(search.EmbyUrl, Is.EqualTo("https://app.emby.media/#!/itemdetails.html?id=1")); Assert.That(search.EmbyUrl, Is.EqualTo("https://app.emby.media/#!/item/item.html?id=1"));
} }
[Test] [Test]

View file

@ -14,14 +14,31 @@ namespace Ombi.Helpers.Tests
return EmbyHelper.GetEmbyMediaUrl(mediaId, url); return EmbyHelper.GetEmbyMediaUrl(mediaId, url);
} }
[TestCaseSource(nameof(JellyfinUrlData))]
public string TestJellyfinUrl(string mediaId, string url)
{
return EmbyHelper.GetEmbyMediaUrl(mediaId, url, true);
}
public static IEnumerable<TestCaseData> UrlData public static IEnumerable<TestCaseData> UrlData
{ {
get get
{ {
var mediaId = 1; var mediaId = 1;
yield return new TestCaseData(mediaId.ToString(), "http://google.com").Returns($"http://google.com/#!/itemdetails.html?id={mediaId}").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain_WithoutTrailingSlash"); yield return new TestCaseData(mediaId.ToString(), "http://google.com").Returns($"http://google.com/#!/item/item.html?id={mediaId}").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain_WithoutTrailingSlash");
yield return new TestCaseData(mediaId.ToString(), "http://google.com/").Returns($"http://google.com/#!/itemdetails.html?id={mediaId}").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain"); yield return new TestCaseData(mediaId.ToString(), "http://google.com/").Returns($"http://google.com/#!/item/item.html?id={mediaId}").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain");
yield return new TestCaseData(mediaId.ToString(), "https://google.com/").Returns($"https://google.com/#!/itemdetails.html?id={mediaId}").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain_Https"); yield return new TestCaseData(mediaId.ToString(), "https://google.com/").Returns($"https://google.com/#!/item/item.html?id={mediaId}").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain_Https");
}
}
public static IEnumerable<TestCaseData> JellyfinUrlData
{
get
{
var mediaId = 1;
yield return new TestCaseData(mediaId.ToString(), "http://google.com").Returns($"http://google.com/#!/itemdetails.html?id={mediaId}").SetName("EmbyHelperJellyfin_GetMediaUrl_WithCustomDomain_WithoutTrailingSlash");
yield return new TestCaseData(mediaId.ToString(), "http://google.com/").Returns($"http://google.com/#!/itemdetails.html?id={mediaId}").SetName("EmbyHelperJellyfin_GetMediaUrl_WithCustomDomain");
yield return new TestCaseData(mediaId.ToString(), "https://google.com/").Returns($"https://google.com/#!/itemdetails.html?id={mediaId}").SetName("EmbyHelperJellyfin_GetMediaUrl_WithCustomDomain_Https");
} }
} }
} }