Skip to content

Commit

Permalink
Test optional string generation
Browse files Browse the repository at this point in the history
Seems to work.
  • Loading branch information
helje5 committed Oct 1, 2023
1 parent dbaf5f3 commit 3d566f6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Tests/ManagedModelTests/SchemaGenerationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,34 @@ final class SchemaGenerationTests: XCTestCase {
XCTAssertFalse(lastname.isRelationship)
}

func testOptionalString() throws {
let cache = SchemaBuilder()
let schema = NSManagedObjectModel(
[ Fixtures.PersonAddressSchema.Person.self ],
schemaCache: cache
)

XCTAssertEqual(schema.entities.count, 2)
XCTAssertEqual(schema.entitiesByName.count, 2)

let address = try XCTUnwrap(schema.entitiesByName["Address"])
XCTAssertEqual(address.attributes.count, 2)

let appartment = try XCTUnwrap(address.attributesByName["appartment"])
XCTAssertFalse(appartment.isTransient)
XCTAssertFalse(appartment.isRelationship)
XCTAssertTrue (appartment.isAttribute)
XCTAssertTrue (appartment.isOptional)
XCTAssertEqual(appartment.attributeType, .stringAttributeType)

let street = try XCTUnwrap(address.attributesByName["street"])
XCTAssertFalse(street.isTransient)
XCTAssertFalse(street.isRelationship)
XCTAssertTrue (street.isAttribute)
XCTAssertFalse(street.isOptional)
XCTAssertEqual(street.attributeType, .stringAttributeType)
}

func testMOM() throws {
let mom = Fixtures.PersonAddressMOM
XCTAssertEqual(mom.entities.count, 2)
Expand Down

0 comments on commit 3d566f6

Please sign in to comment.