Exemple #1
0
 private TopicService SetupTopicService(
     ContentDbContext contentContext       = null,
     StatisticsDbContext statisticsContext = null,
     PersistenceHelper <ContentDbContext> persistenceHelper = null,
     IMapper mapper           = null,
     IUserService userService = null,
     IReleaseSubjectRepository releaseSubjectRepository = null,
     IReleaseDataFileService releaseDataFileService     = null,
     IReleaseFileService releaseFileService             = null,
     IPublishingService publishingService   = null,
     IMethodologyService methodologyService = null)
 {
     return(new TopicService(
                Mock.Of <IConfiguration>(),
                contentContext ?? Mock.Of <ContentDbContext>(),
                statisticsContext ?? Mock.Of <StatisticsDbContext>(),
                persistenceHelper ?? MockUtils.MockPersistenceHelper <ContentDbContext, Topic>(_topic.Id, _topic).Object,
                mapper ?? AdminMapper(),
                userService ?? MockUtils.AlwaysTrueUserService().Object,
                releaseSubjectRepository ?? Mock.Of <IReleaseSubjectRepository>(),
                releaseDataFileService ?? Mock.Of <IReleaseDataFileService>(),
                releaseFileService ?? Mock.Of <IReleaseFileService>(),
                publishingService ?? Mock.Of <IPublishingService>(),
                methodologyService ?? Mock.Of <IMethodologyService>(),
                Mock.Of <IBlobCacheService>()
                ));
 }
Exemple #2
0
 internal static ImportStatusBauService BuildImportStatusBauService(
     IUserService userService          = null,
     ContentDbContext contentDbContext = null)
 {
     return(new ImportStatusBauService(
                userService ?? MockUtils.AlwaysTrueUserService().Object,
                contentDbContext ?? new Mock <ContentDbContext>().Object
                ));
 }
        private Mock <IUserService> UserServiceMock()
        {
            var userService = MockUtils.AlwaysTrueUserService();

            userService
            .Setup(s => s.GetUserId())
            .Returns(_userId);

            return(userService);
        }
 private static DataBlockMigrationService SetupService(
     ContentDbContext contentDbContext,
     IUserService?userService = null)
 {
     return(new DataBlockMigrationService(
                contentDbContext,
                userService ?? MockUtils.AlwaysTrueUserService().Object,
                Mock.Of <ILogger <DataBlockMigrationService> >()
                ));
 }
        public async void UpdateLegacyRelease()
        {
            var id            = Guid.NewGuid();
            var publicationId = Guid.NewGuid();

            using (var context = InMemoryApplicationDbContext())
            {
                context.Add(new Publication
                {
                    Id             = publicationId,
                    LegacyReleases = new List <LegacyRelease>
                    {
                        new LegacyRelease
                        {
                            Id          = id,
                            Description = "Test description",
                            Url         = "http://test.com",
                            Order       = 2,
                        },
                    }
                });

                context.SaveChanges();

                var legacyReleaseService = new LegacyReleaseService(
                    context,
                    AdminMapper(),
                    MockUtils.AlwaysTrueUserService().Object,
                    new PersistenceHelper <ContentDbContext>(context)
                    );

                // Service method under test
                var result = await legacyReleaseService.UpdateLegacyRelease(
                    id,
                    new UpdateLegacyReleaseViewModel()
                {
                    Description   = "Updated test description",
                    Url           = "http://updated-test.com",
                    Order         = 1,
                    PublicationId = publicationId,
                });

                Assert.Equal("Updated test description", result.Right.Description);
                Assert.Equal("http://updated-test.com", result.Right.Url);
                Assert.Equal(1, result.Right.Order);
                Assert.Equal(publicationId, result.Right.PublicationId);

                var savedLegacyRelease = context.LegacyReleases.Single(release => release.Id == result.Right.Id);

                Assert.Equal("Updated test description", savedLegacyRelease.Description);
                Assert.Equal("http://updated-test.com", savedLegacyRelease.Url);
                Assert.Equal(1, savedLegacyRelease.Order);
                Assert.Equal(publicationId, savedLegacyRelease.PublicationId);
            }
        }
