Created
February 23, 2022 22:32
-
-
Save antonio081014/0e80b3e5412db4ce8087468b401009d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func test_imageEntity_properties() throws { | |
// Assert non nil value, and unwrap it. | |
let entity = try XCTUnwrap( | |
CoreDataStore.model?.entitiesByName["Name of Entity"] | |
) | |
entity.verify(attribute: "id", hasType: .UUIDAttributeType, isOptional: false) | |
entity.verify(attribute: "description", hasType: .stringAttributeType, isOptional: true) | |
entity.verify(attribute: "url", hasType: .URIAttributeType, isOptional: false) | |
} | |
extension NSEntityDescription { | |
func verify(attribute name: String, hasType type: NSAttributeType, isOptional: Bool, file: StaticString = #filePath, line: UInt = #line) { | |
guard let attribute = attributesByName[name] else { | |
XCTFail("Missing expected attribute \(name)", file: file, line: line) | |
return | |
} | |
guard let property = propertiesByName[name] else { | |
XCTFail("Missing expected property \(name)", file: file, line: line) | |
return | |
} | |
XCTAssertEqual(attribute.attributeType, type, "attributeType", file: file, line: line) | |
XCTAssertEqual(property.isOptional, isOptional, "isOptional", file: file, line: line) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment