Exemple #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"]);
        }
Exemple #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;
 }
Exemple #4
0
 public void TearDown()
 {
     _dataManagementPlanRepository = null;
     _dmp = null;
     _sharePointHelper = null;
     _pdfHelper        = null;
     _generatorHelper  = null;
     _generator        = null;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LearningPlanHelper"/> class.
 /// </summary>
 /// <param name="logger">Instance of ILogger</param>
 /// <param name="localizer">The current culture's string localizer.</param>
 /// <param name="botOptions">A set of key/value application configuration properties.</param>
 /// <param name="sharePointOptions">A set of key/value application configuration properties for SharePoint.</param>
 /// <param name="graphUtility">Instance of Microsoft Graph utility helper.</param>
 /// <param name="sharePointHelper">Instance of SharePoint utility helper.</param>
 public LearningPlanHelper(
     ILogger <LearningPlanHelper> logger,
     IStringLocalizer <Strings> localizer,
     IOptions <BotOptions> botOptions,
     IOptions <SharePointSettings> sharePointOptions,
     IGraphUtilityHelper graphUtility,
     ISharePointHelper sharePointHelper)
 {
     this.logger            = logger;
     this.localizer         = localizer;
     this.botOptions        = botOptions ?? throw new ArgumentNullException(nameof(botOptions));
     this.sharePointOptions = sharePointOptions ?? throw new ArgumentNullException(nameof(sharePointOptions));
     this.graphUtility      = graphUtility;
     this.sharePointHelper  = sharePointHelper;
 }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ActivityHelper{T}"/> class.
 /// </summary>
 /// <param name="logger">Instance to send logs to the Application Insights service.</param>
 /// <param name="userState">State management object for maintaining user conversation state.</param>
 /// <param name="teamStorageProvider">Provider for fetching information about team details from storage.</param>
 /// <param name="localizer">The current culture's string localizer.</param>
 /// <param name="dialog">Base class for all bot dialogs.</param>
 /// <param name="conversationState">State management object for maintaining conversation state.</param>
 /// <param name="teamMembershipHelper">Helper for team operations with Microsoft Graph API.</param>
 /// <param name="userProfileGraphApiHelper">Helper for user profile operations with Microsoft Graph API.</param>
 /// <param name="introductionStorageProvider">Provider for fetching information about new joiner introduction details from storage.</param>
 /// <param name="sharePointHelper">Helper for working with SharePoint.</param>
 /// <param name="introductionCardHelper">Helper for working with introduction cards.</param>
 /// <param name="graphUtility">Instance of Microsoft Graph utility helper.</param>
 /// <param name="welcomeCardFactory">Factory for working with welcome card attachments.</param>
 /// <param name="botOptions">A set of key/value application configuration properties for bot.</param>
 /// <param name="userStorageProvider">Provider for fetching information about user details from storage.</param>
 /// <param name="securityGroupSettings"> A set of key/value application configuration properties for AAD security group settings.</param>
 /// <param name="feedbackProvider">Provider for fetching information about new joiner feedbacks from storage.</param>
 /// <param name="imageUploadProvider">Provider for uploading user image to blob storage.</param>
 public ActivityHelper(
     ILogger <ActivityHelper <T> > logger,
     UserState userState,
     ITeamStorageProvider teamStorageProvider,
     IStringLocalizer <Strings> localizer,
     T dialog,
     ConversationState conversationState,
     ITeamMembership teamMembershipHelper,
     IUserProfile userProfileGraphApiHelper,
     IIntroductionStorageProvider introductionStorageProvider,
     ISharePointHelper sharePointHelper,
     IIntroductionCardHelper introductionCardHelper,
     IGraphUtilityHelper graphUtility,
     IWelcomeCardFactory welcomeCardFactory,
     IOptions <BotOptions> botOptions,
     IUserStorageProvider userStorageProvider,
     IOptions <AadSecurityGroupSettings> securityGroupSettings,
     IFeedbackProvider feedbackProvider,
     IImageUploadProvider imageUploadProvider)
 {
     this.logger                      = logger;
     this.userState                   = userState;
     this.teamStorageProvider         = teamStorageProvider;
     this.localizer                   = localizer;
     this.dialog                      = dialog;
     this.conversationState           = conversationState;
     this.teamOperationGraphApiHelper = teamMembershipHelper;
     this.userProfileGraphApiHelper   = userProfileGraphApiHelper;
     this.introductionStorageProvider = introductionStorageProvider;
     this.sharePointHelper            = sharePointHelper;
     this.introductionCardHelper      = introductionCardHelper;
     this.graphUtility                = graphUtility;
     this.welcomeCardFactory          = welcomeCardFactory;
     this.botOptions                  = botOptions ?? throw new ArgumentNullException(nameof(botOptions));
     this.userStorageProvider         = userStorageProvider;
     this.securityGroupSettings       = securityGroupSettings ?? throw new ArgumentNullException(nameof(securityGroupSettings));
     this.feedbackProvider            = feedbackProvider;
     this.imageUploadProvider         = imageUploadProvider;
 }