Exemple #6
0
 private static PublishingService BuildPublishingService(ContentDbContext contentDbContext,
                                                         IStorageQueueService storageQueueService = null,
                                                         IUserService userService           = null,
                                                         ILogger <PublishingService> logger = null)
 {
     return(new PublishingService(
                new PersistenceHelper <ContentDbContext>(contentDbContext),
                storageQueueService ?? new Mock <IStorageQueueService>().Object,
                userService ?? MockUtils.AlwaysTrueUserService().Object,
                logger ?? new Mock <ILogger <PublishingService> >().Object));
 }
        private TableBuilderController BuildTableBuilderController(
            ITableBuilderService tableBuilderService = null,
            IPersistenceHelper <ContentDbContext> contentPersistenceHelper = null,
            IUserService userService = null)

        {
            return(new TableBuilderController(
                       tableBuilderService ?? new Mock <ITableBuilderService>().Object,
                       contentPersistenceHelper ?? MockUtils.MockPersistenceHelper <ContentDbContext>().Object,
                       userService ?? MockUtils.AlwaysTrueUserService().Object
                       ));
        }
Exemple #8
0
 private static ReleasePermissionService SetupReleasePermissionService(
     ContentDbContext contentDbContext,
     IUserService?userService = null)
 {
     return(new(
                contentDbContext,
                new PersistenceHelper <ContentDbContext>(contentDbContext),
                new UserReleaseRoleRepository(contentDbContext),
                new UserReleaseInviteRepository(contentDbContext),
                userService ?? MockUtils.AlwaysTrueUserService(_userId).Object
                ));
 }
Exemple #9
0
 private static MethodologyContentService SetupMethodologyContentService(
     ContentDbContext contentDbContext,
     IPersistenceHelper <ContentDbContext>?contentPersistenceHelper = null,
     IUserService?userService = null)
 {
     return(new(
                contentDbContext,
                contentPersistenceHelper ?? new PersistenceHelper <ContentDbContext>(contentDbContext),
                userService ?? MockUtils.AlwaysTrueUserService().Object,
                AdminMapper()
                ));
 }
 private static CommentService SetupCommentService(
     ContentDbContext contentDbContext,
     IPersistenceHelper <ContentDbContext>?persistenceHelper = null,
     IUserService?userService = null,
     Guid?userId = null)
 {
     return(new CommentService(
                contentDbContext,
                persistenceHelper ?? new PersistenceHelper <ContentDbContext>(contentDbContext),
                userService ?? MockUtils.AlwaysTrueUserService(userId).Object,
                AdminMapper()
                ));
 }
 private static DataImportService BuildDataImportService(
     ContentDbContext contentDbContext,
     IDataImportRepository dataImportRepository   = null,
     IReleaseFileRepository releaseFileRepository = null,
     IStorageQueueService queueService            = null,
     IUserService userService = null)
 {
     return(new DataImportService(
                contentDbContext,
                dataImportRepository ?? new DataImportRepository(contentDbContext),
                releaseFileRepository ?? new ReleaseFileRepository(contentDbContext),
                queueService ?? new Mock <IStorageQueueService>().Object,
                userService ?? MockUtils.AlwaysTrueUserService().Object));
 }
