示例#1
0
        public void SetUp()
        {
            var files = Directory.GetFiles(Tempdir);

            Array.ForEach(files, File.Delete);
            _dmp = Builder <DataManagementPlan> .CreateNew()
                   .With(o => o.BackupLocations             = BackupLocations.MicrosoftSharePoint | BackupLocations.PersonalHardDrives | BackupLocations.InstitutionalBackup | BackupLocations.Other)
                   .And(o => o.BackupPolicyResponsibilities = DataResponsibilities.Other | DataResponsibilities.PrincipalInvestigator)
                   .And(o => o.IsSensitive  = Pick <bool> .RandomItemFrom(new[] { false, true }))
                   .And(o => o.CreationDate = DateTime.Now)
                   .And(o => o.UrdmsUsers   = Builder <UrdmsUser> .CreateListOfSize(5).Build())
                   .And(o => o.RelationshipBetweenExistingAndNewData = EnumValuesHelper.RandomItem(DataRelationship.None))
                   .And(o => o.DataRetentionLocations        = DataRetentionLocations.External | DataRetentionLocations.Internal | DataRetentionLocations.Other)
                   .And(o => o.DataRetentionPeriod           = EnumValuesHelper.RandomItem(DataRetentionPeriod.Short))
                   .And(o => o.DataRetentionResponsibilities = DataResponsibilities.Other | DataResponsibilities.PrincipalInvestigator)
                   .And(o => o.DepositToRepository           = Pick <bool> .RandomItemFrom(new[] { false, true }))
                   .And(o => o.DataSharingAvailability       = DataSharingAvailability.AfterASpecifiedEmbargoPeriod)
                   .And(o => o.DataSharingAvailabilityDate   = DateTime.Today.AddYears(10))
                   .And(o => o.DataLicensingType             = EnumValuesHelper.RandomItem <DataLicensingType>())
                   .And(o => o.ShareAccess = EnumValuesHelper.RandomItem(ShareAccess.None))
                   .And(o => o.InstitutionalStorageTypes = InstitutionalStorageTypes.ProjectStorageSpace | InstitutionalStorageTypes.PersonalNetworkDrive | InstitutionalStorageTypes.PersonalNetworkDrive | InstitutionalStorageTypes.Other)
                   .And(o => o.ExternalStorageTypes      = ExternalStorageTypes.DataFabric | ExternalStorageTypes.IvecPetabyte | ExternalStorageTypes.Other)
                   .And(o => o.MaxDataSize             = EnumValuesHelper.RandomItem(MaxDataSize.None))
                   .And(o => o.PersonalStorageTypes    = PersonalStorageTypes.RemovableMedia | PersonalStorageTypes.InternalHardDrives | PersonalStorageTypes.Other)
                   .And(o => o.VersionControl          = EnumValuesHelper.RandomItem(VersionControl.None))
                   .And(o => o.EthicRequiresClearance  = Pick <bool> .RandomItemFrom(new[] { false, true }))
                   .And(o => o.ExistingDataAccessTypes = ExistingDataAccessTypes.DataIsFreelyAvailable | ExistingDataAccessTypes.ObtainApprovalFromOwner | ExistingDataAccessTypes.Other | ExistingDataAccessTypes.Purchase)
                   .And(o => o.UseExistingData         = Pick <bool> .RandomItemFrom(new[] { false, true }))
                   .And(o => o.DataOwners           = DataOwners.MyInstitution | DataOwners.Researcher | DataOwners.Other)
                   .And(o => o.DataActionFrequency  = EnumValuesHelper.RandomItem(DataActionFrequency.None))
                   .And(o => o.NonUrdmsUsers        = Builder <User> .CreateListOfSize(4).Build())
                   .And(o => o.PricipalInvestigator = Pick <string> .RandomItemFrom(new[] { "John Doe", "Joe Bloggs", "Jane Doe", "John Smith" }))
                   .And(o => o.ProjectTitle         = Pick <string> .RandomItemFrom(new[] { "Feeding Habits of Polar Bears", "The Ecosystem in the Sahara Desert" }))
                   .And(o => o.DateModified         = DateTime.Now)
                   .Build();

            _dataManagementPlanRepository = Substitute.For <IDataManagementPlanRepository>();
            _dataManagementPlanRepository.GetDataManagementPlanByProjectId(Arg.Is(ProjectId)).Returns(_dmp);
            _sharePointHelper = Substitute.For <ISharePointHelper>();
            _pdfHelper        = Substitute.For <IPdfHelper>();
            _generatorHelper  = Substitute.For <IGeneratorHelper>();
            _xmlHelper        = Substitute.For <IXmlHelper>();
            _generator        = new DmpGenerator(_sharePointHelper, _dataManagementPlanRepository, _pdfHelper, _generatorHelper, _xmlHelper);

            _projectRepository = Substitute.For <IProjectRepository>();
            var projects = Builder <Project> .CreateListOfSize(2)
                           .TheFirst(1)
                           .With(o => o.SourceProjectType = EnumValuesHelper.RandomItem(SourceProjectType.None, SourceProjectType.DEPOSIT))
                           .TheNext(1)
                           .With(o => o.SourceProjectType = SourceProjectType.DEPOSIT)
                           .Build()
                           .ToList();

            _nonDepositProject = projects[0];
            _depositProject    = projects[1];
            projects.ForEach(o => _projectRepository.Get(Arg.Is(o.Id)).Returns(o));

            // Initialise PDF library
            // XSettings.InstallRedistributionLicense(ConfigurationManager.AppSettings["ABCPDFLicenseKey"]);
        }
示例#2
0
 public DmpGenerator(ISharePointHelper sharePointHelper, IDataManagementPlanRepository repository, IPdfHelper pdfHelper, IGeneratorHelper generatorHelper, IXmlHelper xmlHelper)
 {
     SharePointHelper = sharePointHelper;
     Repository       = repository;
     PdfHelper        = pdfHelper;
     GeneratorHelper  = generatorHelper;
     XmlHelper        = xmlHelper;
 }
 public DmpGenerator(ISharePointHelper sharePointHelper, IDataManagementPlanRepository repository, IPdfHelper pdfHelper, IGeneratorHelper generatorHelper, IXmlHelper xmlHelper)
 {
     SharePointHelper = sharePointHelper;
     Repository = repository;
     PdfHelper = pdfHelper;
     GeneratorHelper = generatorHelper;
     XmlHelper = xmlHelper;
 }
示例#4
0
 public void TearDown()
 {
     _dataManagementPlanRepository = null;
     _dmp = null;
     _sharePointHelper = null;
     _pdfHelper        = null;
     _generatorHelper  = null;
     _generator        = null;
 }