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); }
public void FromApiDeletedNodeSummaryList_Null() { // ARRANGE RecycleBinItemList expected = null; ApiDeletedNodeSummaryList param = null; // ACT RecycleBinItemList actual = NodeMapper.FromApiDeletedNodeSummaryList(param); // ASSERT Assert.Equal(expected, actual, new RecycleBinItemListComparer()); }
internal static RecycleBinItemList FromApiDeletedNodeSummaryList(ApiDeletedNodeSummaryList apiNodeList) { if (apiNodeList == null) { return(null); } RecycleBinItemList nodeList = new RecycleBinItemList { Offset = apiNodeList.Range.Offset, Limit = apiNodeList.Range.Limit, Total = apiNodeList.Range.Total, Items = new List <RecycleBinItem>() }; foreach (ApiDeletedNodeSummary currentNode in apiNodeList.Items) { nodeList.Items.Add(FromApiDeletedNodeSummary(currentNode)); } return(nodeList); }
public void FromApiDeletedNodeSummaryList() { // ARRANGE NodeType expectedType = NodeType.File; string expectedTypeValue = "file"; RecycleBinItemList expected = FactoryNode.RecycleBinItemList; ApiDeletedNodeSummaryList param = new ApiDeletedNodeSummaryList { Range = new ApiRange { Offset = expected.Offset, Limit = expected.Limit, Total = expected.Total }, Items = new List <ApiDeletedNodeSummary>(expected.Items.Count) }; foreach (RecycleBinItem current in expected.Items) { current.Type = expectedType; ApiDeletedNodeSummary currentApi = new ApiDeletedNodeSummary { Type = expectedTypeValue, CntVersions = current.VersionsCount, FirstDeletedAt = current.FirstDeletedAt, LastDeletedAt = current.LastDeletedAt, LastDeletedNodeId = current.LastDeletedNodeId, Name = current.Name, ParentId = current.ParentId, ParentPath = current.ParentPath }; param.Items.Add(currentApi); Mock.Arrange(() => NodeMapper.FromApiDeletedNodeSummary(currentApi)).Returns(current); } // ACT RecycleBinItemList actual = NodeMapper.FromApiDeletedNodeSummaryList(param); // ASSERT Assert.Equal(expected, actual, new RecycleBinItemListComparer()); }