Exemple #12
0
 private static ContentService SetupContentService(
     ContentDbContext contentDbContext,
     IPersistenceHelper <ContentDbContext> persistenceHelper          = null,
     IReleaseContentSectionRepository releaseContentSectionRepository = null,
     IUserService userService = null)
 {
     return(new ContentService(
                contentDbContext,
                persistenceHelper ?? new PersistenceHelper <ContentDbContext>(contentDbContext),
                releaseContentSectionRepository ?? new ReleaseContentSectionRepository(contentDbContext),
                userService ?? MockUtils.AlwaysTrueUserService().Object,
                AdminMapper()
                ));
 }
 private static DataBlockService BuildDataBlockService(
     ContentDbContext contentDbContext,
     IMapper mapper = null,
     IPersistenceHelper <ContentDbContext> persistenceHelper = null,
     IUserService userService = null,
     IReleaseFileService releaseFileService = null)
 {
     return(new DataBlockService(
                contentDbContext,
                mapper ?? MapperUtils.AdminMapper(),
                persistenceHelper ?? new PersistenceHelper <ContentDbContext>(contentDbContext),
                userService ?? MockUtils.AlwaysTrueUserService().Object,
                releaseFileService ?? new Mock <IReleaseFileService>().Object
                ));
 }
Exemple #14
0
 private static ReleaseMetaService BuildReleaseMetaService(
     ContentDbContext contentDbContext = null,
     IPersistenceHelper <ContentDbContext> persistenceHelper = null,
     StatisticsDbContext statisticsDbContext = null,
     IUserService userService = null,
     IImportStatusService importStatusService = null)
 {
     return(new ReleaseMetaService(
                contentDbContext ?? new Mock <ContentDbContext>().Object,
                persistenceHelper ?? new PersistenceHelper <ContentDbContext>(contentDbContext),
                statisticsDbContext ?? new Mock <StatisticsDbContext>().Object,
                userService ?? MockUtils.AlwaysTrueUserService().Object,
                importStatusService ?? new Mock <IImportStatusService>().Object
                ));
 }
        public async void CreateLegacyRelease_WithExisting()
        {
            var publicationId = Guid.NewGuid();

            using (var context = InMemoryApplicationDbContext())
            {
                context.Add(new Publication
                {
                    Id             = publicationId,
                    LegacyReleases = new List <LegacyRelease>
                    {
                        new LegacyRelease
                        {
                            Id            = Guid.NewGuid(),
                            Description   = "Test description 1",
                            Url           = "http://test1.com",
                            Order         = 1,
                            PublicationId = publicationId,
                        }
                    }
                });

                context.SaveChanges();

                var legacyReleaseService = new LegacyReleaseService(
                    context,
                    AdminMapper(),
                    MockUtils.AlwaysTrueUserService().Object,
                    new PersistenceHelper <ContentDbContext>(context)
                    );

                // Service method under test
                var result = await legacyReleaseService.CreateLegacyRelease(
                    new CreateLegacyReleaseViewModel()
                {
                    Description   = "Test description 2",
                    Url           = "http://test2.com",
                    PublicationId = publicationId
                });

                var legacyRelease = context.LegacyReleases.Single(release => release.Id == result.Right.Id);

                Assert.Equal("Test description 2", legacyRelease.Description);
                Assert.Equal("http://test2.com", legacyRelease.Url);
                Assert.Equal(2, legacyRelease.Order);
                Assert.Equal(publicationId, legacyRelease.PublicationId);
            }
        }
 private static ManageContentPageService SetupManageContentPageService(
     ContentDbContext contentDbContext,
     IPersistenceHelper <ContentDbContext> contentPersistenceHelper = null,
     IContentService contentService = null,
     IMapper mapper = null,
     IReleaseFileService releaseFileService = null,
     IUserService userService = null)
 {
     return(new ManageContentPageService(
                mapper ?? MapperUtils.AdminMapper(),
                releaseFileService ?? new Mock <IReleaseFileService>().Object,
                contentService ?? new Mock <IContentService>().Object,
                contentPersistenceHelper ?? new PersistenceHelper <ContentDbContext>(contentDbContext),
                userService ?? MockUtils.AlwaysTrueUserService().Object
                ));
 }
        public async Task GetPreReleaseSummaryViewModelAsync()
        {
            var contact = new Contact
            {
                Id        = Guid.NewGuid(),
                TeamEmail = "*****@*****.**"
            };

            var publication = new Publication
            {
                Id        = Guid.NewGuid(),
                Slug      = "prerelease-publication",
                Title     = "PreRelease Publication",
                ContactId = contact.Id
            };

            var release = new Release
            {
                Id                 = Guid.NewGuid(),
                ReleaseName        = "2020",
                Slug               = "2020",
                TimePeriodCoverage = TimeIdentifier.AutumnSpringTerm,
                PublicationId      = publication.Id
            };

            await using (var context = InMemoryApplicationDbContext("PreReleaseSummaryViewModel"))
            {
                context.Add(contact);
                context.Add(publication);
                context.Add(release);
                await context.SaveChangesAsync();
            }

            await using (var context = InMemoryApplicationDbContext("PreReleaseSummaryViewModel"))
            {
                var preReleaseSummaryService = new PreReleaseSummaryService(
                    new PersistenceHelper <ContentDbContext>(context),
                    MockUtils.AlwaysTrueUserService().Object);

                var viewModel = (await preReleaseSummaryService.GetPreReleaseSummaryViewModelAsync(release.Id)).Right;
                Assert.Equal(contact.TeamEmail, viewModel.ContactEmail);
                Assert.Equal(publication.Slug, viewModel.PublicationSlug);
                Assert.Equal(publication.Title, viewModel.PublicationTitle);
                Assert.Equal(release.Title, viewModel.ReleaseTitle);
                Assert.Equal(release.Slug, viewModel.ReleaseSlug);
            }
        }
 private static MetaGuidanceService SetupMetaGuidanceService(
     ContentDbContext contentDbContext,
     StatisticsDbContext statisticsDbContext = null,
     IPersistenceHelper <ContentDbContext> contentPersistenceHelper = null,
     IMetaGuidanceSubjectService metaGuidanceSubjectService         = null,
     IUserService userService       = null,
     IFileRepository fileRepository = null)
 {
     return(new MetaGuidanceService(
                contentDbContext,
                contentPersistenceHelper ?? new PersistenceHelper <ContentDbContext>(contentDbContext),
                metaGuidanceSubjectService ?? new Mock <IMetaGuidanceSubjectService>().Object,
                statisticsDbContext ?? new Mock <StatisticsDbContext>().Object,
                userService ?? MockUtils.AlwaysTrueUserService().Object,
                fileRepository ?? new FileRepository(contentDbContext)
                ));
 }
 private static ThemeService SetupThemeService(
     ContentDbContext context,
     IMapper mapper = null,
     IPersistenceHelper <ContentDbContext> persistenceHelper = null,
     IUserService userService             = null,
     ITopicService topicService           = null,
     IPublishingService publishingService = null)
 {
     return(new ThemeService(
                context,
                mapper ?? AdminMapper(),
                persistenceHelper ?? new PersistenceHelper <ContentDbContext>(context),
                userService ?? MockUtils.AlwaysTrueUserService().Object,
                topicService ?? new Mock <ITopicService>().Object,
                publishingService ?? new Mock <IPublishingService>().Object
                ));
 }
