public async Task ItCanCreateAConnectionBetweenAnAssetAndAFile() { var fileId = await CreateFile(); var assets = await GetAssets(); var asset = assets.FirstOrDefault() ?? await CreateAsset(); var request = new FortnoxApiRequest(connectionSettings.AccessToken, connectionSettings.ClientSecret); try { var response = await AssetFileConnectionService.CreateAssetFileConnection( request, asset.Id.ToString(), fileId ); await DeleteConnection(fileId); Assert.IsNotNull(response); Assert.AreEqual(fileId, response.FileId); Assert.AreEqual(asset.Id.ToString(), response.AssetId); } finally { await DeleteFile(fileId); if (!assets.Any()) { await DeleteAsset(asset.Id); } } }
public async Task ItCanGetAllAssetFileConnections() { var request = new AssetFileConnectionListRequest(connectionSettings.AccessToken, connectionSettings.ClientSecret); var response = await AssetFileConnectionService.GetAssetFileConnectionsAsync(request); Assert.IsNotNull(response); Assert.IsNotNull(response.Data); }
private async Task <AssetFileConnection> CreateConnection() { var fileId = await CreateFile(); var assets = await GetAssets(); var asset = assets.FirstOrDefault() ?? await CreateAsset(); var request = new FortnoxApiRequest(connectionSettings.AccessToken, connectionSettings.ClientSecret); return(await AssetFileConnectionService.CreateAssetFileConnection( request, asset.Id.ToString(), fileId )); }
public async Task ItCanGetAssetConnectionsForAFile() { var connections = await GetConnections(); if (connections == null || !connections.Any()) { Assert.Inconclusive("No asset file connections exist in the system"); } var request = new AssetFileConnectionListRequest(connectionSettings.AccessToken, connectionSettings.ClientSecret); var response = await AssetFileConnectionService.GetAssetFileConnectionAsync( request, connections.First().FileId ); Assert.IsNotNull(response); Assert.AreEqual(connections.First().FileId, response.FileId); }
public async Task ItCanDeleteAnConnectionBetweenAnAssetAndAFile() { var initialConnections = await GetConnections(); var connection = await CreateConnection(); try { var deleteRequest = new FortnoxApiRequest(connectionSettings.AccessToken, connectionSettings.ClientSecret); await AssetFileConnectionService.DeleteAssetFileConnection(deleteRequest, connection.FileId); var getConnectionRequest = new AssetFileConnectionListRequest( connectionSettings.AccessToken, connectionSettings.ClientSecret ); if (initialConnections.Count < 1) { await Assert.ThrowsExceptionAsync <Exception>(async() => { await AssetFileConnectionService.GetAssetFileConnectionAsync( getConnectionRequest, connection.FileId ); }); } else { var currentConnections = await GetConnections(); Assert.AreEqual(initialConnections.Count, currentConnections.Count); } } finally { await DeleteFile(connection.FileId); } }
private async Task DeleteConnection(string fileId) { var request = new FortnoxApiRequest(connectionSettings.AccessToken, connectionSettings.ClientSecret); await AssetFileConnectionService.DeleteAssetFileConnection(request, fileId); }
private async Task <List <AssetFileConnections> > GetConnections() { var request = new AssetFileConnectionListRequest(connectionSettings.AccessToken, connectionSettings.ClientSecret); return((await AssetFileConnectionService.GetAssetFileConnectionsAsync(request)).Data.ToList()); }