11
11
using GovUk . Education . ExploreEducationStatistics . Common . Services . Interfaces ;
12
12
using GovUk . Education . ExploreEducationStatistics . Common . Services . Interfaces . Security ;
13
13
using GovUk . Education . ExploreEducationStatistics . Common . Tests . Extensions ;
14
+ using GovUk . Education . ExploreEducationStatistics . Common . Tests . Fixtures ;
14
15
using GovUk . Education . ExploreEducationStatistics . Common . Tests . Utils ;
15
16
using GovUk . Education . ExploreEducationStatistics . Common . Utils ;
16
17
using GovUk . Education . ExploreEducationStatistics . Content . Model ;
17
18
using GovUk . Education . ExploreEducationStatistics . Content . Model . Database ;
18
19
using GovUk . Education . ExploreEducationStatistics . Content . Model . Extensions ;
20
+ using GovUk . Education . ExploreEducationStatistics . Content . Model . Tests . Fixtures ;
19
21
using GovUk . Education . ExploreEducationStatistics . Content . Services . Interfaces ;
20
22
using Moq ;
21
23
using Xunit ;
@@ -29,6 +31,7 @@ namespace GovUk.Education.ExploreEducationStatistics.Content.Services.Tests
29
31
{
30
32
public class ReleaseFileServiceTests : IDisposable
31
33
{
34
+ private readonly DataFixture _dataFixture = new ( ) ;
32
35
private readonly List < string > _filePaths = new ( ) ;
33
36
34
37
public void Dispose ( )
@@ -203,14 +206,9 @@ public async Task StreamFile_BlobDoesNotExist()
203
206
[ Fact ]
204
207
public async Task ZipFilesToStream_ValidFileTypes ( )
205
208
{
206
- var releaseVersion = new ReleaseVersion
207
- {
208
- Publication = new Publication
209
- {
210
- Slug = "publication-slug"
211
- } ,
212
- Slug = "release-slug"
213
- } ;
209
+ ReleaseVersion releaseVersion = _dataFixture . DefaultReleaseVersion ( )
210
+ . WithRelease ( _dataFixture . DefaultRelease ( )
211
+ . WithPublication ( _dataFixture . DefaultPublication ( ) ) ) ;
214
212
215
213
var releaseFile1 = new ReleaseFile
216
214
{
@@ -309,14 +307,9 @@ public async Task ZipFilesToStream_ValidFileTypes()
309
307
[ Fact ]
310
308
public async Task ZipFilesToStream_DataGuidanceForMultipleDataFiles ( )
311
309
{
312
- var releaseVersion = new ReleaseVersion
313
- {
314
- Publication = new Publication
315
- {
316
- Slug = "publication-slug"
317
- } ,
318
- Slug = "release-slug"
319
- } ;
310
+ ReleaseVersion releaseVersion = _dataFixture . DefaultReleaseVersion ( )
311
+ . WithRelease ( _dataFixture . DefaultRelease ( )
312
+ . WithPublication ( _dataFixture . DefaultPublication ( ) ) ) ;
320
313
321
314
var releaseFile1 = new ReleaseFile
322
315
{
@@ -415,14 +408,9 @@ public async Task ZipFilesToStream_DataGuidanceForMultipleDataFiles()
415
408
[ Fact ]
416
409
public async Task ZipFilesToStream_OrderedAlphabetically ( )
417
410
{
418
- var releaseVersion = new ReleaseVersion
419
- {
420
- Publication = new Publication
421
- {
422
- Slug = "publication-slug"
423
- } ,
424
- Slug = "release-slug"
425
- } ;
411
+ ReleaseVersion releaseVersion = _dataFixture . DefaultReleaseVersion ( )
412
+ . WithRelease ( _dataFixture . DefaultRelease ( )
413
+ . WithPublication ( _dataFixture . DefaultPublication ( ) ) ) ;
426
414
427
415
var releaseFile1 = new ReleaseFile
428
416
{
@@ -519,14 +507,9 @@ public async Task ZipFilesToStream_OrderedAlphabetically()
519
507
[ Fact ]
520
508
public async Task ZipFilesToStream_FiltersInvalidFileTypes ( )
521
509
{
522
- var releaseVersion = new ReleaseVersion
523
- {
524
- Publication = new Publication
525
- {
526
- Slug = "publication-slug"
527
- } ,
528
- Slug = "release-slug"
529
- } ;
510
+ ReleaseVersion releaseVersion = _dataFixture . DefaultReleaseVersion ( )
511
+ . WithRelease ( _dataFixture . DefaultRelease ( )
512
+ . WithPublication ( _dataFixture . DefaultPublication ( ) ) ) ;
530
513
531
514
var releaseFile1 = new ReleaseFile
532
515
{
@@ -612,14 +595,9 @@ public async Task ZipFilesToStream_FiltersInvalidFileTypes()
612
595
[ Fact ]
613
596
public async Task ZipFilesToStream_FiltersFilesNotInBlobStorage ( )
614
597
{
615
- var releaseVersion = new ReleaseVersion
616
- {
617
- Publication = new Publication
618
- {
619
- Slug = "publication-slug"
620
- } ,
621
- Slug = "release-slug"
622
- } ;
598
+ ReleaseVersion releaseVersion = _dataFixture . DefaultReleaseVersion ( )
599
+ . WithRelease ( _dataFixture . DefaultRelease ( )
600
+ . WithPublication ( _dataFixture . DefaultPublication ( ) ) ) ;
623
601
624
602
var releaseFile1 = new ReleaseFile
625
603
{
@@ -689,14 +667,9 @@ public async Task ZipFilesToStream_FiltersFilesNotInBlobStorage()
689
667
[ Fact ]
690
668
public async Task ZipFilesToStream_FiltersFilesForOtherReleases ( )
691
669
{
692
- var releaseVersion = new ReleaseVersion
693
- {
694
- Publication = new Publication
695
- {
696
- Slug = "publication-slug"
697
- } ,
698
- Slug = "release-slug"
699
- } ;
670
+ ReleaseVersion releaseVersion = _dataFixture . DefaultReleaseVersion ( )
671
+ . WithRelease ( _dataFixture . DefaultRelease ( )
672
+ . WithPublication ( _dataFixture . DefaultPublication ( ) ) ) ;
700
673
701
674
// Files are for other releases
702
675
var releaseFile1 = new ReleaseFile
@@ -763,14 +736,9 @@ public async Task ZipFilesToStream_FiltersFilesForOtherReleases()
763
736
[ Fact ]
764
737
public async Task ZipFilesToStream_Empty ( )
765
738
{
766
- var releaseVersion = new ReleaseVersion
767
- {
768
- Publication = new Publication
769
- {
770
- Slug = "publication-slug"
771
- } ,
772
- Slug = "release-slug"
773
- } ;
739
+ ReleaseVersion releaseVersion = _dataFixture . DefaultReleaseVersion ( )
740
+ . WithRelease ( _dataFixture . DefaultRelease ( )
741
+ . WithPublication ( _dataFixture . DefaultPublication ( ) ) ) ;
774
742
775
743
var contentDbContextId = Guid . NewGuid ( ) . ToString ( ) ;
776
744
@@ -808,14 +776,9 @@ public async Task ZipFilesToStream_Empty()
808
776
[ Fact ]
809
777
public async Task ZipFilesToStream_Cancelled ( )
810
778
{
811
- var releaseVersion = new ReleaseVersion
812
- {
813
- Publication = new Publication
814
- {
815
- Slug = "publication-slug"
816
- } ,
817
- Slug = "release-slug"
818
- } ;
779
+ ReleaseVersion releaseVersion = _dataFixture . DefaultReleaseVersion ( )
780
+ . WithRelease ( _dataFixture . DefaultRelease ( )
781
+ . WithPublication ( _dataFixture . DefaultPublication ( ) ) ) ;
819
782
820
783
var releaseFile1 = new ReleaseFile
821
784
{
@@ -900,14 +863,10 @@ public async Task ZipFilesToStream_Cancelled()
900
863
[ Fact ]
901
864
public async Task ZipFilesToStream_NoFileIds_NoCachedAllFilesZip ( )
902
865
{
903
- var releaseVersion = new ReleaseVersion
904
- {
905
- Publication = new Publication
906
- {
907
- Slug = "publication-slug"
908
- } ,
909
- Slug = "release-slug"
910
- } ;
866
+ ReleaseVersion releaseVersion = _dataFixture . DefaultReleaseVersion ( )
867
+ . WithRelease ( _dataFixture . DefaultRelease ( )
868
+ . WithPublication ( _dataFixture . DefaultPublication ( )
869
+ . WithSlug ( "publication-slug" ) ) ) ;
911
870
912
871
var releaseFile1 = new ReleaseFile
913
872
{
@@ -1024,14 +983,10 @@ public async Task ZipFilesToStream_NoFileIds_NoCachedAllFilesZip()
1024
983
[ Fact ]
1025
984
public async Task ZipFilesToStream_NoFileIds_CachedAllFilesZip ( )
1026
985
{
1027
- var releaseVersion = new ReleaseVersion
1028
- {
1029
- Publication = new Publication
1030
- {
1031
- Slug = "publication-slug"
1032
- } ,
1033
- Slug = "release-slug"
1034
- } ;
986
+ ReleaseVersion releaseVersion = _dataFixture . DefaultReleaseVersion ( )
987
+ . WithRelease ( _dataFixture . DefaultRelease ( )
988
+ . WithPublication ( _dataFixture . DefaultPublication ( )
989
+ . WithSlug ( "publication-slug" ) ) ) ;
1035
990
1036
991
var contentDbContextId = Guid . NewGuid ( ) . ToString ( ) ;
1037
992
@@ -1087,14 +1042,10 @@ public async Task ZipFilesToStream_NoFileIds_CachedAllFilesZip()
1087
1042
[ Fact ]
1088
1043
public async Task ZipFilesToStream_NoFileIds_StaleCachedAllFilesZip ( )
1089
1044
{
1090
- var releaseVersion = new ReleaseVersion
1091
- {
1092
- Publication = new Publication
1093
- {
1094
- Slug = "publication-slug"
1095
- } ,
1096
- Slug = "release-slug"
1097
- } ;
1045
+ ReleaseVersion releaseVersion = _dataFixture . DefaultReleaseVersion ( )
1046
+ . WithRelease ( _dataFixture . DefaultRelease ( )
1047
+ . WithPublication ( _dataFixture . DefaultPublication ( )
1048
+ . WithSlug ( "publication-slug" ) ) ) ;
1098
1049
1099
1050
var releaseFile1 = new ReleaseFile
1100
1051
{
0 commit comments