internal static PreviousVersion FromApiDeletedNodeVersion(ApiDeletedNodeVersion apiNode) { if (apiNode == null) { return(null); } PreviousVersion node = new PreviousVersion { Type = EnumConverter.ConvertValueToNodeTypeEnum(apiNode.Type), ParentId = apiNode.ParentId, ParentPath = apiNode.ParentPath, Name = apiNode.Name, AccessedAt = apiNode.AccessedAt, Classification = EnumConverter.ConvertValueToClassificationEnum(apiNode.Classification), CreatedAt = apiNode.CreatedAt, CreatedBy = UserMapper.FromApiUserInfo(apiNode.CreatedBy), DeletedAt = apiNode.DeletedAt, DeletedBy = UserMapper.FromApiUserInfo(apiNode.DeletedBy), ExpireAt = apiNode.ExpireAt, Id = apiNode.Id, IsEncrypted = apiNode.IsEncrypted, Notes = apiNode.Notes, Size = apiNode.Size, UpdatedAt = apiNode.UpdatedAt, UpdatedBy = UserMapper.FromApiUserInfo(apiNode.UpdatedBy) }; return(node); }
public void FromApiDeletedNodeVersion() { // ARRANGE Classification expectedClassification = Classification.Confidential; NodeType expectedType = NodeType.File; string expectedTypeValue = "file"; PreviousVersion expected = FactoryNode.PreviousVersion; expected.Classification = expectedClassification; expected.Type = expectedType; ApiDeletedNodeVersion param = new ApiDeletedNodeVersion { Type = expectedTypeValue, ParentId = expected.ParentId, ParentPath = expected.ParentPath, Name = expected.Name, AccessedAt = expected.AccessedAt, Classification = (int)expectedClassification, CreatedAt = expected.CreatedAt, CreatedBy = new ApiUserInfo { Id = expected.CreatedBy.Id.Value, DisplayName = expected.CreatedBy.DisplayName, AvatarUuid = expected.CreatedBy.AvatarUUID }, DeletedAt = expected.DeletedAt, DeletedBy = new ApiUserInfo { Id = expected.DeletedBy.Id.Value, DisplayName = expected.DeletedBy.DisplayName, AvatarUuid = expected.DeletedBy.AvatarUUID }, ExpireAt = expected.ExpireAt, Id = expected.Id, IsEncrypted = expected.IsEncrypted, Notes = expected.Notes, Size = expected.Size, UpdatedAt = expected.UpdatedAt, UpdatedBy = new ApiUserInfo { Id = expected.UpdatedBy.Id.Value, DisplayName = expected.UpdatedBy.DisplayName, AvatarUuid = expected.UpdatedBy.AvatarUUID } }; Mock.Arrange(() => EnumConverter.ConvertValueToNodeTypeEnum(expectedTypeValue)).Returns(expectedType); Mock.Arrange(() => EnumConverter.ConvertValueToClassificationEnum((int)expectedClassification)).Returns(expectedClassification); Mock.Arrange(() => UserMapper.FromApiUserInfo(param.CreatedBy)).Returns(expected.CreatedBy); Mock.Arrange(() => UserMapper.FromApiUserInfo(param.DeletedBy)).Returns(expected.DeletedBy); Mock.Arrange(() => UserMapper.FromApiUserInfo(param.UpdatedBy)).Returns(expected.UpdatedBy); // ACT PreviousVersion actual = NodeMapper.FromApiDeletedNodeVersion(param); // ASSERT Assert.Equal(expected, actual, new PreviousVersionComparer()); }
public void FromApiDeletedNodeVersion_Null() { // ARRANGE PreviousVersion expected = null; ApiDeletedNodeVersion param = null; // ACT PreviousVersion actual = NodeMapper.FromApiDeletedNodeVersion(param); // ASSERT Assert.Equal(expected, actual, new PreviousVersionComparer()); }
public PreviousVersion GetPreviousVersion(long previousNodeId) { _client.Executor.CheckApiServerVersion(); #region Parameter Validation previousNodeId.MustPositive(nameof(previousNodeId)); #endregion IRestRequest restRequest = _client.Builder.GetPreviousVersion(previousNodeId); ApiDeletedNodeVersion result = _client.Executor.DoSyncApiCall <ApiDeletedNodeVersion>(restRequest, RequestType.GetPreviousVersion); return(NodeMapper.FromApiDeletedNodeVersion(result)); }
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()); }