예제 #1
0
        private static void GetFileVersions()
        {
            RecycleBinItemList binItems = dc.Nodes.GetRecycleBinItems(1);

            foreach (RecycleBinItem current in binItems.Items)
            {
                Console.WriteLine("NodeName: " + current.Name + "; Versions: " + current.VersionsCount + "; LastDeletedNodeId: " +
                                  current.LastDeletedNodeId + "; ParentPath: " + current.ParentPath);
            }

            PreviousVersionList versionList = dc.Nodes.GetPreviousVersions(1, NodeType.File, "test.txt");

            foreach (PreviousVersion current in versionList.Items)
            {
                Console.WriteLine("NodeName: " + current.Name + "; Id: " + current.Id + "; ParentPath: " + current.ParentPath + "; DeletedAt: " +
                                  current.DeletedAt.ToString());
            }

            // Restore the last version of the node "test.txt"
            RestorePreviousVersionsRequest request = new RestorePreviousVersionsRequest(new List <long>()
            {
                versionList.Items[0].Id.Value
            });

            dc.Nodes.RestorePreviousVersion(request);
        }
예제 #2
0
        public void FromApiDeletedNodeVersionsList_Null()
        {
            // ARRANGE
            PreviousVersionList expected = null;

            ApiDeletedNodeVersionsList param = null;

            // ACT
            PreviousVersionList actual = NodeMapper.FromApiDeletedNodeVersionsList(param);

            // ASSERT
            Assert.Equal(expected, actual, new PreviousVersionListComparer());
        }
예제 #3
0
        internal static PreviousVersionList FromApiDeletedNodeVersionsList(ApiDeletedNodeVersionsList apiNodeList)
        {
            if (apiNodeList == null)
            {
                return(null);
            }

            PreviousVersionList nodeList = new PreviousVersionList {
                Offset = apiNodeList.Range.Offset,
                Limit  = apiNodeList.Range.Limit,
                Total  = apiNodeList.Range.Total,
                Items  = new List <PreviousVersion>()
            };

            foreach (ApiDeletedNodeVersion currentNode in apiNodeList.Items)
            {
                nodeList.Items.Add(FromApiDeletedNodeVersion(currentNode));
            }

            return(nodeList);
        }
예제 #4
0
        public void FromApiDeletedNodeVersionsList()
        {
            // ARRANGE
            Classification expectedClassification = Classification.Confidential;
            NodeType       expectedType           = NodeType.File;
            string         expectedTypeValue      = "file";

            PreviousVersionList expected = FactoryNode.PreviousVersionList;

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

            foreach (PreviousVersion current in expected.Items)
            {
                current.Classification = expectedClassification;
                current.Type           = expectedType;
                ApiDeletedNodeVersion currentApi = new ApiDeletedNodeVersion()
                {
                    Type           = expectedTypeValue,
                    ParentId       = current.ParentId,
                    ParentPath     = current.ParentPath,
                    Name           = current.Name,
                    AccessedAt     = current.AccessedAt,
                    Classification = (int)expectedClassification,
                    CreatedAt      = current.CreatedAt,
                    CreatedBy      = new ApiUserInfo {
                        Id          = current.CreatedBy.Id.Value,
                        DisplayName = current.CreatedBy.DisplayName,
                        AvatarUuid  = current.CreatedBy.AvatarUUID
                    },
                    DeletedAt = current.DeletedAt,
                    DeletedBy = new ApiUserInfo {
                        Id          = current.DeletedBy.Id.Value,
                        DisplayName = current.DeletedBy.DisplayName,
                        AvatarUuid  = current.DeletedBy.AvatarUUID
                    },
                    ExpireAt    = current.ExpireAt,
                    Id          = current.Id,
                    IsEncrypted = current.IsEncrypted,
                    Notes       = current.Notes,
                    Size        = current.Size,
                    UpdatedAt   = current.UpdatedAt,
                    UpdatedBy   = new ApiUserInfo {
                        Id          = current.UpdatedBy.Id.Value,
                        DisplayName = current.UpdatedBy.DisplayName,
                        AvatarUuid  = current.UpdatedBy.AvatarUUID
                    }
                };
                param.Items.Add(currentApi);
                Mock.Arrange(() => NodeMapper.FromApiDeletedNodeVersion(currentApi)).Returns(current);
            }

            // ACT
            PreviousVersionList actual = NodeMapper.FromApiDeletedNodeVersionsList(param);

            // ASSERT
            Assert.Equal(expected, actual, new PreviousVersionListComparer());
        }