private Project SetUpFullProject(string curtinId) { var dmp = Builder <DataManagementPlan> .CreateNew() .With(o => o.ExistingDataDetail = Builder <ExistingDataDetail> .CreateNew() .With(q => q.UseExistingData = PickHelper.RandomBoolean()) .And(q => q.ExistingDataAccessTypes = PickHelper.RandomEnumsExcept(ExistingDataAccessTypes.None)) .Build()) .And(o => o.BackupPolicy = Builder <BackupPolicy> .CreateNew().Build()) .And(o => o.NewDataDetail = Builder <NewDataDetail> .CreateNew() .With(q => q.DataOwners = PickHelper.RandomEnumsExcept(DataOwners.None)) .Build()) .And(o => o.DataRelationshipDetail = Builder <DataRelationshipDetail> .CreateNew() .With(q => q.RelationshipBetweenExistingAndNewData = PickHelper.RandomEnumExcept(DataRelationship.None)) .Build()) .And(o => o.DataDocumentation = Builder <DataDocumentation> .CreateNew() .Build()) .And(o => o.Ethic = Builder <Ethic> .CreateNew() .With(q => q.EthicRequiresClearance = PickHelper.RandomBoolean()) .Build()) .And(o => o.Confidentiality = Builder <Confidentiality> .CreateNew() .With(q => q.IsSensitive = PickHelper.RandomBoolean()) .Build()) .And(o => o.DataStorage = Builder <DataStorage> .CreateNew() .With(q => q.InstitutionalStorageTypes = PickHelper.RandomEnumExcept(InstitutionalStorageTypes.ProjectStorageSpace)) .And(q => q.ExternalStorageTypes = PickHelper.RandomEnumExcept(ExternalStorageTypes.None)) .And(q => q.PersonalStorageTypes = PickHelper.RandomEnumExcept(PersonalStorageTypes.None)) .And(q => q.MaxDataSize = PickHelper.RandomEnumExcept(MaxDataSize.None)) .And(q => q.VersionControl = PickHelper.RandomEnumsExcept(VersionControl.None)) .Build()) .And(o => o.DataRetention = Builder <DataRetention> .CreateNew() .With(q => q.DataRetentionLocations = PickHelper.RandomEnumExcept(DataRetentionLocations.None)) .And(q => q.DataRetentionResponsibilities = PickHelper.RandomEnumExcept(DataResponsibilities.None)) .And(q => q.DataRetentionPeriod = PickHelper.RandomEnumExcept <DataRetentionPeriod>()) .Build()) .And(o => o.DataSharing = Builder <DataSharing> .CreateNew() .With(q => q.DataSharingAvailability = PickHelper.RandomEnumExcept <DataSharingAvailability>()) .And(q => q.DataSharingAvailabilityDate = DateTime.Today.AddYears(1)) .And(q => q.ShareAccess = PickHelper.RandomEnumExcept(ShareAccess.NoAccess)) .And(q => q.DataLicensingType = PickHelper.RandomEnumExcept <DataLicensingType>()) .Build()) .Build(); var projectParties = Builder <ProjectParty> .CreateListOfSize(5) .TheFirst(1) .With(q => q.Party = Builder <Party> .CreateNew().With(r => r.UserId = curtinId).Build()) .And(q => q.Relationship = ProjectRelationship.PrincipalInvestigator) .TheLast(4) .With(q => q.Party = Builder <Party> .CreateNew().Build()) .And(q => q.Relationship = PickHelper.RandomEnumExcept(ProjectRelationship.None, ProjectRelationship.PrincipalInvestigator)) .Build(); var project = Builder <Project> .CreateNew() .With(o => o.DataManagementPlan = dmp) .And(o => o.Title = "Feeding habits of polarbears (2011)") .And(o => o.ProvisioningStatus = PickHelper.RandomEnumExcept <ProvisioningStatus>()) .Do(o => o.Parties.AddRange(projectParties)) .Build(); return(project); }
private Project SetUpFullProjectWithAuthentication(string userId = "XX12345") { CreateUser(userId); var dmp = Builder <DataManagementPlan> .CreateNew() .With(o => o.ExistingDataDetail = Builder <ExistingDataDetail> .CreateNew() .With(q => q.UseExistingData = PickHelper.RandomBoolean()) .And(q => q.ExistingDataAccessTypes = PickHelper.RandomEnumsExcept(ExistingDataAccessTypes.None)) .Build()) .And(o => o.NewDataDetail = Builder <NewDataDetail> .CreateNew() .With(q => q.DataOwners = PickHelper.RandomEnumsExcept(DataOwners.None)) .Build()) .And(o => o.DataRelationshipDetail = Builder <DataRelationshipDetail> .CreateNew() .With(q => q.RelationshipBetweenExistingAndNewData = PickHelper.RandomEnumExcept(DataRelationship.None)) .Build()) .And(o => o.DataDocumentation = Builder <DataDocumentation> .CreateNew() .Build()) .And(o => o.Ethic = Builder <Ethic> .CreateNew() .With(q => q.EthicRequiresClearance = PickHelper.RandomBoolean()) .Build()) .And(o => o.Confidentiality = Builder <Confidentiality> .CreateNew() .With(q => q.IsSensitive = PickHelper.RandomBoolean()) .Build()) .And(o => o.DataStorage = Builder <DataStorage> .CreateNew() .With(q => q.InstitutionalStorageTypes = PickHelper.RandomEnumExcept(InstitutionalStorageTypes.ProjectStorageSpace)) .And(q => q.ExternalStorageTypes = PickHelper.RandomEnumExcept(ExternalStorageTypes.None)) .And(q => q.PersonalStorageTypes = PickHelper.RandomEnumExcept(PersonalStorageTypes.None)) .And(q => q.MaxDataSize = PickHelper.RandomEnumExcept(MaxDataSize.None)) .And(q => q.VersionControl = PickHelper.RandomEnumsExcept(VersionControl.None)) .Build()) .And(o => o.DataRetention = Builder <DataRetention> .CreateNew() .With(q => q.DataRetentionLocations = PickHelper.RandomEnumExcept(DataRetentionLocations.None)) .And(q => q.DataRetentionResponsibilities = PickHelper.RandomEnumExcept(DataResponsibilities.None)) .And(q => q.DataRetentionPeriod = PickHelper.RandomEnumExcept <DataRetentionPeriod>()) .And(q => q.DepositToRepository = PickHelper.RandomBoolean()) .Build()) .And(o => o.DataSharing = Builder <DataSharing> .CreateNew() .With(q => q.DataSharingAvailability = PickHelper.RandomEnumExcept <DataSharingAvailability>()) .And(q => q.DataSharingAvailabilityDate = DateTime.Today.AddYears(1)) .And(q => q.ShareAccess = PickHelper.RandomEnumExcept(ShareAccess.NoAccess)) .And(q => q.DataLicensingType = PickHelper.RandomEnumExcept <DataLicensingType>()) .Build()) .Build(); var project = Builder <Project> .CreateNew() .With(o => o.DataManagementPlan = dmp) .And(o => o.ProvisioningStatus = PickHelper.RandomEnumExcept <ProvisioningStatus>(ProvisioningStatus.Error, ProvisioningStatus.TimeOut)) .Do(o => o.Parties.Add(Builder <ProjectParty> .CreateNew() .With(q => q.Party = Builder <Party> .CreateNew().With(r => r.UserId = userId).Build()) .And(q => q.Relationship = ProjectRelationship.PrincipalInvestigator) .Build())) .Build(); project.Parties.Do(o => o.Project = project); _projectRepository.GetByDataManagementPlanId(project.DataManagementPlan.Id).Returns(project); return(project); }
public void Update_the_project_entity_when_saving_at_step1() { const int step = 1; _form["stepAction"] = "Save and Next"; var project = SetUpFullProjectWithAuthentication(); var dmp = project.DataManagementPlan; var existingDataDetail = Builder <ExistingDataDetailViewModel> .CreateNew() .With(o => o.UseExistingData = !dmp.ExistingDataDetail.UseExistingData) .And(o => o.AccessTypesDescription = "Updated Access Types Description") .And(o => o.ExistingDataAccessTypes = PickHelper.RandomEnumsExcept(ExistingDataAccessTypes.None)) .And(o => o.ExistingDataOwner = "Updated Owner") .Build(); var newDataDetail = Builder <NewDataDetailViewModel> .CreateNew() .With(o => o.DataOwners = PickHelper.RandomEnumsExcept(DataOwners.None)) .And(o => o.ResearchDataDescription = "Updated Research Data Description") .Build(); var dataRelationshipDetail = Builder <DataRelationshipDetailViewModel> .CreateNew() .With(o => o.RelationshipBetweenExistingAndNewData = PickHelper .RandomEnumExcept(dmp.DataRelationshipDetail.RelationshipBetweenExistingAndNewData, DataRelationship.None)) .Build(); var vm = Builder <DataManagementPlanViewModel> .CreateNew() .With(o => o.Id = dmp.Id) .And(o => o.ProjectId = project.Id) .And(o => o.ProjectTitle = project.Title) .And(o => o.Step = step) .And(o => o.ExistingDataDetail = existingDataDetail) .And(o => o.NewDataDetail = newDataDetail) .And(o => o.DataRelationshipDetail = dataRelationshipDetail) .Build(); var methodInfo = _controller.GetType().GetMethod("Edit", new[] { typeof(int), typeof(int) }); Assert.That(methodInfo, Is.Not.Null); _controller.WithCallTo(x => x.Edit(vm)).ShouldRedirectTo(methodInfo); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.NewDataDetail.DataOwners == newDataDetail.DataOwners)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.NewDataDetail.ResearchDataDescription == newDataDetail.ResearchDataDescription)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.DataRelationshipDetail.RelationshipBetweenExistingAndNewData == dataRelationshipDetail.RelationshipBetweenExistingAndNewData)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.ExistingDataDetail.UseExistingData == existingDataDetail.UseExistingData)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.ExistingDataDetail.AccessTypesDescription == existingDataDetail.AccessTypesDescription)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.ExistingDataDetail.ExistingDataAccessTypes == existingDataDetail.ExistingDataAccessTypes)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.ExistingDataDetail.ExistingDataOwner == existingDataDetail.ExistingDataOwner)); }
public void Update_the_project_entity_when_saving_at_step4() { const int step = 4; _form["stepAction"] = "Save and Next"; var project = SetUpFullProjectWithAuthentication(); var dmp = project.DataManagementPlan; var dataStorage = Builder <DataStorageViewModel> .CreateNew() .With(o => o.InstitutionalStorageTypes = PickHelper.RandomEnumsExcept(InstitutionalStorageTypes.ProjectStorageSpace, dmp.DataStorage.InstitutionalStorageTypes)) .And(o => o.InstitutionalOtherTypeDescription = "Updated Institutional Other Type Description") .And(o => o.ExternalStorageTypes = PickHelper.RandomEnumsExcept(ExternalStorageTypes.Other, dmp.DataStorage.ExternalStorageTypes)) .And(o => o.ExternalOtherTypeDescription = "Updated External Other Type Description") .And(o => o.PersonalStorageTypes = PickHelper.RandomEnumsExcept(PersonalStorageTypes.None, dmp.DataStorage.PersonalStorageTypes)) .And(o => o.PersonalOtherTypeDescription = "Updated Personal Other Type Description") .And(o => o.MaxDataSize = PickHelper.RandomEnumExcept(MaxDataSize.None, dmp.DataStorage.MaxDataSize)) .And(o => o.FileFormats = "Updated File Formats") .And(o => o.VersionControl = PickHelper.RandomEnumsExcept(dmp.DataStorage.VersionControl, VersionControl.None)) .And(o => o.VersionControlDescription = "Updated Version Control Description") .Build(); var vm = Builder <DataManagementPlanViewModel> .CreateNew() .With(o => o.Id = dmp.Id) .And(o => o.ProjectId = project.Id) .And(o => o.ProjectTitle = project.Title) .And(o => o.DataStorage = dataStorage) .And(o => o.Step = step) .Build(); var methodInfo = _controller.GetType().GetMethod("Edit", new[] { typeof(int), typeof(int) }); Assert.That(methodInfo, Is.Not.Null); _controller.WithCallTo(x => x.Edit(vm)).ShouldRedirectTo(methodInfo); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.DataStorage.InstitutionalOtherTypeDescription == dataStorage.InstitutionalOtherTypeDescription)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.DataStorage.InstitutionalStorageTypes == dataStorage.InstitutionalStorageTypes)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.DataStorage.ExternalOtherTypeDescription == dataStorage.ExternalOtherTypeDescription)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.DataStorage.ExternalStorageTypes == dataStorage.ExternalStorageTypes)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.DataStorage.PersonalOtherTypeDescription == dataStorage.PersonalOtherTypeDescription)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.DataStorage.PersonalStorageTypes == dataStorage.PersonalStorageTypes)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.DataStorage.VersionControl == dataStorage.VersionControl)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.DataStorage.VersionControlDescription == dataStorage.VersionControlDescription)); }
public void Generate_Datatable_from_DataManagementPlans() { const string userId = "GA37493"; var projectParties = Builder <ProjectParty> .CreateListOfSize(5) .TheFirst(1) .With(q => q.Party = Builder <Party> .CreateNew().With(r => r.UserId = userId).Build()) .And(q => q.Relationship = ProjectRelationship.PrincipalInvestigator) .TheLast(4) .With(q => q.Party = Builder <Party> .CreateNew().Build()) .And(q => q.Relationship = PickHelper.RandomEnumExcept(ProjectRelationship.None, ProjectRelationship.PrincipalInvestigator)) .Build(); var dataManagementPlan = Builder <DataManagementPlan> .CreateNew() .With(o => o.ExistingDataDetail = Builder <ExistingDataDetail> .CreateNew() .With(q => q.UseExistingData = PickHelper.RandomBoolean()) .And(q => q.ExistingDataAccessTypes = PickHelper.RandomEnumsExcept(ExistingDataAccessTypes.None)) .Build()) .And(o => o.BackupPolicy = Builder <BackupPolicy> .CreateNew().Build()) .And(o => o.NewDataDetail = Builder <NewDataDetail> .CreateNew() .With(q => q.DataOwners = PickHelper.RandomEnumsExcept(DataOwners.None)) .Build()) .And(o => o.DataRelationshipDetail = Builder <DataRelationshipDetail> .CreateNew() .With(q => q.RelationshipBetweenExistingAndNewData = PickHelper.RandomEnumExcept(DataRelationship.None)) .Build()) .And(o => o.DataDocumentation = Builder <DataDocumentation> .CreateNew() .Build()) .And(o => o.Ethic = Builder <Ethic> .CreateNew() .With(q => q.EthicRequiresClearance = PickHelper.RandomBoolean()) .Build()) .And(o => o.Confidentiality = Builder <Confidentiality> .CreateNew() .With(q => q.IsSensitive = PickHelper.RandomBoolean()) .Build()) .And(o => o.DataStorage = Builder <DataStorage> .CreateNew() .With(q => q.InstitutionalStorageTypes = PickHelper.RandomEnumExcept(InstitutionalStorageTypes.ProjectStorageSpace)) .And(q => q.ExternalStorageTypes = PickHelper.RandomEnumExcept(ExternalStorageTypes.None)) .And(q => q.PersonalStorageTypes = PickHelper.RandomEnumExcept(PersonalStorageTypes.None)) .And(q => q.MaxDataSize = PickHelper.RandomEnumExcept(MaxDataSize.None)) .And(q => q.VersionControl = PickHelper.RandomEnumsExcept(VersionControl.None)) .Build()) .And(o => o.DataRetention = Builder <DataRetention> .CreateNew() .With(q => q.DataRetentionLocations = PickHelper.RandomEnumExcept(DataRetentionLocations.None)) .And(q => q.DataRetentionResponsibilities = PickHelper.RandomEnumExcept(DataResponsibilities.None)) .And(q => q.DataRetentionPeriod = PickHelper.RandomEnumExcept <DataRetentionPeriod>()) .Build()) .And(o => o.DataSharing = Builder <DataSharing> .CreateNew() .With(q => q.DataSharingAvailability = PickHelper.RandomEnumExcept <DataSharingAvailability>()) .And(q => q.DataSharingAvailabilityDate = DateTime.Today.AddYears(1)) .And(q => q.ShareAccess = PickHelper.RandomEnumExcept(ShareAccess.NoAccess)) .And(q => q.DataLicensingType = PickHelper.RandomEnumExcept <DataLicensingType>()) .Build()) .Build(); var projects = Builder <Project> .CreateListOfSize(5) .All() .With(o => o.DataManagementPlan = dataManagementPlan) .And(o => o.ProvisioningStatus = PickHelper.RandomEnumExcept <ProvisioningStatus>()) .Do(o => o.Parties.AddRange(projectParties)) .Build(); var dataManagementPlansTable = _csvHelper.DataManagementPlansToDataTable(projects); Assert.That(dataManagementPlansTable, Is.Not.Null); Assert.That(dataManagementPlansTable.Columns.Count, Is.EqualTo(DataManagementColumnCount), "Incorrect number of columns"); Assert.That(dataManagementPlansTable.Rows.Count, Is.EqualTo(5)); for (var index = 0; index < projects.Count; index++) { var dmp = projects[index].DataManagementPlan; var dataRow = dataManagementPlansTable.Rows[index]; Assert.That(dataRow["ExistingDataAccessTypes"], Is.EqualTo(dmp.ExistingDataDetail.ExistingDataAccessTypes.ToString())); Assert.That(dataRow["ExistingDataOwner"], Is.EqualTo(dmp.ExistingDataDetail.ExistingDataOwner)); Assert.That(dataRow["InstitutionalOtherTypeDescription"], Is.EqualTo(dmp.DataStorage.InstitutionalOtherTypeDescription)); Assert.That(dataRow["DataRetentionLocations"], Is.EqualTo(dmp.DataRetention.DataRetentionLocations.ToString())); Assert.That(dataRow["VersionControl"], Is.EqualTo(dmp.DataStorage.VersionControl.ToString())); Assert.That(dataRow["EthicRequiresClearance"], Is.EqualTo(dmp.Ethic.EthicRequiresClearance)); Assert.That(dataRow["ConfidentialityComments"], Is.EqualTo(dmp.Confidentiality.ConfidentialityComments)); Assert.That(dataRow["RelationshipBetweenExistingAndNewData"], Is.EqualTo(dmp.DataRelationshipDetail.RelationshipBetweenExistingAndNewData.ToString())); Assert.That(dataRow["DataSharingAvailabilityDate"], Is.EqualTo(dmp.DataSharing.DataSharingAvailabilityDate)); var parties = dataRow["AccessRoles"].ToString().Split('%'); Assert.That(parties.Length, Is.EqualTo(5)); } }
private Project SetUpFullProjectWithAuthentication(string userId = "XX12345") { CreateUser(userId); var dmp = Builder <DataManagementPlan> .CreateNew() .With(o => o.ExistingDataDetail = Builder <ExistingDataDetail> .CreateNew() .With(q => q.UseExistingData = PickHelper.RandomBoolean()) .And(q => q.ExistingDataAccessTypes = PickHelper.RandomEnumsExcept(ExistingDataAccessTypes.None)) .Build()) .And(o => o.NewDataDetail = Builder <NewDataDetail> .CreateNew() .With(q => q.DataOwners = PickHelper.RandomEnumsExcept(DataOwners.None)) .Build()) .And(o => o.DataRelationshipDetail = Builder <DataRelationshipDetail> .CreateNew() .With(q => q.RelationshipBetweenExistingAndNewData = PickHelper.RandomEnumExcept(DataRelationship.None)) .Build()) .And(o => o.DataDocumentation = Builder <DataDocumentation> .CreateNew() .Build()) .And(o => o.Ethic = Builder <Ethic> .CreateNew() .With(q => q.EthicRequiresClearance = PickHelper.RandomBoolean()) .Build()) .And(o => o.Confidentiality = Builder <Confidentiality> .CreateNew() .With(q => q.IsSensitive = PickHelper.RandomBoolean()) .Build()) .And(o => o.DataStorage = Builder <DataStorage> .CreateNew() .With(q => q.InstitutionalStorageTypes = PickHelper.RandomEnumExcept(InstitutionalStorageTypes.ProjectStorageSpace)) .And(q => q.ExternalStorageTypes = PickHelper.RandomEnumExcept(ExternalStorageTypes.None)) .And(q => q.PersonalStorageTypes = PickHelper.RandomEnumExcept(PersonalStorageTypes.None)) .And(q => q.MaxDataSize = PickHelper.RandomEnumExcept(MaxDataSize.None)) .And(q => q.VersionControl = PickHelper.RandomEnumsExcept(VersionControl.None)) .Build()) .And(o => o.DataRetention = Builder <DataRetention> .CreateNew() .With(q => q.DataRetentionLocations = PickHelper.RandomEnumExcept(DataRetentionLocations.None)) .And(q => q.DataRetentionResponsibilities = PickHelper.RandomEnumExcept(DataResponsibilities.None)) .And(q => q.DataRetentionPeriod = PickHelper.RandomEnumExcept <DataRetentionPeriod>()) .And(q => q.DepositToRepository = PickHelper.RandomBoolean()) .Build()) .And(o => o.DataSharing = Builder <DataSharing> .CreateNew() .With(q => q.DataSharingAvailability = PickHelper.RandomEnumExcept <DataSharingAvailability>()) .And(q => q.DataSharingAvailabilityDate = DateTime.Today.AddYears(1)) .And(q => q.ShareAccess = PickHelper.RandomEnumExcept(ShareAccess.NoAccess)) .And(q => q.DataLicensingType = PickHelper.RandomEnumExcept <DataLicensingType>()) .Build()) .Build(); var socioEconomicObjectives = Builder <SocioEconomicObjective> .CreateListOfSize(5).Build(); var fieldsOfResearch = Builder <FieldOfResearch> .CreateListOfSize(6).Build(); var parties = Builder <Party> .CreateListOfSize(7) .TheFirst(1) .With(o => o.UserId = userId) .And(o => o.FirstName = Pick <string> .RandomItemFrom(new[] { "Alan", "Albert", "Adrian" })) .And(o => o.LastName = Pick <string> .RandomItemFrom(new[] { "Wallace", "Willis", "Waylan" })) .TheNext(3) .And(o => o.FirstName = Pick <string> .RandomItemFrom(new[] { "Bastian", "Bruce", "Brian", "Julian", "James", "Jones" })) .And(o => o.LastName = Pick <string> .RandomItemFrom(new[] { "Dallas", "Donga", "Dulles", "Frost", "Feller", "Frist" })) .TheNext(3) .With(o => o.UserId = null) .And(o => o.Organisation = null) .And(o => o.Email = null) .And(o => o.FirstName = Pick <string> .RandomItemFrom(new[] { "George", "Gerald", "Gordon", "Hally", "Harvey", "Harry" })) .And(o => o.LastName = Pick <string> .RandomItemFrom(new [] { "Pepper", "Prince", "Pulse", "Tommy", "Thors", "Tallis" })) .All() .With(o => o.FullName = string.Format("{0} {1}", o.FirstName, o.LastName)) .TheFirst(4) .With(o => o.Organisation = "Your University") .And(o => o.Email = string.Format("{0}.{1}@domain.edu.au", o.FirstName, o.LastName)) .Build(); var project = Builder <Project> .CreateNew() .With(o => o.DataManagementPlan = dmp) .And(o => o.ProvisioningStatus = PickHelper.RandomEnumExcept <ProvisioningStatus>()) .And(o => o.Status = PickHelper.RandomEnumExcept(ProjectStatus.Completed)) .And(o => o.SourceProjectType = SourceProjectType.DMP) .And(o => o.StartDate = DateTime.Today.AddMonths(-3)) .And(o => o.EndDate = DateTime.Today.AddMonths(9)) .Do(o => { o.Parties.AddRange(Builder <ProjectParty> .CreateListOfSize(parties.Count) .All() .With(q => q.Party = parties[q.Id - 1]) .TheFirst(1) .With(q => q.Relationship = ProjectRelationship.PrincipalInvestigator) .And(q => q.Role = AccessRole.Owners) .TheNext(3) .With(q => q.Relationship = Pick <ProjectRelationship> .RandomItemFrom(new[] { ProjectRelationship.Student, ProjectRelationship.SupportStaff, ProjectRelationship.Investigator, ProjectRelationship.PartnerInvestigator })) .And(q => q.Role = Pick <AccessRole> .RandomItemFrom(new[] { AccessRole.Members, AccessRole.Visitors })) .TheNext(3) .With(q => q.Relationship = ProjectRelationship.ExternalResearcher) .And(q => q.Role = Pick <AccessRole> .RandomItemFrom(new[] { AccessRole.Members, AccessRole.Visitors })) .Build() ); o.SocioEconomicObjectives.AddRange(Builder <ProjectSocioEconomicObjective> .CreateListOfSize(socioEconomicObjectives.Count) .All() .With(q => q.Code = socioEconomicObjectives[q.Id - 1]) .Build()); o.FieldsOfResearch.AddRange(Builder <ProjectFieldOfResearch> .CreateListOfSize(fieldsOfResearch.Count) .All() .With(q => q.Code = fieldsOfResearch[q.Id = 1]) .Build()); o.Funders.AddRange(Builder <ProjectFunder> .CreateListOfSize(2) .TheFirst(1) .With(q => q.Funder = Funder.ARC) .TheLast(1) .With(q => q.Funder = Funder.NMHRC) .All() .With(q => q.GrantNumber = Pick <string> .RandomItemFrom(new[] { "ABC123", "DEF456", "GHI789" })) .Build()); }).Build(); project.Parties.Do(o => o.Project = project); _projectRepository.Get(Arg.Is(project.Id)).Returns(project); return(project); }
public void Update_the_project_entity_when_saving_at_step5() { const int step = 5; _form["stepAction"] = "Save and Next"; var project = SetUpFullProjectWithAuthentication(); var dmp = project.DataManagementPlan; var dataRetention = Builder <DataRetentionViewModel> .CreateNew() .With(o => o.DataRetentionLocations = PickHelper.RandomEnumsExcept(DataRetentionLocations.None)) .And(o => o.DataRetentionLocationsDescription = "Updated Locations Description") .And(o => o.DataRetentionPeriod = PickHelper.RandomEnumExcept(dmp.DataRetention.DataRetentionPeriod)) .And(o => o.DataRetentionResponsibilities = PickHelper.RandomEnumsExcept(DataResponsibilities.None)) .And(o => o.DataRetentionResponsibilitiesDescription = "Updated Responsibilities Description") .And(o => o.DepositToRepository = !project.DataManagementPlan.DataRetention.DepositToRepository) .Build(); var dataSharing = Builder <DataSharingViewModel> .CreateNew() .With(o => o.DataSharingAvailability = PickHelper.RandomEnumExcept(dmp.DataSharing.DataSharingAvailability)) .And(o => o.DataSharingAvailabilityDate = DateTime.Today) .And(o => o.DataLicensingType = PickHelper.RandomEnumExcept(dmp.DataSharing.DataLicensingType)) .And(o => o.ReuseByOrganisations = "Updated Reuse By Organisations") .And(o => o.ShareAccess = PickHelper.RandomEnumExcept(ShareAccess.NoAccess, dmp.DataSharing.ShareAccess)) .And(o => o.ShareAccessDescription = "Updated Share Access Description") .Build(); var vm = Builder <DataManagementPlanViewModel> .CreateNew() .With(o => o.Id = dmp.Id) .And(o => o.ProjectId = project.Id) .And(o => o.ProjectTitle = project.Title) .And(o => o.DataRetention = dataRetention) .And(o => o.DataSharing = dataSharing) .And(o => o.Step = step) .Build(); string actionName; switch (project.ProvisioningStatus) { case ProvisioningStatus.NotStarted: actionName = "Review"; break; case ProvisioningStatus.Pending: actionName = "Pending"; break; case ProvisioningStatus.Provisioned: actionName = "Republish"; break; default: throw new InvalidOperationException("Unknown provisioning status"); } Console.WriteLine("actionName: {0}", actionName); var methodInfo = typeof(ConfirmController).GetMethod(actionName, new[] { typeof(int) }); Assert.That(methodInfo, Is.Not.Null); _controller.WithCallTo(x => x.Confirm(vm)).ShouldRedirectTo <ConfirmController>(methodInfo); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.DataRetention.DataRetentionLocations == dataRetention.DataRetentionLocations)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.DataRetention.DataRetentionLocationsDescription == dataRetention.DataRetentionLocationsDescription)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.DataRetention.DataRetentionPeriod == dataRetention.DataRetentionPeriod)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.DataRetention.DataRetentionResponsibilities == dataRetention.DataRetentionResponsibilities)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.DataRetention.DataRetentionResponsibilitiesDescription == dataRetention.DataRetentionResponsibilitiesDescription)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.DataRetention.DepositToRepository == dataRetention.DepositToRepository)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.DataSharing.DataSharingAvailability == dataSharing.DataSharingAvailability)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.DataSharing.DataSharingAvailabilityDate == dataSharing.DataSharingAvailabilityDate)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.DataSharing.DataLicensingType == dataSharing.DataLicensingType)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.DataSharing.ReuseByOrganisations == dataSharing.ReuseByOrganisations)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.DataSharing.ShareAccess == dataSharing.ShareAccess)); _projectRepository.Received().Save(Arg.Is <Project>(o => o.DataManagementPlan.DataSharing.ShareAccessDescription == dataSharing.ShareAccessDescription)); }