@@ -49,18 +49,24 @@ public async Task Record_Has_Metadata(BackendType backendType)
4949 [ InlineData ( BackendType . Fuseki ) ]
5050 public async Task Record_Can_Add_Metadata ( BackendType backendType )
5151 {
52+ // Arrange
5253 var record = await Immutable . Record . CreateAsync ( await CreateBackend ( backendType , RdfMediaType . JsonLd , await TestData . ValidJsonLdRecordString ( ) ) ) ;
53- var result1 = record . Metadata ! . Count ( ) ;
54+ var oldRecordMetadataCount = record . Metadata ! . Count ( ) ;
5455 var g = new Graph ( ) ;
55- g . Assert ( new Triple ( new UriNode ( new Uri ( "https://example.com/subject/123" ) ) , new UriNode ( new Uri ( "https://example.com/predicate/456" ) ) , new LiteralNode ( "Example value" ) ) ) ;
56+ g . Assert ( new Triple ( new UriNode ( new Uri ( record . Id ) ) , new UriNode ( new Uri ( "https://rdf.equinor.com/ontology/record/replaces" ) ) , new UriNode ( new Uri ( TestData . CreateRecordId ( "2" ) ) ) ) ) ;
57+
58+ // Act
5659 var newRecord = await record . WithAdditionalMetadata ( g ) ;
57- var result2 = record . Metadata ! . Count ( ) ;
58- var result3 = newRecord . Metadata ! . Count ( ) ;
59-
60-
61- result1 . Should ( ) . Be ( 21 ) ;
62- result2 . Should ( ) . Be ( 21 ) ;
63- result3 . Should ( ) . Be ( 22 ) ;
60+
61+ // Assert
62+ newRecord . Replaces . Should ( ) . Contain ( TestData . CreateRecordId ( "2" ) ) ;
63+ newRecord . Replaces . Count ( ) . Should ( ) . Be ( 1 ) ;
64+ record . Replaces ! . Count ( ) . Should ( ) . Be ( 0 ) ;
65+ var oldRecordMetadataCountAfterAdditional = record . Metadata ! . Count ( ) ;
66+ var newRecordMetadataCount = newRecord . Metadata ! . Count ( ) ;
67+ oldRecordMetadataCount . Should ( ) . Be ( 21 ) ;
68+ oldRecordMetadataCountAfterAdditional . Should ( ) . Be ( 21 ) ;
69+ newRecordMetadataCount . Should ( ) . Be ( 22 ) ;
6470 }
6571 [ Theory ]
6672 [ InlineData ( BackendType . DotNetRdf ) ]
@@ -111,7 +117,7 @@ public async Task Record_Does_Not_Have_Metadata(BackendType backendType)
111117
112118 var result = async ( ) => await Immutable . Record . CreateAsync ( await CreateBackend ( backendType , RdfMediaType . Quads , rdf ) ) ;
113119
114- await result . Should ( ) . ThrowAsync < RecordException > ( ) . WithMessage ( "Could not find a metadata graph. A record must have exactly one metadata graph. " ) ;
120+ await result . Should ( ) . ThrowAsync < RecordException > ( ) . WithMessage ( "Could not find a metadata graph. A record must have exactly one metadata graph" ) ;
115121 }
116122
117123
0 commit comments