piwigodotnet/PiwigoDotnet/Piwigo.Client.Tests/SessionApiTests.cs

55 lines
1.3 KiB
C#
Raw Normal View History

using Microsoft.Extensions.Logging.Abstractions;
using Piwigo.Client.Contract;
namespace Piwigo.Client.Tests;
[TestFixture]
public class SessionApiTests : ApiTestsBase
{
private SessionApi _sessionApi = null!;
protected override void OnSetUp()
{
base.OnSetUp();
_sessionApi = new SessionApi(Context, new NullLogger<SessionApi>());
}
[Test]
public async Task Login_should_set_cookies_and_session()
{
await LoginAsync();
}
[Test]
public async Task GetStatus_should_return_config()
{
await LoginAsync();
var serverResponse = new PiwigoResponse<PiwigoStatus>
{
Status = "OK",
Result = new PiwigoStatus
{
Username = "admin",
Version = "12.0.0"
}
};
SetJsonResult(serverResponse);
var status = await _sessionApi.GetStatusAsync();
status.Should().NotBeNull();
status.Username.Should().Be("admin");
status.Version.Should().NotBeEmpty();
}
[Test]
public async Task Logout_should_set_IsLoggedIn_to_false()
{
await LoginAsync();
HttpTest?.RespondWith("OK");
await _sessionApi.LogoutAsync();
Context.IsLoggedIn.Should().BeFalse();
}
}