public void GetTitle_AlternativeTitleSet() { var methodology = new MethodologyVersion { Methodology = new Methodology { OwningPublicationTitle = "Owning Publication Title" }, AlternativeTitle = "Alternative Title" }; Assert.Equal(methodology.AlternativeTitle, methodology.Title); }
private async Task <Either <ActionResult, MethodologyVersion> > HydrateMethodologyVersionForAmendment( MethodologyVersion methodologyVersion) { await _context .Entry(methodologyVersion) .Collection(m => m.Notes) .LoadAsync(); await _context .Entry(methodologyVersion) .Reference(m => m.Methodology) .LoadAsync(); return(methodologyVersion); }
public async Task Stream_BlobDoesNotExist() { var methodologyVersion = new MethodologyVersion(); var methodologyFile = new MethodologyFile { MethodologyVersion = methodologyVersion, File = new File { RootPath = Guid.NewGuid(), Filename = "image.png", Type = Image } }; var contentDbContextId = Guid.NewGuid().ToString(); await using (var contentDbContext = InMemoryContentDbContext(contentDbContextId)) { await contentDbContext.MethodologyVersions.AddAsync(methodologyVersion); await contentDbContext.MethodologyFiles.AddAsync(methodologyFile); await contentDbContext.SaveChangesAsync(); } var blobStorageService = new Mock <IBlobStorageService>(MockBehavior.Strict); blobStorageService.Setup(mock => mock.CheckBlobExists(PublicMethodologyFiles, It.IsAny <string>())) .ReturnsAsync(false); await using (var contentDbContext = InMemoryContentDbContext(contentDbContextId)) { var service = SetupMethodologyImageService(contentDbContext: contentDbContext, blobStorageService: blobStorageService.Object); var result = await service.Stream(methodologyVersion.Id, methodologyFile.File.Id); result.AssertNotFound(); blobStorageService.Verify( mock => mock.CheckBlobExists(PublicMethodologyFiles, methodologyFile.Path()), Times.Once()); } MockUtils.VerifyAllMocks(blobStorageService); }
public async Task PublishMethodologyFilesIfApplicableForRelease_NotFirstPublicReleaseHasMethodologyScheduledImmediately() { var release = new Release { Id = Guid.NewGuid(), PublicationId = Guid.NewGuid() }; var methodologyVersion = new MethodologyVersion { Id = Guid.NewGuid(), PublishingStrategy = Immediately, Status = Approved }; var methodologyService = new Mock <IMethodologyService>(MockBehavior.Strict); var publicBlobStorageService = new Mock <IBlobStorageService>(MockBehavior.Strict); var privateBlobStorageService = new Mock <IBlobStorageService>(MockBehavior.Strict); var publicationService = new Mock <IPublicationService>(MockBehavior.Strict); var releaseService = new Mock <IReleaseService>(MockBehavior.Strict); methodologyService.Setup(mock => mock.GetLatestByRelease(release.Id)) .ReturnsAsync(ListOf(methodologyVersion)); publicationService.Setup(mock => mock.IsPublicationPublished(release.PublicationId)) .ReturnsAsync(true); releaseService.Setup(mock => mock.Get(release.Id)) .ReturnsAsync(release); // No invocations on the storage services expected because the publication already has published releases. // Files for this methodology will be published independently of this release var service = BuildPublishingService(publicStorageConnectionString: PublicStorageConnectionString, methodologyService: methodologyService.Object, publicBlobStorageService: publicBlobStorageService.Object, privateBlobStorageService: privateBlobStorageService.Object, publicationService: publicationService.Object, releaseService: releaseService.Object); await service.PublishMethodologyFilesIfApplicableForRelease(release.Id); MockUtils.VerifyAllMocks(methodologyService, publicBlobStorageService, privateBlobStorageService, publicationService, releaseService); }
public void ScheduledForPublishingWithPublishedRelease_FalseWhenScheduledWithNonLiveRelease() { var nonLiveRelease = new Release { Id = Guid.NewGuid() }; var methodology = new MethodologyVersion { PublishingStrategy = WithRelease, ScheduledWithRelease = nonLiveRelease, ScheduledWithReleaseId = nonLiveRelease.Id }; Assert.False(methodology.ScheduledForPublishingWithPublishedRelease); }
public PermissionsSet Resolve( MethodologyVersion source, MyMethodologyVersionViewModel destination, PermissionsSet destMember, ResolutionContext context) { return(new PermissionsSet { CanApproveMethodology = CheckResult(_userService.CheckCanApproveMethodology(source)), CanUpdateMethodology = CheckResult(_userService.CheckCanUpdateMethodology(source)), CanDeleteMethodology = CheckResult(_userService.CheckCanDeleteMethodology(source)), CanMakeAmendmentOfMethodology = CheckResult(_userService.CheckCanMakeAmendmentOfMethodology(source)), CanMarkMethodologyAsDraft = CheckResult(_userService.CheckCanMarkMethodologyAsDraft(source)) }); }
private async Task <Either <ActionResult, MethodologyVersion> > UpdateStatus( MethodologyVersion methodologyVersionToUpdate, MethodologyApprovalUpdateRequest request) { if (!request.IsStatusUpdateForMethodology(methodologyVersionToUpdate)) { return(methodologyVersionToUpdate); } return(await _methodologyApprovalService .UpdateApprovalStatus(methodologyVersionToUpdate.Id, request) .OnSuccess(_ => _context .MethodologyVersions .Include(mv => mv.Methodology) .SingleAsync(mv => mv.Id == methodologyVersionToUpdate.Id))); }
public void ScheduledForPublishingWithRelease_TrueWhenPublishingStrategyIsWithRelease() { var release = new Release { Id = Guid.NewGuid() }; var methodology = new MethodologyVersion { PublishingStrategy = WithRelease, ScheduledWithReleaseId = release.Id, ScheduledWithRelease = release }; Assert.True(methodology.ScheduledForPublishingWithRelease); }
private Either <ActionResult, Tuple <MethodologyVersion, List <ContentSection> > > FindContentList( MethodologyVersion methodologyVersion, List <Guid> contentSectionIds) { if (ContentListContainsAllSectionIds(methodologyVersion.Content, contentSectionIds)) { return(TupleOf(methodologyVersion, methodologyVersion.Content)); } if (ContentListContainsAllSectionIds(methodologyVersion.Annexes, contentSectionIds)) { return(TupleOf(methodologyVersion, methodologyVersion.Annexes)); } return(new NotFoundResult()); }
public async Task UserWithCorrectClaimCanApproveNonPubliclyAccessibleDraftMethodology() { var methodologyVersion = new MethodologyVersion { Id = Guid.NewGuid(), MethodologyId = Guid.NewGuid(), Status = Draft }; await ForEachSecurityClaimAsync(async claim => { var( handler, methodologyRepository, methodologyVersionRepository, userReleaseRoleRepository ) = CreateHandlerAndDependencies(); methodologyVersionRepository.Setup(mock => mock.IsPubliclyAccessible(methodologyVersion.Id)) .ReturnsAsync(false); // Only the ApproveAllMethodologies claim should allow approving a Methodology var expectedToPassByClaimAlone = claim == ApproveAllMethodologies; if (!expectedToPassByClaimAlone) { methodologyRepository.Setup(s => s.GetOwningPublication(methodologyVersion.MethodologyId)) .ReturnsAsync(OwningPublication); userReleaseRoleRepository .Setup(s => s.IsUserApproverOnLatestRelease(UserId, OwningPublication.Id)) .ReturnsAsync(false); } var user = CreateClaimsPrincipal(UserId, claim); var authContext = CreateAuthorizationHandlerContext <ApproveSpecificMethodologyRequirement, MethodologyVersion> (user, methodologyVersion); await handler.HandleAsync(authContext); VerifyAllMocks(methodologyRepository, methodologyVersionRepository, userReleaseRoleRepository); Assert.Equal(expectedToPassByClaimAlone, authContext.HasSucceeded); }); }
public async Task PublishMethodologyFilesIfApplicableForRelease_ReleaseHasMethodologyScheduledWithOtherRelease() { var release = new Release { Id = Guid.NewGuid(), PublicationId = Guid.NewGuid() }; var methodologyVersion = new MethodologyVersion { Id = Guid.NewGuid(), PublishingStrategy = WithRelease, ScheduledWithReleaseId = Guid.NewGuid(), Status = Approved }; var methodologyService = new Mock <IMethodologyService>(MockBehavior.Strict); var publicBlobStorageService = new Mock <IBlobStorageService>(MockBehavior.Strict); var privateBlobStorageService = new Mock <IBlobStorageService>(MockBehavior.Strict); var publicationService = new Mock <IPublicationService>(MockBehavior.Strict); var releaseService = new Mock <IReleaseService>(MockBehavior.Strict); methodologyService.Setup(mock => mock.GetLatestByRelease(release.Id)) .ReturnsAsync(ListOf(methodologyVersion)); publicationService.Setup(mock => mock.IsPublicationPublished(release.PublicationId)) .ReturnsAsync(true); releaseService.Setup(mock => mock.Get(release.Id)) .ReturnsAsync(release); // No invocations on the storage services expected because the methodology is scheduled with another release var service = BuildPublishingService(methodologyService: methodologyService.Object, publicBlobStorageService: publicBlobStorageService.Object, privateBlobStorageService: privateBlobStorageService.Object, publicationService: publicationService.Object, releaseService: releaseService.Object); await service.PublishMethodologyFilesIfApplicableForRelease(release.Id); MockUtils.VerifyAllMocks(methodologyService, publicBlobStorageService, privateBlobStorageService, publicationService, releaseService); }
public async Task AddNote() { var methodologyVersion = new MethodologyVersion(); const string content = "Adding note"; var createdById = Guid.NewGuid(); var displayDate = DateTime.Today.ToUniversalTime(); var contentDbContextId = Guid.NewGuid().ToString(); await using (var contentDbContext = InMemoryContentDbContext(contentDbContextId)) { await contentDbContext.MethodologyVersions.AddAsync(methodologyVersion); await contentDbContext.SaveChangesAsync(); } await using (var contentDbContext = InMemoryContentDbContext(contentDbContextId)) { var service = BuildMethodologyNoteRepository(contentDbContext); var result = await service.AddNote( methodologyVersionId: methodologyVersion.Id, createdByUserId: createdById, content: content, displayDate: displayDate); Assert.NotNull(result); } await using (var contentDbContext = InMemoryContentDbContext(contentDbContextId)) { Assert.Single(contentDbContext.MethodologyNotes); var addedNote = await contentDbContext.MethodologyNotes.SingleAsync(n => n.MethodologyVersionId == methodologyVersion.Id); Assert.NotEqual(Guid.Empty, addedNote.Id); Assert.Equal(content, addedNote.Content); Assert.InRange(DateTime.UtcNow.Subtract(addedNote.Created).Milliseconds, 0, 1500); Assert.Equal(createdById, addedNote.CreatedById); Assert.Equal(displayDate, addedNote.DisplayDate); Assert.Equal(methodologyVersion.Id, addedNote.MethodologyVersionId); Assert.Null(addedNote.Updated); Assert.Null(addedNote.UpdatedById); } }
public async Task AddNote_NoDisplayDateDefaultsToToday() { var methodologyVersion = new MethodologyVersion(); var request = new MethodologyNoteAddRequest { Content = "Adding note", DisplayDate = null }; var today = DateTime.Today.ToUniversalTime(); var contentDbContextId = Guid.NewGuid().ToString(); await using (var contentDbContext = InMemoryApplicationDbContext(contentDbContextId)) { await contentDbContext.MethodologyVersions.AddAsync(methodologyVersion); await contentDbContext.SaveChangesAsync(); } await using (var contentDbContext = InMemoryApplicationDbContext(contentDbContextId)) { var service = SetupMethodologyNoteService(contentDbContext); var result = (await service.AddNote( methodologyVersionId: methodologyVersion.Id, request: request)).AssertRight(); Assert.NotEqual(Guid.Empty, result.Id); Assert.Equal(request.Content, result.Content); Assert.Equal(today, result.DisplayDate); } await using (var contentDbContext = InMemoryApplicationDbContext(contentDbContextId)) { Assert.Single(contentDbContext.MethodologyVersions); var addedNote = await contentDbContext.MethodologyNotes.SingleAsync(n => n.MethodologyVersionId == methodologyVersion.Id); Assert.Equal(request.Content, addedNote.Content); Assert.Equal(today, addedNote.DisplayDate); } }
public void ScheduledForPublishingWithPublishedRelease_TrueWhenScheduledWithLiveRelease() { var liveRelease = new Release { Id = Guid.NewGuid(), Published = DateTime.UtcNow }; var methodology = new MethodologyVersion { PublishingStrategy = WithRelease, ScheduledWithRelease = liveRelease, ScheduledWithReleaseId = liveRelease.Id }; Assert.True(methodology.ScheduledForPublishingWithPublishedRelease); }
private async Task <MethodologyVersionSummaryViewModel> BuildMethodologySummaryViewModel( MethodologyVersion methodologyVersion) { var loadedMethodology = _context.AssertEntityLoaded(methodologyVersion); await _context.Entry(loadedMethodology) .Reference(m => m.Methodology) .Query() .Include(m => m.Publications) .ThenInclude(p => p.Publication) .LoadAsync(); var publicationLinks = loadedMethodology.Methodology.Publications; var owningPublication = BuildPublicationViewModel(publicationLinks.Single(pm => pm.Owner)); var otherPublications = publicationLinks.Where(pm => !pm.Owner) .Select(BuildPublicationViewModel) .OrderBy(model => model.Title) .ToList(); var viewModel = _mapper.Map <MethodologyVersionSummaryViewModel>(loadedMethodology); viewModel.OwningPublication = owningPublication; viewModel.OtherPublications = otherPublications; if (loadedMethodology.ScheduledForPublishingWithRelease) { await _context.Entry(loadedMethodology) .Reference(m => m.ScheduledWithRelease) .LoadAsync(); if (loadedMethodology.ScheduledWithRelease != null) { await _context.Entry(loadedMethodology.ScheduledWithRelease) .Reference(r => r !.Publication) .LoadAsync(); var title = $"{loadedMethodology.ScheduledWithRelease.Publication.Title} - {loadedMethodology.ScheduledWithRelease.Title}"; viewModel.ScheduledWithRelease = new TitleAndIdViewModel( loadedMethodology.ScheduledWithRelease.Id, title); } } return(viewModel); }
public async Task SetPublishedDatesByPublication_PublishedMethodologyHasPublishedDateSet() { var publicationId = Guid.NewGuid(); var published = DateTime.UtcNow; var methodologyVersion = new MethodologyVersion { Published = null, PublishingStrategy = Immediately, Status = Approved, Version = 0 }; var contentDbContextId = Guid.NewGuid().ToString(); await using (var contentDbContext = InMemoryContentDbContext(contentDbContextId)) { await contentDbContext.MethodologyVersions.AddAsync(methodologyVersion); await contentDbContext.SaveChangesAsync(); } var methodologyVersionRepository = new Mock <IMethodologyVersionRepository>(MockBehavior.Strict); methodologyVersionRepository.Setup(mock => mock.GetLatestPublishedVersionByPublication(publicationId)) .ReturnsAsync(AsList(methodologyVersion)); await using (var contentDbContext = InMemoryContentDbContext(contentDbContextId)) { var service = SetupMethodologyService(contentDbContext, methodologyVersionRepository.Object); await service.SetPublishedDatesByPublication(publicationId, published); } await using (var contentDbContext = InMemoryContentDbContext(contentDbContextId)) { var actual = await contentDbContext.MethodologyVersions.FindAsync(methodologyVersion.Id); Assert.NotNull(actual); Assert.Equal(published, actual.Published); } MockUtils.VerifyAllMocks(methodologyVersionRepository); }
public void IsLatestVersionOfMethodology_TrueForSingleVersion() { var version = new MethodologyVersion { Id = Guid.NewGuid(), PreviousVersionId = null, PublishingStrategy = Immediately, Status = Draft, Version = 0 }; var methodology = new Methodology { Versions = AsList(version) }; Assert.True(methodology.IsLatestVersionOfMethodology(version.Id)); }
public void LatestVersion_SingleVersionIsLatest() { var version = new MethodologyVersion { Id = Guid.NewGuid(), PreviousVersionId = null, PublishingStrategy = Immediately, Status = Draft, Version = 0 }; var methodology = new Methodology { Versions = AsList(version) }; Assert.Equal(version, methodology.LatestVersion()); }
private async Task <Either <ActionResult, Unit> > CheckMethodologyCanDependOnRelease( MethodologyVersion methodologyVersion, MethodologyApprovalUpdateRequest request) { if (request.PublishingStrategy != WithRelease) { return(Unit.Instance); } if (!request.WithReleaseId.HasValue) { return(new NotFoundResult()); } // Check that this release exists, that it's not already published, and that it's using the methodology return(await _persistenceHelper .CheckEntityExists <Release>(request.WithReleaseId.Value) .OnSuccess <ActionResult, Release, Unit>(async release => { if (release.Live) { return ValidationActionResult(MethodologyCannotDependOnPublishedRelease); } await _context.Entry(methodologyVersion) .Reference(m => m.Methodology) .LoadAsync(); await _context.Entry(methodologyVersion.Methodology) .Collection(mp => mp.Publications) .LoadAsync(); var publicationIds = methodologyVersion.Methodology.Publications .Select(pm => pm.PublicationId) .ToList(); if (!publicationIds.Contains(release.PublicationId)) { return ValidationActionResult(MethodologyCannotDependOnRelease); } return Unit.Instance; })); }
private async Task <Either <ActionResult, MethodologyVersion> > UpdateStatus( MethodologyVersion methodologyVersionToUpdate, MethodologyApprovalUpdateRequest request) { if (!request.IsStatusUpdateForMethodology(methodologyVersionToUpdate)) { // Status unchanged return(methodologyVersionToUpdate); } return(await CheckCanUpdateStatus(methodologyVersionToUpdate, request.Status) .OnSuccessDo(methodology => CheckMethodologyCanDependOnRelease(methodology, request)) .OnSuccessDo(RemoveUnusedImages) .OnSuccess(async methodology => { methodology.Status = request.Status; methodology.PublishingStrategy = request.PublishingStrategy; methodology.ScheduledWithReleaseId = WithRelease == request.PublishingStrategy ? request.WithReleaseId : null; methodology.InternalReleaseNote = Approved == request.Status ? request.LatestInternalReleaseNote : null; methodology.Updated = DateTime.UtcNow; _context.MethodologyVersions.Update(methodology); if (await _methodologyVersionRepository.IsPubliclyAccessible(methodology.Id)) { methodology.Published = DateTime.UtcNow; await _publishingService.PublishMethodologyFiles(methodology.Id); // Invalidate the 'All Methodologies' cache item await _publicBlobCacheService.DeleteItem(new AllMethodologiesCacheKey()); } _context.MethodologyVersions.Update(methodology); await _context.SaveChangesAsync(); return methodology; })); }
private async Task <Either <ActionResult, MethodologyVersion> > UpdateDetails( MethodologyVersion methodologyVersionToUpdate, MethodologyUpdateRequest request) { if (!request.IsDetailUpdateForMethodology(methodologyVersionToUpdate)) { // Details unchanged return(methodologyVersionToUpdate); } return(await _userService.CheckCanUpdateMethodology(methodologyVersionToUpdate) // Check that the Methodology will have a unique slug. It is possible to have a clash in the case where // another Methodology has previously set its AlternativeTitle (and Slug) to something specific and then // this Methodology attempts to set its AlternativeTitle (and Slug) to the same value. Whilst an // unlikely scenario, it's entirely possible. .OnSuccessDo(methodologyVersion => ValidateMethodologySlugUniqueForUpdate(methodologyVersion.Id, request.Slug)) .OnSuccess(async methodologyVersion => { methodologyVersion.Updated = DateTime.UtcNow; if (request.Title != methodologyVersion.Title) { methodologyVersion.AlternativeTitle = request.Title != methodologyVersion.Methodology.OwningPublicationTitle ? request.Title : null; // If we're updating a Methodology that is not an Amendment, it's not yet publicly // visible and so its Slug can be updated. At the point that a Methodology is publicly // visible and the only means of updating it is via Amendments, we will no longer allow its // Slug to change even though its AlternativeTitle can. if (!methodologyVersion.Amendment) { methodologyVersion.Methodology.Slug = request.Slug; } } await _context.SaveChangesAsync(); return methodologyVersion; })); }
public async Task PublishMethodologyFiles() { var methodologyVersion = new MethodologyVersion { Id = Guid.NewGuid() }; var logger = new Mock <ILogger <PublishingService> >(); var methodologyService = new Mock <IMethodologyService>(MockBehavior.Strict); var publicBlobStorageService = new Mock <IBlobStorageService>(MockBehavior.Strict); var privateBlobStorageService = new Mock <IBlobStorageService>(MockBehavior.Strict); methodologyService.Setup(mock => mock.Get(methodologyVersion.Id)) .ReturnsAsync(methodologyVersion); methodologyService.Setup(mock => mock.GetFiles(methodologyVersion.Id, Image)) .ReturnsAsync(new List <File>()); publicBlobStorageService.Setup(mock => mock.DeleteBlobs( PublicMethodologyFiles, $"{methodologyVersion.Id}/", null)) .Returns(Task.CompletedTask); privateBlobStorageService.Setup(mock => mock.CopyDirectory( PrivateMethodologyFiles, $"{methodologyVersion.Id}/", PublicMethodologyFiles, $"{methodologyVersion.Id}/", It.Is <IBlobStorageService.CopyDirectoryOptions>(options => options.DestinationConnectionString == PublicStorageConnectionString))) .ReturnsAsync(new List <BlobInfo>()); var service = BuildPublishingService(publicStorageConnectionString: PublicStorageConnectionString, methodologyService: methodologyService.Object, publicBlobStorageService: publicBlobStorageService.Object, privateBlobStorageService: privateBlobStorageService.Object, logger: logger.Object); await service.PublishMethodologyFiles(methodologyVersion.Id); MockUtils.VerifyAllMocks(methodologyService, publicBlobStorageService, privateBlobStorageService); }
private async Task <Either <ActionResult, IContentBlockViewModel> > AddContentBlockToContentSectionAndSave( int?order, ContentSection section, ContentBlock newContentBlock, MethodologyVersion methodologyVersion) { var orderForNewBlock = OrderValueForNewlyAddedContentBlock(order, section); section.Content .FindAll(contentBlock => contentBlock.Order >= orderForNewBlock) .ForEach(contentBlock => contentBlock.Order++); newContentBlock.Order = orderForNewBlock; section.Content.Add(newContentBlock); _context.MethodologyVersions.Update(methodologyVersion); await _context.SaveChangesAsync(); return(new Either <ActionResult, IContentBlockViewModel>(_mapper.Map <IContentBlockViewModel>(newContentBlock))); }
private async Task <Either <ActionResult, Unit> > LinkOriginalMethodologyFilesToAmendment( MethodologyVersion methodologyVersion) { var originalFiles = await _context .MethodologyFiles .AsQueryable() .Where(f => f.MethodologyVersionId == methodologyVersion.PreviousVersionId) .ToListAsync(); var fileCopies = originalFiles .Select(f => new MethodologyFile { FileId = f.FileId, MethodologyVersionId = methodologyVersion.Id }); await _context.AddRangeAsync(fileCopies); await _context.SaveChangesAsync(); return(Unit.Instance); }
public async Task PublishMethodologyFiles() { var methodologyVersion = new MethodologyVersion(); var contentDbContextId = Guid.NewGuid().ToString(); await using (var context = InMemoryApplicationDbContext(contentDbContextId)) { await context.MethodologyVersions.AddAsync(methodologyVersion); await context.SaveChangesAsync(); } var storageQueueService = new Mock <IStorageQueueService>(MockBehavior.Strict); storageQueueService.Setup( mock => mock.AddMessageAsync(PublishMethodologyFilesQueue, It.Is <PublishMethodologyFilesMessage>(message => message.MethodologyId == methodologyVersion.Id))) .Returns(Task.CompletedTask); await using (var context = InMemoryApplicationDbContext(contentDbContextId)) { var publishingService = BuildPublishingService(contentDbContext: context, storageQueueService: storageQueueService.Object); var result = await publishingService .PublishMethodologyFiles(methodologyVersion.Id); storageQueueService.Verify( mock => mock.AddMessageAsync(PublishMethodologyFilesQueue, It.Is <PublishMethodologyFilesMessage>(message => message.MethodologyId == methodologyVersion.Id)), Times.Once()); result.AssertRight(); } MockUtils.VerifyAllMocks(storageQueueService); }
public async Task AddNote() { var methodologyVersion = new MethodologyVersion { Id = Guid.NewGuid() }; await PolicyCheckBuilder <SecurityPolicies>() .SetupResourceCheckToFail(methodologyVersion, CanUpdateSpecificMethodology) .AssertForbidden( userService => { var service = SetupMethodologyNoteService( persistenceHelper: MockPersistenceHelper <ContentDbContext, MethodologyVersion>( methodologyVersion.Id, methodologyVersion).Object, userService: userService.Object); return(service.AddNote( methodologyVersion.Id, new MethodologyNoteAddRequest())); } ); }
private static void AssertMethodologyNoteAmendedCorrectly( MethodologyNote amendmentNote, MethodologyNote originalNote, MethodologyVersion amendment) { // Check the note has a new id. Assert.NotEqual(Guid.Empty, amendmentNote.Id); Assert.NotEqual(originalNote.Id, amendmentNote.Id); // Check the note has the amended methodology version Assert.Equal(amendment, amendmentNote.MethodologyVersion); Assert.Equal(amendment.Id, amendmentNote.MethodologyVersionId); // Check the other fields are the same Assert.Equal(originalNote.Content, amendmentNote.Content); Assert.Equal(originalNote.Created, amendmentNote.Created); Assert.Equal(originalNote.CreatedBy, amendmentNote.CreatedBy); Assert.Equal(originalNote.CreatedById, amendmentNote.CreatedById); Assert.Equal(originalNote.DisplayDate, amendmentNote.DisplayDate); Assert.Equal(originalNote.Updated, amendmentNote.Updated); Assert.Equal(originalNote.UpdatedBy, amendmentNote.UpdatedBy); Assert.Equal(originalNote.UpdatedById, amendmentNote.UpdatedById); }
public static Task <Either <ActionResult, MethodologyVersion> > CheckCanMakeAmendmentOfMethodology( this IUserService userService, MethodologyVersion methodologyVersion) { return(userService.CheckPolicy(methodologyVersion, SecurityPolicies.CanMakeAmendmentOfSpecificMethodology)); }
public static Task <Either <ActionResult, MethodologyVersion> > CheckCanMarkMethodologyAsDraft( this IUserService userService, MethodologyVersion methodologyVersion) { return(userService.CheckPolicy(methodologyVersion, SecurityPolicies.CanMarkSpecificMethodologyAsDraft)); }
public bool IsDetailUpdateForMethodology(MethodologyVersion methodologyVersion) { return(methodologyVersion.Title != Title); }