45 lines
1.0 KiB
C#
45 lines
1.0 KiB
C#
using Flurl.Http.Testing;
|
|
|
|
namespace Piwigo.Client.Tests;
|
|
|
|
public class PiwigoClientTests
|
|
{
|
|
private PiwigoClient _piwigoClient = null!;
|
|
private HttpTest _httpTest = null!;
|
|
|
|
[SetUp]
|
|
public void SetUp()
|
|
{
|
|
_piwigoClient = new PiwigoClient();
|
|
_httpTest = new HttpTest();
|
|
}
|
|
|
|
[TearDown]
|
|
public void TearDown()
|
|
{
|
|
_httpTest.Dispose();
|
|
}
|
|
|
|
[Test]
|
|
public async Task Login_should_set_cookies_and_session()
|
|
{
|
|
await LoginAsync();
|
|
}
|
|
|
|
[Test]
|
|
public async Task Logout_should_set_IsLoggedIn_to_false()
|
|
{
|
|
await LoginAsync();
|
|
|
|
_httpTest.RespondWith("OK");
|
|
await _piwigoClient.Logout();
|
|
_piwigoClient.IsLoggedIn.Should().BeFalse();
|
|
}
|
|
|
|
private async Task LoginAsync()
|
|
{
|
|
_httpTest.RespondWith("OK", 200, cookies: new { pwg_id = "pwg_id" });
|
|
await _piwigoClient.LoginAsync(new Uri("http://localhost:8080/foo/bar/ws.php?format=json"), "admin", "admin");
|
|
_piwigoClient.IsLoggedIn.Should().BeTrue();
|
|
}
|
|
} |