78 lines
2.4 KiB
C#
78 lines
2.4 KiB
C#
using Knoks.Api.Client;
|
|
using Knoks.Api.Nswag.Client;
|
|
using Knoks.Test.Integrations.Api.Tools;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Net.Http;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Xunit;
|
|
using System.Linq;
|
|
using Knoks.Api.Nswag.ClientApp;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Knoks.Test.Integrations.Nswag.Api
|
|
{
|
|
public class AccountControllerTests
|
|
: IAsyncLifetime
|
|
{
|
|
public ApiClient ApiClient { get; }
|
|
public HttpClient HttpClient { get; }
|
|
public AccountClient Client { get; }
|
|
public FavoritesClient FavoritesClient { get; }
|
|
public FollowsClient FollowsClient { get; }
|
|
private readonly ITestOutputHelper output;
|
|
public AccountControllerTests(ITestOutputHelper output)
|
|
{
|
|
this.output = output;
|
|
HttpClient = ApiTestServer.CreateClient();
|
|
ApiClient = new ApiClient(ApiTestServer.ApiIndetifier, HttpClient);
|
|
|
|
Client = new AccountClient(HttpClient);
|
|
Client.BaseUrl = "http://localhost:52281/";
|
|
FavoritesClient = new FavoritesClient(HttpClient);
|
|
FavoritesClient.BaseUrl = Client.BaseUrl;
|
|
FollowsClient = new FollowsClient(HttpClient);
|
|
FollowsClient.BaseUrl = Client.BaseUrl;
|
|
}
|
|
public async Task InitializeAsync()
|
|
{
|
|
await ApiClient.AuthorizeApiUser("CompanyWallet@knoks.com", "XXXXXX");
|
|
}
|
|
|
|
public Task DisposeAsync()
|
|
{
|
|
HttpClient.Dispose();
|
|
return Task.CompletedTask;
|
|
}
|
|
[Fact(DisplayName = "Favorites")]
|
|
|
|
void TestFavorites()
|
|
{
|
|
FavoritesClient.Add(1);
|
|
FavoritesClient.Add(2);
|
|
var cur = FavoritesClient.Get().Result.Items;
|
|
Assert.Contains(1, cur);
|
|
Assert.Contains(2, cur);
|
|
FavoritesClient.Remove(1);
|
|
FavoritesClient.Remove(2);
|
|
var cur2 = FavoritesClient.Get().Result.Items;
|
|
Assert.Empty(cur2);
|
|
}
|
|
[Fact(DisplayName = "Follow")]
|
|
|
|
void TestFollow()
|
|
{
|
|
FollowsClient.Add(1);
|
|
FollowsClient.Add(2);
|
|
var cur = FollowsClient.Get().Result.Items;
|
|
Assert.Contains(1, cur);
|
|
Assert.Contains(2, cur);
|
|
FollowsClient.Remove(1);
|
|
FollowsClient.Remove(2);
|
|
var cur2 = FollowsClient.Get().Result.Items;
|
|
Assert.Empty(cur2);
|
|
}
|
|
}
|
|
}
|