@@ -32,7 +32,11 @@ public void ById_WhenContentExists_ReturnsPublishedContent()
32
32
content . Key . Returns ( new Guid ( "3B1E9E9C-A89E-4FE0-902D-3466D8678E47" ) ) ;
33
33
34
34
var snapshotAccessor = Substitute . For < IPublishedSnapshotAccessor > ( ) ;
35
- snapshotAccessor . PublishedSnapshot . Content . GetById ( Arg . Is ( content . Key ) )
35
+ if ( ! snapshotAccessor . TryGetPublishedSnapshot ( out var publishedSnapshot ) )
36
+ {
37
+ throw new InvalidOperationException ( "Wasn't possible to a get a valid Snapshot" ) ;
38
+ }
39
+ publishedSnapshot . Content . GetById ( Arg . Is ( content . Key ) )
36
40
. Returns ( content ) ;
37
41
38
42
var actual = query . ById ( snapshotAccessor , new Id ( content . Key . ToString ( ) ) ) ;
@@ -47,7 +51,11 @@ public void ById_WhenContentDoesNotExists_ReturnsNull()
47
51
var id = new Guid ( "3B1E9E9C-A89E-4FE0-902D-3466D8678E47" ) ;
48
52
49
53
var snapshotAccessor = Substitute . For < IPublishedSnapshotAccessor > ( ) ;
50
- snapshotAccessor . PublishedSnapshot . Content . GetById ( Arg . Is ( id ) )
54
+ if ( ! snapshotAccessor . TryGetPublishedSnapshot ( out var publishedSnapshot ) )
55
+ {
56
+ throw new InvalidOperationException ( "Wasn't possible to a get a valid Snapshot" ) ;
57
+ }
58
+ publishedSnapshot . Content . GetById ( Arg . Is ( id ) )
51
59
. Returns ( ( IPublishedContent ) null ) ;
52
60
53
61
var actual = query . ById ( snapshotAccessor , new Id ( id . ToString ( ) ) ) ;
@@ -74,7 +82,11 @@ public void ByUrl_WhenContentExists_ReturnsPublishedContent()
74
82
content . Key . Returns ( new Guid ( "3B1E9E9C-A89E-4FE0-902D-3466D8678E47" ) ) ;
75
83
76
84
var snapshotAccessor = Substitute . For < IPublishedSnapshotAccessor > ( ) ;
77
- snapshotAccessor . PublishedSnapshot . Content . GetByRoute ( "/" )
85
+ if ( ! snapshotAccessor . TryGetPublishedSnapshot ( out var publishedSnapshot ) )
86
+ {
87
+ throw new InvalidOperationException ( "Wasn't possible to a get a valid Snapshot" ) ;
88
+ }
89
+ publishedSnapshot . Content . GetByRoute ( "/" )
78
90
. Returns ( content ) ;
79
91
80
92
var actual = query . ByUrl ( snapshotAccessor , "/" ) ;
@@ -88,7 +100,11 @@ public void ByUrl_WhenContentDoesNotExists_ReturnsNull()
88
100
var query = CreateSUT ( ) ;
89
101
90
102
var snapshotAccessor = Substitute . For < IPublishedSnapshotAccessor > ( ) ;
91
- snapshotAccessor . PublishedSnapshot . Content . GetByRoute ( "/" )
103
+ if ( ! snapshotAccessor . TryGetPublishedSnapshot ( out var publishedSnapshot ) )
104
+ {
105
+ throw new InvalidOperationException ( "Wasn't possible to a get a valid Snapshot" ) ;
106
+ }
107
+ publishedSnapshot . Content . GetByRoute ( "/" )
92
108
. Returns ( ( IPublishedContent ) null ) ;
93
109
94
110
var actual = query . ByUrl ( snapshotAccessor , "/" ) ;
0 commit comments