Exemple #20
0
 private static ReleaseService BuildReleaseService(
     ContentDbContext contentDbContext,
     IPersistenceHelper <ContentDbContext>?persistenceHelper = null,
     StatisticsDbContext?statisticsDbContext = null,
     IUserService?userService = null,
     IDataGuidanceSubjectService?dataGuidanceSubjectService = null,
     ITimePeriodService?timePeriodService           = null,
     IReleaseService.IBlobInfoGetter?fileSizeGetter = null)
 {
     return(new ReleaseService(
                contentDbContext,
                persistenceHelper ?? new PersistenceHelper <ContentDbContext>(contentDbContext),
                statisticsDbContext ?? Mock.Of <StatisticsDbContext>(),
                userService ?? MockUtils.AlwaysTrueUserService().Object,
                dataGuidanceSubjectService ?? Mock.Of <IDataGuidanceSubjectService>(),
                timePeriodService ?? Mock.Of <ITimePeriodService>(),
                fileSizeGetter ?? Mock.Of <IReleaseService.IBlobInfoGetter>()
                ));
 }
Exemple #21
0
 private ReleaseChecklistService BuildReleaseChecklistService(
     IPersistenceHelper <ContentDbContext> persistenceHelper = null,
     ITableStorageService tableStorageService = null,
     IUserService userService = null,
     IMetaGuidanceService metaGuidanceService = null,
     IFileRepository fileRepository           = null,
     IFootnoteRepository footnoteRepository   = null,
     IDataBlockService dataBlockService       = null)
 {
     return(new ReleaseChecklistService(
                persistenceHelper ?? DefaultPersistenceHelperMock().Object,
                tableStorageService ?? new Mock <ITableStorageService>().Object,
                userService ?? MockUtils.AlwaysTrueUserService().Object,
                metaGuidanceService ?? new Mock <IMetaGuidanceService>().Object,
                fileRepository ?? new Mock <IFileRepository>().Object,
                footnoteRepository ?? new Mock <IFootnoteRepository>().Object,
                dataBlockService ?? new Mock <IDataBlockService>().Object
                ));
 }
