@@ -40,6 +40,24 @@ class EntityTests: XCTestCase {
4040
4141 XCTAssertEqual ( entity2. relationships. other. id, entity1. id)
4242 }
43+
44+ func test_initialization( ) {
45+ let entity1 = TestEntity1 ( id: . init( rawValue: " wow " ) )
46+ let entity2 = TestEntity2 ( id: . init( rawValue: " cool " ) , relationships: . init( other: . init( entity: entity1) ) )
47+ let _ = TestEntity3 ( id: . init( rawValue: " 3 " ) , relationships: . init( others: . init( ids: [ . init( rawValue: " 10 " ) , . init( rawValue: " 20 " ) , entity1. id] ) ) )
48+ let _ = TestEntity4 ( id: . init( rawValue: " 4 " ) , attributes: . init( word: . init( value: " hello " ) , number: . init( value: 10 ) , array: . init( value: [ 10.2 , 10.3 ] ) ) , relationships: . init( other: entity2. pointer) )
49+ let _ = TestEntity5 ( id: . init( rawValue: " 5 " ) , attributes: . init( floater: . init( value: 10.2 ) ) )
50+ let _ = TestEntity6 ( id: . init( rawValue: " 6 " ) , attributes: . init( here: . init( value: " here " ) , maybeHere: nil , maybeNull: . init( value: nil ) ) )
51+ let _ = TestEntity7 ( id: . init( rawValue: " 7 " ) , attributes: . init( here: . init( value: " hello " ) , maybeHereMaybeNull: . init( value: " world " ) ) )
52+ XCTAssertNoThrow ( try TestEntity8 ( id: . init( rawValue: " 8 " ) , attributes: . init( string: . init( value: " hello " ) , int: . init( value: 10 ) , stringFromInt: . init( rawValue: 20 ) , plus: . init( rawValue: 30 ) , doubleFromInt: . init( rawValue: 32 ) , omitted: nil , nullToString: . init( rawValue: nil ) ) ) )
53+ let _ = TestEntity9 ( id: . init( rawValue: " 9 " ) , relationships: . init( one: entity1. pointer, nullableOne: nil ) )
54+ let e10id1 = TestEntity10 . Identifier ( rawValue: " hello " )
55+ let e10id2 = TestEntity10 . Id ( rawValue: " world " )
56+ let e10id3 : TestEntity10 . Id = " ! "
57+ let _ = TestEntity10 ( id: . init( rawValue: " 10 " ) , relationships: . init( selfRef: . init( id: e10id1) , selfRefs: . init( ids: [ e10id2, e10id3] ) ) )
58+ XCTAssertNoThrow ( try TestEntity11 ( id: . init( rawValue: " 11 " ) , attributes: . init( number: . init( rawValue: 11 ) ) ) )
59+ let _ = UnidentifiedTestEntity ( attributes: . init( me: . init( value: " hello " ) ) )
60+ }
4361}
4462
4563// MARK: - Encode/Decode
0 commit comments