Пример #1
0
        public void FromApiDownloadShareList()
        {
            // ARRANGE
            Classification    expectedClassification = Classification.StrictlyConfidential;
            DownloadShareList expected = FactoryShare.DownloadShareList;

            ApiDownloadShareList param = new ApiDownloadShareList {
                Range = new ApiRange {
                    Offset = expected.Offset,
                    Limit  = expected.Limit,
                    Total  = expected.Total
                },
                Items = new List <ApiDownloadShare>(expected.Items.Count)
            };

            foreach (DownloadShare current in expected.Items)
            {
                current.Classification = expectedClassification;
                ApiDownloadShare currentApi = new ApiDownloadShare {
                    ShareId               = current.ShareId,
                    NodeId                = current.NodeId,
                    NodePath              = current.NodePath,
                    Name                  = current.Name,
                    Notes                 = current.Notes,
                    Classification        = (int)current.Classification,
                    ExpireAt              = current.ExpireAt,
                    AccessKey             = current.AccessKey,
                    ShowCreatorName       = current.ShowCreatorName,
                    ShowCreatorUserName   = current.ShowCreatorUserName,
                    NotifyCreator         = current.NotifyCreator,
                    MaxAllowedDownloads   = current.MaxAllowedDownloads,
                    CurrentDownloadsCount = current.CurrentDownloadsCount,
                    CreatedAt             = current.CreatedAt,
                    CreatedBy             = new ApiUserInfo {
                        AvatarUuid  = current.CreatedBy.AvatarUUID,
                        DisplayName = current.CreatedBy.DisplayName,
                        Id          = current.CreatedBy.Id.Value
                    },
                    IsProtected = current.IsProtected,
                    IsEncrypted = current.IsEncrypted
                };
                param.Items.Add(currentApi);
                Mock.Arrange(() => ShareMapper.FromApiDownloadShare(currentApi)).Returns(current);
            }

            // ACT
            DownloadShareList actual = ShareMapper.FromApiDownloadShareList(param);

            // ASSERT
            Assert.Equal(expected, actual, new DownloadShareListComparer());
        }
Пример #2
0
        internal static DownloadShareList FromApiDownloadShareList(ApiDownloadShareList apiDownloadShareList)
        {
            DownloadShareList shareList = new DownloadShareList {
                Offset = apiDownloadShareList.Range.Offset,
                Limit  = apiDownloadShareList.Range.Limit,
                Total  = apiDownloadShareList.Range.Total,
                Items  = new List <DownloadShare>()
            };

            foreach (ApiDownloadShare currentShare in apiDownloadShareList.Items)
            {
                shareList.Items.Add(FromApiDownloadShare(currentShare));
            }

            return(shareList);
        }
Пример #3
0
        public DownloadShareList GetDownloadShares(long?offset     = null, long?limit = null, GetDownloadSharesFilter filter = null,
                                                   SharesSort sort = null)
        {
            _client.Executor.CheckApiServerVersion();

            #region Parameter Validation

            offset.NullableMustNotNegative(nameof(offset));
            limit.NullableMustPositive(nameof(limit));

            #endregion

            IRestRequest         restRequest = _client.Builder.GetDownloadShares(offset, limit, filter, sort);
            ApiDownloadShareList result      =
                _client.Executor.DoSyncApiCall <ApiDownloadShareList>(restRequest, DracoonRequestExecutor.RequestType.GetDownloadShares);
            return(ShareMapper.FromApiDownloadShareList(result));
        }