public void ConvertClassificationEnumToValue(Classification?value, int?expected)
        {
            // ARRANGE

            // ACT
            int?actual = EnumConverter.ConvertClassificationEnumToValue(value);

            // ASSERT
            Assert.Equal(expected, actual);
        }
Exemplo n.º 2
0
        public void FromApiDownloadShare()
        {
            // ARRANGE
            DownloadShare expected = FactoryShare.DownloadShare;

            expected.Classification = Classification.Confidential;

            ApiDownloadShare param = new ApiDownloadShare {
                ShareId               = expected.ShareId,
                NodeId                = expected.NodeId,
                NodePath              = expected.NodePath,
                Name                  = expected.Name,
                Notes                 = expected.Notes,
                Classification        = (int)expected.Classification,
                ExpireAt              = expected.ExpireAt,
                AccessKey             = expected.AccessKey,
                ShowCreatorName       = expected.ShowCreatorName,
                ShowCreatorUserName   = expected.ShowCreatorUserName,
                NotifyCreator         = expected.NotifyCreator,
                MaxAllowedDownloads   = expected.MaxAllowedDownloads,
                CurrentDownloadsCount = expected.CurrentDownloadsCount,
                CreatedAt             = expected.CreatedAt,
                CreatedBy             = new ApiUserInfo {
                    AvatarUuid  = expected.CreatedBy.AvatarUUID,
                    DisplayName = expected.CreatedBy.DisplayName,
                    Id          = expected.CreatedBy.Id.Value
                },
                IsProtected = expected.IsProtected,
                IsEncrypted = expected.IsEncrypted
            };

            Mock.Arrange(() => EnumConverter.ConvertClassificationEnumToValue(expected.Classification)).Returns((int)expected.Classification);
            Mock.Arrange(() => UserMapper.FromApiUserInfo(param.CreatedBy)).Returns(expected.CreatedBy);

            // ACT
            DownloadShare actual = ShareMapper.FromApiDownloadShare(param);

            // ASSERT
            Assert.Equal(expected, actual, new DownloadShareComparer());
        }
Exemplo n.º 3
0
        internal static ApiUpdateFileRequest ToApiUpdateFileRequest(UpdateFileRequest updateFileRequest)
        {
            ApiExpiration apiExpiration = null;

            if (updateFileRequest.Expiration.HasValue)
            {
                apiExpiration = new ApiExpiration()
                {
                    ExpireAt         = updateFileRequest.Expiration,
                    EnableExpiration = updateFileRequest.Expiration.Value.Ticks != 0
                };
            }

            ApiUpdateFileRequest apiUpdateFileRequest = new ApiUpdateFileRequest {
                Name           = updateFileRequest.Name,
                Notes          = updateFileRequest.Notes,
                Classification = EnumConverter.ConvertClassificationEnumToValue(updateFileRequest.Classification),
                Expiration     = apiExpiration
            };

            return(apiUpdateFileRequest);
        }
Exemplo n.º 4
0
        internal static ApiCreateFileUpload ToApiCreateFileUpload(FileUploadRequest fileUploadRequest)
        {
            ApiExpiration apiExpiration = null;

            if (fileUploadRequest.ExpirationDate.HasValue)
            {
                apiExpiration = new ApiExpiration {
                    ExpireAt         = fileUploadRequest.ExpirationDate,
                    EnableExpiration = fileUploadRequest.ExpirationDate.Value.Ticks != 0
                };
            }

            ApiCreateFileUpload apiCreateFileUpload = new ApiCreateFileUpload {
                ParentId       = fileUploadRequest.ParentId,
                Name           = fileUploadRequest.Name,
                Classification = EnumConverter.ConvertClassificationEnumToValue(fileUploadRequest.Classification),
                Notes          = fileUploadRequest.Notes,
                Expiration     = apiExpiration
            };

            return(apiCreateFileUpload);
        }
Exemplo n.º 5
0
        public void ToApiUpdateFileRequest()
        {
            // ARRANGE
            ApiUpdateFileRequest expected = FactoryFile.ApiUpdateFileRequest;

            expected.Classification = 2;

            UpdateFileRequest param = new UpdateFileRequest(24654)
            {
                Classification = (Classification)Enum.ToObject(typeof(Classification), expected.Classification),
                Expiration     = expected.Expiration.ExpireAt,
                Name           = expected.Name,
                Notes          = expected.Notes
            };

            Mock.Arrange(() => EnumConverter.ConvertClassificationEnumToValue(param.Classification)).Returns(expected.Classification);

            // ACT
            ApiUpdateFileRequest actual = FileMapper.ToApiUpdateFileRequest(param);

            // ASSERT
            Assert.Equal(expected, actual, new ApiUpdateFileRequestComparer());
        }
Exemplo n.º 6
0
        public void ToApiCreateFileUpload()
        {
            // ARRANGE
            ApiCreateFileUpload expected = FactoryFile.ApiCreateFileUpload;

            expected.Classification = 3;

            FileUploadRequest param = new FileUploadRequest(expected.ParentId,
                                                            expected.Name,
                                                            (Classification)Enum.ToObject(typeof(Classification), expected.Classification))
            {
                ExpirationDate     = expected.Expiration.ExpireAt,
                Notes              = expected.Notes,
                ResolutionStrategy = ResolutionStrategy.Overwrite
            };

            Mock.Arrange(() => EnumConverter.ConvertClassificationEnumToValue(param.Classification)).Returns(expected.Classification);

            // ACT
            ApiCreateFileUpload actual = FileMapper.ToApiCreateFileUpload(param);

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