Exemple #22
0
 private ReleaseChecklistService BuildReleaseChecklistService(
     ContentDbContext contentDbContext,
     ITableStorageService tableStorageService = null,
     IUserService userService = null,
     IMetaGuidanceService metaGuidanceService = null,
     IFileRepository fileRepository           = null,
     IFootnoteRepository footnoteRepository   = null,
     IDataBlockService dataBlockService       = null)
 {
     return(new ReleaseChecklistService(
                new PersistenceHelper <ContentDbContext>(contentDbContext),
                tableStorageService ?? MockTableStorageService(new List <DatafileImport>()).Object,
                userService ?? MockUtils.AlwaysTrueUserService().Object,
                metaGuidanceService ?? new Mock <IMetaGuidanceService>().Object,
                fileRepository ?? new Mock <IFileRepository>().Object,
                footnoteRepository ?? new Mock <IFootnoteRepository>().Object,
                dataBlockService ?? new Mock <IDataBlockService>().Object
                ));
 }
        public async void DeleteLegacyRelease()
        {
            var id            = Guid.NewGuid();
            var publicationId = Guid.NewGuid();

            using (var context = InMemoryApplicationDbContext())
            {
                context.Add(new Publication
                {
                    Id             = publicationId,
                    LegacyReleases = new List <LegacyRelease>
                    {
                        new LegacyRelease
                        {
                            Id          = id,
                            Description = "Test description",
                            Url         = "http://test.com",
                            Order       = 2,
                        },
                    }
                });

                context.SaveChanges();

                var legacyReleaseService = new LegacyReleaseService(
                    context,
                    AdminMapper(),
                    MockUtils.AlwaysTrueUserService().Object,
                    new PersistenceHelper <ContentDbContext>(context)
                    );

                // Service method under test
                var result = await legacyReleaseService.DeleteLegacyRelease(id);

                Assert.Empty(context.LegacyReleases);
                Assert.Empty(
                    context.Publications
                    .Single(publication => publication.Id == publicationId)
                    .LegacyReleases
                    );
            }
        }
        private FootnoteService SetupFootnoteService(
            StatisticsDbContext statisticsDbContext,
            ContentDbContext contentDbContext = null,
            IPersistenceHelper <ContentDbContext> contentPersistenceHelper = null,
            IUserService userService = null,
            IFootnoteRepository footnoteRepository = null,
            IPersistenceHelper <StatisticsDbContext> statisticsPersistenceHelper = null,
            IGuidGenerator guidGenerator = null)
        {
            var contentContext = contentDbContext ?? new Mock <ContentDbContext>().Object;

            return(new FootnoteService(
                       statisticsDbContext,
                       contentPersistenceHelper ?? new PersistenceHelper <ContentDbContext>(contentContext),
                       userService ?? MockUtils.AlwaysTrueUserService().Object,
                       footnoteRepository ?? new FootnoteRepository(statisticsDbContext),
                       statisticsPersistenceHelper ?? new PersistenceHelper <StatisticsDbContext>(statisticsDbContext),
                       guidGenerator ?? new SequentialGuidGenerator()
                       ));
        }
        private ReleaseImageService SetupReleaseImageService(
            ContentDbContext contentDbContext,
            IPersistenceHelper <ContentDbContext> contentPersistenceHelper = null,
            IBlobStorageService blobStorageService = null,
            IFileUploadsValidatorService fileUploadsValidatorService = null,
            IReleaseFileRepository releaseFileRepository             = null,
            IUserService userService = null)
        {
            contentDbContext.Users.Add(_user);
            contentDbContext.SaveChanges();

            return(new ReleaseImageService(
                       contentDbContext,
                       contentPersistenceHelper ?? new PersistenceHelper <ContentDbContext>(contentDbContext),
                       blobStorageService ?? new Mock <IBlobStorageService>().Object,
                       fileUploadsValidatorService ?? new Mock <IFileUploadsValidatorService>().Object,
                       releaseFileRepository ?? new ReleaseFileRepository(contentDbContext),
                       userService ?? MockUtils.AlwaysTrueUserService(_user.Id).Object
                       ));
        }
