예제 #1
0
        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);
                }
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
        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
                       ));
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
            }
        }
예제 #6
0
 private async Task DeleteConnection(string fileId)
 {
     var request = new FortnoxApiRequest(connectionSettings.AccessToken, connectionSettings.ClientSecret);
     await AssetFileConnectionService.DeleteAssetFileConnection(request, fileId);
 }
예제 #7
0
        private async Task <List <AssetFileConnections> > GetConnections()
        {
            var request = new AssetFileConnectionListRequest(connectionSettings.AccessToken, connectionSettings.ClientSecret);

            return((await AssetFileConnectionService.GetAssetFileConnectionsAsync(request)).Data.ToList());
        }