public void SetRestrictionProperties_ShouldSetOpenDisplayText()
        {
            var list = new List <SandboxDatasetDto>();

            list.Add(new SandboxDatasetDto()
            {
                Classification = DatasetClassification.Open.ToString(), DatasetId = 1
            });
            list.Add(new SandboxDatasetDto()
            {
                Classification = DatasetClassification.Open.ToString(), DatasetId = 2
            });
            list.Add(new SandboxDatasetDto()
            {
                Classification = DatasetClassification.Open.ToString(), DatasetId = 3
            });
            var sandboxDetails = new SandboxDetails()
            {
                Datasets = list
            };

            DatasetClassificationUtils.SetRestrictionProperties(sandboxDetails);

            Assert.Equal(DatasetConstants.DATASET_RESTRICTION_TEXT_OPEN, sandboxDetails.RestrictionDisplayText);
        }
        public void SetRestrictionProperties_AvailableDatasets_ShouldSetOpendDisplayText()
        {
            var list = new List <AvailableDatasetItem>();

            list.Add(new AvailableDatasetItem()
            {
                Classification = DatasetClassification.Open.ToString(), DatasetId = 1, AddedToSandbox = true
            });
            list.Add(new AvailableDatasetItem()
            {
                Classification = DatasetClassification.Open.ToString(), DatasetId = 2, AddedToSandbox = true
            });
            list.Add(new AvailableDatasetItem()
            {
                Classification = DatasetClassification.Open.ToString(), DatasetId = 3, AddedToSandbox = true
            });

            AvailableDatasets availableDatasets = new AvailableDatasets(list);

            availableDatasets.Datasets = list;

            DatasetClassificationUtils.SetRestrictionProperties(availableDatasets);

            Assert.Equal(DatasetConstants.DATASET_RESTRICTION_TEXT_OPEN, availableDatasets.RestrictionDisplayText);
        }
Пример #3
0
        protected async Task <SandboxDetails> GetSandboxDetailsInternalAsync(int sandboxId)
        {
            var sandboxFromDb = await _sandboxModelService.GetDetailsByIdAsync(sandboxId);

            var sandboxDetailsDto = _mapper.Map <SandboxDetails>(sandboxFromDb);

            await DecorateDto(sandboxFromDb.Study, sandboxDetailsDto.Permissions, sandboxDetailsDto.CurrentPhase);

            DatasetClassificationUtils.SetRestrictionProperties(sandboxDetailsDto);

            return(sandboxDetailsDto);
        }
Пример #4
0
        AvailableDatasets MapToAvailable(Sandbox sandbox)
        {
            var availableDatasets = sandbox.Study
                                    .StudyDatasets
                                    .Select(sd => new AvailableDatasetItem()
            {
                DatasetId      = sd.DatasetId,
                Name           = sd.Dataset.Name,
                Classification = sd.Dataset.Classification,
                AddedToSandbox = sd.Dataset.SandboxDatasets.Where(sd => sd.SandboxId == sandbox.Id).Any()
            });

            var result = new AvailableDatasets(availableDatasets);

            DatasetClassificationUtils.SetRestrictionProperties(result);

            return(result);
        }