public void FromApiNodeList_Null() { // ARRANGE NodeList expected = null; ApiNodeList param = null; // ACT NodeList actual = NodeMapper.FromApiNodeList(param); // ASSERT Assert.Equal(expected, actual, new NodeListComparer()); }
public NodeList GetNodes(long parentNodeId = 0, long?offset = null, long?limit = null, GetNodesFilter filter = null) { _client.Executor.CheckApiServerVersion(); #region Parameter Validation parentNodeId.MustNotNegative(nameof(parentNodeId)); offset.NullableMustNotNegative(nameof(offset)); limit.NullableMustPositive(nameof(limit)); #endregion IRestRequest restRequest = _client.Builder.GetNodes(parentNodeId, offset, limit, filter: filter); ApiNodeList result = _client.Executor.DoSyncApiCall <ApiNodeList>(restRequest, RequestType.GetNodes); return(NodeMapper.FromApiNodeList(result)); }
public NodeList SearchNodes(string searchString, long parentNodeId = 0, long offset = 0, long limit = 500, SearchNodesFilter filter = null, SearchNodesSort sort = null) { _client.Executor.CheckApiServerVersion(); #region Parameter Validation searchString.MustNotNullOrEmptyOrWhitespace(nameof(searchString)); parentNodeId.MustNotNegative(nameof(parentNodeId)); offset.MustNotNegative(nameof(offset)); limit.MustPositive(nameof(limit)); #endregion IRestRequest restRequest = _client.Builder.GetSearchNodes(parentNodeId, searchString, offset, limit, filter: filter, sort: sort); ApiNodeList result = _client.Executor.DoSyncApiCall <ApiNodeList>(restRequest, RequestType.GetSearchNodes); return(NodeMapper.FromApiNodeList(result)); }
internal static NodeList FromApiNodeList(ApiNodeList apiNodeList) { if (apiNodeList == null) { return(null); } NodeList nodeList = new NodeList { Offset = apiNodeList.Range.Offset, Limit = apiNodeList.Range.Limit, Total = apiNodeList.Range.Total, Items = new List <Node>() }; foreach (ApiNode currentNode in apiNodeList.Items) { nodeList.Items.Add(FromApiNode(currentNode)); } return(nodeList); }
public void FromApiNodeList() { // ARRANGE Classification expectedClassification = Classification.Confidential; NodeType expectedType = NodeType.File; string expectedTypeValue = "file"; NodeList expected = FactoryNode.NodeList; ApiNodeList param = new ApiNodeList { Range = new ApiRange { Offset = expected.Offset, Limit = expected.Limit, Total = expected.Total }, Items = new List <ApiNode>(expected.Items.Count) }; foreach (Node current in expected.Items) { current.Type = expectedType; current.Classification = expectedClassification; ApiNode currentApi = new ApiNode { Id = current.Id, Type = expectedTypeValue, ParentId = current.ParentId, ParentPath = current.ParentPath, Name = current.Name, MediaType = current.MediaType, MediaToken = current.MediaToken, Size = current.Size, Quota = current.Quota, Classification = (int)current.Classification, Notes = current.Notes, Hash = current.Hash, ExpireAt = current.ExpireAt, CreatedAt = current.CreatedAt, CreatedBy = new ApiUserInfo { Id = current.CreatedBy.Id.Value, AvatarUuid = current.CreatedBy.AvatarUUID, DisplayName = current.CreatedBy.DisplayName }, UpdatedAt = current.UpdatedAt, UpdatedBy = new ApiUserInfo { Id = current.UpdatedBy.Id.Value, AvatarUuid = current.UpdatedBy.AvatarUUID, DisplayName = current.UpdatedBy.DisplayName }, InheritPermissions = current.HasInheritPermissions, Permissions = new ApiNodePermissions { Manage = current.Permissions.Manage, Read = current.Permissions.Read, Create = current.Permissions.Create, Change = current.Permissions.Change, Delete = current.Permissions.Delete, ManageDownloadShare = current.Permissions.ManageDownloadShare, ManageUploadShare = current.Permissions.ManageUploadShare, ReadRecycleBin = current.Permissions.CanReadRecycleBin, RestoreRecycleBin = current.Permissions.CanRestoreRecycleBin, DeleteRecycleBin = current.Permissions.CanDeleteRecycleBin }, IsFavorite = current.IsFavorite, IsEncrypted = current.IsEncrypted, CountChildren = current.CountChildren, CountFiles = current.CountFiles, CountRooms = current.CountRooms, CountFolders = current.CountFolders, CountDeletedVersions = current.CountDeletedVersions, RecycleBinRetentionPeriod = current.RecycleBinRetentionPeriod, CountDownloadShares = current.CountDownloadShares, CountUploadShares = current.CountUploadShares, BranchVersion = current.BranchVersion, FileType = current.Extension }; param.Items.Add(currentApi); Mock.Arrange(() => NodeMapper.FromApiNode(currentApi)).Returns(current); } // ACT NodeList actual = NodeMapper.FromApiNodeList(param); // ASSERT Assert.Equal(expected, actual, new NodeListComparer()); }