vendredi 31 juillet 2015

fatal error: NSArray element failed to match the Swift Array Element type only third time

I know, that there is a lot of questions about this problem, but it haven't solved my problem.

This is my function:

func sortedWorkingHours() -> [DBWorkingHours] {

    let result = Array(workingHours).sort {
        return ($0 as DBWorkingHours).createdAt.compare(($1 as DBWorkingHours).createdAt) == NSComparisonResult.OrderedAscending
    }
    print("--->DONE")
    return result
}

This is how I call this function in 3 places for 3 tests:

for workingHoursItem in settings.sortedWorkingHours() { //here is an error by third time
    ...
}

This is what get in console:

Test Case '-[DirectBistroTests.CoreDataLocationTests testCurrentWorkingHoursTitleForLocationWithWorkingTypeOpenForSelectedAndTimeIsIncluded]' started.
...
--->DONE
...
Test Case '-[DirectBistroTests.CoreDataLocationTests testCurrentWorkingHoursTitleForLocationWithWorkingTypeOpenForSelectedAndTimeIsNotIncluded]' started.
...
--->DONE
...

Test Case '-[DirectBistroTests.CoreDataLocationTests testRequestingHoursTitleForTakeawayMode]' started.
--->DONE
fatal error: NSArray element failed to match the Swift Array Element type

Why?

This is failing test:

func testRequestingHoursTitleForTakeawayMode() {

    let location = DBLocation.findOrUpdateLocationWithDictionary(mockDictionaryForLocation(), inContext: context)
    DBWorkingHours.findOrUpdateWorkingHoursWithDictionary(mockDictionaryForCurrentWorkingHours(), inContext: context)
    let requestingHoursTitle = location.requestingHoursTitleForMode(.Takeaway)

    let expectedTitle = "sdf"
    XCTAssertEqual(requestingHoursTitle.string, expectedTitle)
}

Aucun commentaire:

Enregistrer un commentaire