Exemple #26
0
 private TableBuilderService BuildTableBuilderService(
     StatisticsDbContext statisticsDbContext,
     IObservationService observationService = null,
     IPersistenceHelper <StatisticsDbContext> statisticsPersistenceHelper = null,
     IResultSubjectMetaService resultSubjectMetaService = null,
     ISubjectService subjectService = null,
     IUserService userService       = null,
     IResultBuilder <Observation, ObservationViewModel> resultBuilder = null,
     IReleaseService releaseService = null)
 {
     return(new TableBuilderService(
                observationService ?? new Mock <IObservationService>().Object,
                statisticsPersistenceHelper ?? new PersistenceHelper <StatisticsDbContext>(statisticsDbContext),
                resultSubjectMetaService ?? new Mock <IResultSubjectMetaService>().Object,
                subjectService ?? new Mock <ISubjectService>().Object,
                userService ?? MockUtils.AlwaysTrueUserService().Object,
                resultBuilder ?? new ResultBuilder(DataServiceMapperUtils.DataServiceMapper()),
                releaseService ?? new Mock <IReleaseService>().Object
                ));
 }
Exemple #27
0
 private PreReleaseUserService SetupPreReleaseUserService(
     ContentDbContext context,
     UsersAndRolesDbContext usersAndRolesDbContext = null,
     IConfiguration configuration         = null,
     IEmailService emailService           = null,
     IPreReleaseService preReleaseService = null,
     IPersistenceHelper <ContentDbContext> persistenceHelper = null,
     IUserService userService = null,
     IHttpContextAccessor httpContextAccessor = null)
 {
     return(new PreReleaseUserService(
                context,
                usersAndRolesDbContext,
                configuration ?? DefaultConfigurationMock().Object,
                emailService ?? new Mock <IEmailService>().Object,
                preReleaseService ?? new Mock <IPreReleaseService>().Object,
                persistenceHelper ?? new PersistenceHelper <ContentDbContext>(context),
                userService ?? MockUtils.AlwaysTrueUserService().Object,
                httpContextAccessor ?? DefaultHttpContextAccessorMock().Object
                ));
 }
 private static ReleaseChecklistService BuildReleaseChecklistService(
     ContentDbContext contentDbContext,
     IDataImportService dataImportService                       = null,
     IUserService userService                                   = null,
     IDataGuidanceService dataGuidanceService                   = null,
     IReleaseDataFileRepository releaseDataFileRepository       = null,
     IMethodologyVersionRepository methodologyVersionRepository = null,
     IFootnoteRepository footnoteRepository                     = null,
     IDataBlockService dataBlockService                         = null)
 {
     return(new(
                contentDbContext,
                new PersistenceHelper <ContentDbContext>(contentDbContext),
                dataImportService ?? new Mock <IDataImportService>().Object,
                userService ?? MockUtils.AlwaysTrueUserService().Object,
                dataGuidanceService ?? new Mock <IDataGuidanceService>().Object,
                releaseDataFileRepository ?? new Mock <IReleaseDataFileRepository>().Object,
                methodologyVersionRepository ?? new Mock <IMethodologyVersionRepository>().Object,
                footnoteRepository ?? new Mock <IFootnoteRepository>().Object,
                dataBlockService ?? new Mock <IDataBlockService>().Object
                ));
 }
 private TopicService SetupTopicService(
     ContentDbContext contentContext       = null,
     StatisticsDbContext statisticsContext = null,
     PersistenceHelper <ContentDbContext> persistenceHelper = null,
     IMapper mapper           = null,
     IUserService userService = null,
     IReleaseSubjectService releaseSubjectService   = null,
     IReleaseDataFileService releaseDataFileService = null,
     IReleaseFileService releaseFileService         = null,
     IPublishingService publishingService           = null)
 {
     return(new TopicService(
                contentContext ?? new Mock <ContentDbContext>().Object,
                statisticsContext ?? new Mock <StatisticsDbContext>().Object,
                persistenceHelper ?? MockUtils.MockPersistenceHelper <ContentDbContext, Topic>(_topic.Id, _topic).Object,
                mapper ?? AdminMapper(),
                userService ?? MockUtils.AlwaysTrueUserService().Object,
                releaseSubjectService ?? new Mock <IReleaseSubjectService>().Object,
                releaseDataFileService ?? new Mock <IReleaseDataFileService>().Object,
                releaseFileService ?? new Mock <IReleaseFileService>().Object,
                publishingService ?? new Mock <IPublishingService>().Object
                ));
 }
        public async void DeleteLegacyRelease_ReordersWithExisting()
        {
            var id            = Guid.NewGuid();
            var publicationId = Guid.NewGuid();

            using (var context = InMemoryApplicationDbContext())
            {
                context.Add(new Publication
                {
                    Id             = publicationId,
                    LegacyReleases = new List <LegacyRelease>
                    {
                        new LegacyRelease
                        {
                            Id          = id,
                            Description = "Test description 1",
                            Url         = "http://test1.com",
                            Order       = 1,
                        },
                        new LegacyRelease
                        {
                            Id          = Guid.NewGuid(),
                            Description = "Test description 2",
                            Url         = "http://test2.com",
                            Order       = 2,
                        },
                        new LegacyRelease
                        {
                            Id          = Guid.NewGuid(),
                            Description = "Test description 3",
                            Url         = "http://test3.com",
                            Order       = 3,
                        }
                    }
                });

                context.SaveChanges();

                var legacyReleaseService = new LegacyReleaseService(
                    context,
                    AdminMapper(),
                    MockUtils.AlwaysTrueUserService().Object,
                    new PersistenceHelper <ContentDbContext>(context)
                    );

                // Service method under test
                var result = await legacyReleaseService.DeleteLegacyRelease(id);

                var legacyReleases = context.LegacyReleases
                                     .OrderBy(release => release.Order)
                                     .ToList();

                Assert.Equal(2, legacyReleases.Count);
                Assert.Equal(2,
                             context.Publications
                             .Single(publication => publication.Id == publicationId)
                             .LegacyReleases
                             .Count
                             );

                Assert.Equal("Test description 2", legacyReleases[0].Description);
                Assert.Equal(1, legacyReleases[0].Order);

                Assert.Equal("Test description 3", legacyReleases[1].Description);
                Assert.Equal(2, legacyReleases[1].Order);
            }
        }