public void GetUploadShares() { // ARRANGE UploadShareList expected = FactoryShare.UploadShareList; 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.GetUploadShares(Arg.IsAny <long?>(), Arg.IsAny <long?>(), Arg.IsAny <GetUploadSharesFilter>(), Arg.IsAny <SharesSort>())).Returns(FactoryRestSharp.GetUploadSharesMock()).Occurs(1); Mock.Arrange(() => c.Executor.DoSyncApiCall <ApiUploadShareList>(Arg.IsAny <IRestRequest>(), RequestType.GetUploadShares, 0)) .Returns(FactoryShare.ApiUploadShareList).Occurs(1); Mock.Arrange(() => ShareMapper.FromApiUploadShareList(Arg.IsAny <ApiUploadShareList>())).Returns(FactoryShare.UploadShareList).Occurs(1); // ACT UploadShareList actual = s.GetUploadShares(); // ASSERT Assert.NotNull(actual); Mock.Assert(() => Arg.IsAny <long?>().NullableMustNotNegative(Arg.AnyString)); Mock.Assert(() => Arg.IsAny <long?>().NullableMustPositive(Arg.AnyString)); Mock.Assert(() => ShareMapper.FromApiUploadShareList(Arg.IsAny <ApiUploadShareList>())); Mock.Assert(c.Builder); Mock.Assert(c.Executor); }
public void FromApiUploadShareList() { // ARRANGE UploadShareList expected = FactoryShare.UploadShareList; ApiUploadShareList param = new ApiUploadShareList { Range = new ApiRange { Offset = expected.Offset, Limit = expected.Limit, Total = expected.Total }, Items = new List <ApiUploadShare>(expected.Items.Count) }; foreach (UploadShare current in expected.Items) { ApiUploadShare currentApi = new ApiUploadShare { ShareId = current.ShareId, NodeId = current.NodeId, NodePath = current.NodePath, Name = current.Name, Notes = current.Notes, ExpireAt = current.ExpireAt, AccessKey = current.AccessKey, NotifyCreator = current.NotifyCreator, 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, CurrentDoneUploadsCount = current.CurrentDoneUploadsCount, CurrentUploadedFilesCount = current.CurrentUploadedFilesCount, MaxAllowedTotalSizeOverAllUploadedFiles = current.MaxAllowedTotalSizeOverAllUploadedFiles, MaxAllowedUploads = current.MaxAllowedUploads, ShowUploadedFiles = current.ShowUploadedFiles, UploadedFilesExpirationPeriod = current.UploadedFilesExpirationPeriod }; param.Items.Add(currentApi); Mock.Arrange(() => ShareMapper.FromApiUploadShare(currentApi)).Returns(current); } // ACT UploadShareList actual = ShareMapper.FromApiUploadShareList(param); // ASSERT Assert.Equal(expected, actual, new UploadShareListComparer()); }
internal static UploadShareList FromApiUploadShareList(ApiUploadShareList apiUploadShareList) { UploadShareList shareList = new UploadShareList { Offset = apiUploadShareList.Range.Offset, Limit = apiUploadShareList.Range.Limit, Total = apiUploadShareList.Range.Total, Items = new List <UploadShare>() }; foreach (ApiUploadShare currentShare in apiUploadShareList.Items) { shareList.Items.Add(FromApiUploadShare(currentShare)); } return(shareList); }