mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 18:08:53 -07:00
Fix QuickConnect tests, move class to proper namespace
This commit is contained in:
parent
45f478f63e
commit
1b197a2c2a
@ -1,17 +1,28 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using AutoFixture;
|
using AutoFixture;
|
||||||
using AutoFixture.AutoMoq;
|
using AutoFixture.AutoMoq;
|
||||||
using Emby.Server.Implementations.QuickConnect;
|
using Emby.Server.Implementations.QuickConnect;
|
||||||
using MediaBrowser.Controller.Authentication;
|
using MediaBrowser.Controller.Authentication;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
using MediaBrowser.Controller.Net;
|
||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Jellyfin.Server.Implementations.Tests.LiveTv
|
namespace Jellyfin.Server.Implementations.Tests.QuickConnect
|
||||||
{
|
{
|
||||||
public class QuickConnectManagerTests
|
public class QuickConnectManagerTests
|
||||||
{
|
{
|
||||||
|
private static readonly AuthorizationInfo _quickConnectAuthInfo = new AuthorizationInfo
|
||||||
|
{
|
||||||
|
Device = "Device",
|
||||||
|
DeviceId = "DeviceId",
|
||||||
|
Client = "Client",
|
||||||
|
Version = "1.0.0"
|
||||||
|
};
|
||||||
|
|
||||||
private readonly Fixture _fixture;
|
private readonly Fixture _fixture;
|
||||||
private readonly ServerConfiguration _config;
|
private readonly ServerConfiguration _config;
|
||||||
private readonly QuickConnectManager _quickConnectManager;
|
private readonly QuickConnectManager _quickConnectManager;
|
||||||
@ -27,6 +38,12 @@ namespace Jellyfin.Server.Implementations.Tests.LiveTv
|
|||||||
{
|
{
|
||||||
ConfigureMembers = true
|
ConfigureMembers = true
|
||||||
}).Inject(configManager.Object);
|
}).Inject(configManager.Object);
|
||||||
|
|
||||||
|
// User object contains circular references.
|
||||||
|
_fixture.Behaviors.OfType<ThrowingRecursionBehavior>().ToList()
|
||||||
|
.ForEach(b => _fixture.Behaviors.Remove(b));
|
||||||
|
_fixture.Behaviors.Add(new OmitOnRecursionBehavior());
|
||||||
|
|
||||||
_quickConnectManager = _fixture.Create<QuickConnectManager>();
|
_quickConnectManager = _fixture.Create<QuickConnectManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,7 +53,7 @@ namespace Jellyfin.Server.Implementations.Tests.LiveTv
|
|||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TryConnect_QuickConnectUnavailable_ThrowsAuthenticationException()
|
public void TryConnect_QuickConnectUnavailable_ThrowsAuthenticationException()
|
||||||
=> Assert.Throws<AuthenticationException>(_quickConnectManager.TryConnect);
|
=> Assert.Throws<AuthenticationException>(() => _quickConnectManager.TryConnect(_quickConnectAuthInfo));
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void CheckRequestStatus_QuickConnectUnavailable_ThrowsAuthenticationException()
|
public void CheckRequestStatus_QuickConnectUnavailable_ThrowsAuthenticationException()
|
||||||
@ -44,7 +61,7 @@ namespace Jellyfin.Server.Implementations.Tests.LiveTv
|
|||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void AuthorizeRequest_QuickConnectUnavailable_ThrowsAuthenticationException()
|
public void AuthorizeRequest_QuickConnectUnavailable_ThrowsAuthenticationException()
|
||||||
=> Assert.Throws<AuthenticationException>(() => _quickConnectManager.AuthorizeRequest(Guid.Empty, string.Empty));
|
=> Assert.ThrowsAsync<AuthenticationException>(() => _quickConnectManager.AuthorizeRequest(Guid.Empty, string.Empty));
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void IsEnabled_QuickConnectAvailable_True()
|
public void IsEnabled_QuickConnectAvailable_True()
|
||||||
@ -57,17 +74,17 @@ namespace Jellyfin.Server.Implementations.Tests.LiveTv
|
|||||||
public void CheckRequestStatus_QuickConnectAvailable_Success()
|
public void CheckRequestStatus_QuickConnectAvailable_Success()
|
||||||
{
|
{
|
||||||
_config.QuickConnectAvailable = true;
|
_config.QuickConnectAvailable = true;
|
||||||
var res1 = _quickConnectManager.TryConnect();
|
var res1 = _quickConnectManager.TryConnect(_quickConnectAuthInfo);
|
||||||
var res2 = _quickConnectManager.CheckRequestStatus(res1.Secret);
|
var res2 = _quickConnectManager.CheckRequestStatus(res1.Secret);
|
||||||
Assert.Equal(res1, res2);
|
Assert.Equal(res1, res2);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void AuthorizeRequest_QuickConnectAvailable_Success()
|
public async Task AuthorizeRequest_QuickConnectAvailable_Success()
|
||||||
{
|
{
|
||||||
_config.QuickConnectAvailable = true;
|
_config.QuickConnectAvailable = true;
|
||||||
var res = _quickConnectManager.TryConnect();
|
var res = _quickConnectManager.TryConnect(_quickConnectAuthInfo);
|
||||||
Assert.True(_quickConnectManager.AuthorizeRequest(Guid.Empty, res.Code));
|
Assert.True(await _quickConnectManager.AuthorizeRequest(Guid.Empty, res.Code));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user