internal static UploadShare FromApiUploadShare(ApiUploadShare apiUploadShare) { UploadShare uploadShare = new UploadShare { ShareId = apiUploadShare.ShareId, NodeId = apiUploadShare.NodeId, Name = apiUploadShare.Name, IsProtected = apiUploadShare.IsProtected, AccessKey = apiUploadShare.AccessKey, NotifyCreator = apiUploadShare.NotifyCreator, CreatedAt = apiUploadShare.CreatedAt, CreatedBy = UserMapper.FromApiUserInfo(apiUploadShare.CreatedBy), ExpireAt = apiUploadShare.ExpireAt, NodePath = apiUploadShare.NodePath, IsEncrypted = apiUploadShare.IsEncrypted, Notes = apiUploadShare.Notes, UploadedFilesExpirationPeriod = apiUploadShare.UploadedFilesExpirationPeriod, CurrentDoneUploadsCount = apiUploadShare.CurrentDoneUploadsCount, CurrentUploadedFilesCount = apiUploadShare.CurrentUploadedFilesCount, ShowUploadedFiles = apiUploadShare.ShowUploadedFiles, MaxAllowedUploads = apiUploadShare.MaxAllowedUploads, MaxAllowedTotalSizeOverAllUploadedFiles = apiUploadShare.MaxAllowedTotalSizeOverAllUploadedFiles }; return(uploadShare); }
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()); }
public UploadShare CreateUploadShare(CreateUploadShareRequest request) { _client.Executor.CheckApiServerVersion(); #region Parameter Validation request.MustNotNull(nameof(request)); request.NodeId.MustPositive(nameof(request.NodeId)); request.Name.MustNotNullOrEmptyOrWhitespace(nameof(request.Name)); request.MaxAllowedUploads.NullableMustPositive(nameof(request.MaxAllowedUploads)); request.MaxAllowedTotalSizeOverAllUploadedFiles.NullableMustPositive(nameof(request.MaxAllowedTotalSizeOverAllUploadedFiles)); request.UploadedFilesExpirationPeriod.NullableMustPositive(nameof(request.UploadedFilesExpirationPeriod)); if (request.EmailRecipients != null) { request.EmailRecipients.EnumerableMustNotNullOrEmpty(nameof(request.EmailRecipients)); request.EmailRecipients.ForEach(current => current.MustNotNullOrEmptyOrWhitespace(nameof(request.EmailRecipients) + " element")); request.EmailBody.MustNotNullOrEmptyOrWhitespace(nameof(request.EmailBody)); request.EmailSubject.MustNotNullOrEmptyOrWhitespace(nameof(request.EmailSubject)); } if (request.SmsRecipients != null) { request.SmsRecipients.EnumerableMustNotNullOrEmpty(nameof(request.SmsRecipients)); request.SmsRecipients.ForEach(current => current.MustNotNullOrEmptyOrWhitespace(nameof(request.SmsRecipients) + " element")); if (string.IsNullOrEmpty(request.AccessPassword)) { throw new ArgumentException("If a SMS should be sent, a access password must be set."); } } #endregion ApiCreateUploadShareRequest apiRequest = ShareMapper.ToApiCreateUploadShareRequest(request); IRestRequest restRequest = _client.Builder.PostCreateUploadShare(apiRequest); ApiUploadShare resultShare = _client.Executor.DoSyncApiCall <ApiUploadShare>(restRequest, DracoonRequestExecutor.RequestType.PostCreateUploadShare); return(ShareMapper.FromApiUploadShare(resultShare)); }
public void FromApiUploadShare() { // ARRANGE UploadShare expected = FactoryShare.UploadShare; ApiUploadShare param = new ApiUploadShare { ShareId = expected.ShareId, NodeId = expected.NodeId, NodePath = expected.NodePath, Name = expected.Name, IsProtected = expected.IsProtected, AccessKey = expected.AccessKey, NotifyCreator = expected.NotifyCreator, CreatedAt = expected.CreatedAt, CreatedBy = new ApiUserInfo { AvatarUuid = expected.CreatedBy.AvatarUUID, DisplayName = expected.CreatedBy.DisplayName, Id = expected.CreatedBy.Id.Value }, ExpireAt = expected.ExpireAt, IsEncrypted = expected.IsEncrypted, Notes = expected.Notes, UploadedFilesExpirationPeriod = expected.UploadedFilesExpirationPeriod, CurrentDoneUploadsCount = expected.CurrentDoneUploadsCount, CurrentUploadedFilesCount = expected.CurrentUploadedFilesCount, ShowUploadedFiles = expected.ShowUploadedFiles, MaxAllowedUploads = expected.MaxAllowedUploads, MaxAllowedTotalSizeOverAllUploadedFiles = expected.MaxAllowedTotalSizeOverAllUploadedFiles }; Mock.Arrange(() => UserMapper.FromApiUserInfo(param.CreatedBy)).Returns(expected.CreatedBy); // ACT UploadShare actual = ShareMapper.FromApiUploadShare(param); // ASSERT Assert.Equal(expected, actual, new UploadShareComparer()); }