Пример #1
0
        public void GetDownloadShares()
        {
            // ARRANGE
            DownloadShareList      expected = FactoryShare.DownloadShareList;
            IInternalDracoonClient c        = FactoryClients.InternalDracoonClientMock(true);
            DracoonSharesImpl      s        = new DracoonSharesImpl(c);

            Mock.Arrange(() => Arg.IsAny <long?>().NullableMustNotNegative(Arg.AnyString)).DoNothing().Occurs(1);
            Mock.Arrange(() => Arg.IsAny <long?>().NullableMustPositive(Arg.AnyString)).DoNothing().Occurs(1);
            Mock.Arrange(() => c.Builder.GetDownloadShares(Arg.IsAny <long?>(), Arg.IsAny <long?>(), Arg.IsAny <GetDownloadSharesFilter>(), Arg.IsAny <SharesSort>()))
            .Returns(FactoryRestSharp.GetDownloadSharesMock()).Occurs(1);
            Mock.Arrange(() => c.Executor.DoSyncApiCall <ApiDownloadShareList>(Arg.IsAny <IRestRequest>(), RequestType.GetDownloadShares, 0))
            .Returns(FactoryShare.ApiDownloadShareList).Occurs(1);
            Mock.Arrange(() => ShareMapper.FromApiDownloadShareList(Arg.IsAny <ApiDownloadShareList>())).Returns(FactoryShare.DownloadShareList).Occurs(1);

            // ACT
            DownloadShareList actual = s.GetDownloadShares();

            // ASSERT
            Assert.NotNull(actual);
            Mock.Assert(() => Arg.IsAny <long?>().NullableMustNotNegative(Arg.AnyString));
            Mock.Assert(() => Arg.IsAny <long?>().NullableMustPositive(Arg.AnyString));
            Mock.Assert(() => ShareMapper.FromApiDownloadShareList(Arg.IsAny <ApiDownloadShareList>()));
            Mock.Assert(c.Builder);
            Mock.Assert(c.Executor);
        }
Пример #2
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());
        }
Пример #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));
        }