public async Task ItCanCreateAConnectionForAFile() { var fileId = await CreateFile(); var articles = await GetArticles(); var article = articles.FirstOrDefault() ?? await CreateArticle(); var request = new FortnoxApiRequest(connectionSettings.AccessToken, connectionSettings.ClientSecret); try { var response = await ArticleFileConnectionService.CreateArticleFileConnection( request, article.ArticleNumber, fileId ); await DeleteConnection(fileId); Assert.IsNotNull(response); Assert.AreEqual(fileId, response.FileId); Assert.AreEqual(article.ArticleNumber, response.ArticleNumber); } finally { await DeleteFile(fileId); if (!articles.Any()) { await DeleteArticle(article.ArticleNumber); } } }
public async Task ItCanGetConnectionsForManyFiles() { var request = new ArticleFileConnectionListRequest(connectionSettings.AccessToken, connectionSettings.ClientSecret); var response = await ArticleFileConnectionService.GetArticleFileConnectionsAsync(request); Assert.IsNotNull(response); Assert.IsNotNull(response.Data); }
private async Task <ArticleFileConnection> CreateConnection() { var fileId = await CreateFile(); var articles = await GetArticles(); var article = articles.FirstOrDefault() ?? await CreateArticle(); var request = new FortnoxApiRequest(connectionSettings.AccessToken, connectionSettings.ClientSecret); return(await ArticleFileConnectionService.CreateArticleFileConnection( request, article.ArticleNumber, fileId )); }
public async Task ItCanGetConnectionsForAFile() { var fileConnections = await GetConnections(); if (fileConnections == null || !fileConnections.Any()) { Assert.Inconclusive("No connection exist between any article to any file in the system"); return; } var request = new ArticleFileConnectionListRequest(connectionSettings.AccessToken, connectionSettings.ClientSecret); var response = await ArticleFileConnectionService.GetArticleFileConnectionAsync( request, fileConnections.First().FileId ); Assert.IsNotNull(response); Assert.AreEqual(fileConnections.First().FileId, response.FileId); }
public async Task ItCanDeleteAConnectionForAFile() { var initialConnections = await GetConnections(); var articleFileConnection = await CreateConnection(); try { var deleteRequest = new FortnoxApiRequest(connectionSettings.AccessToken, connectionSettings.ClientSecret); await ArticleFileConnectionService.DeleteArticleFileConnection(deleteRequest, articleFileConnection.FileId); var getConnectionRequest = new ArticleFileConnectionListRequest( connectionSettings.AccessToken, connectionSettings.ClientSecret ); if (initialConnections.Count < 1) { await Assert.ThrowsExceptionAsync <Exception>(async() => await ArticleFileConnectionService.GetArticleFileConnectionAsync( getConnectionRequest, articleFileConnection.FileId ) ); } else { var currentConnections = await GetConnections(); Assert.AreEqual(initialConnections.Count, currentConnections.Count); } } finally { await DeleteFile(articleFileConnection.FileId); } }
private async Task DeleteConnection(string fileId) { var request = new FortnoxApiRequest(connectionSettings.AccessToken, connectionSettings.ClientSecret); await ArticleFileConnectionService.DeleteArticleFileConnection(request, fileId); }
private async Task <List <ArticleFileConnections> > GetConnections() { var request = new ArticleFileConnectionListRequest(connectionSettings.AccessToken, connectionSettings.ClientSecret); return((await ArticleFileConnectionService.GetArticleFileConnectionsAsync(request)).Data.ToList()); }