-
-
Save MarcoSantarossa/4a8ef480bf362a5d6be112473a55c08a to your computer and use it in GitHub Desktop.
StorageKit - Reproduce Issue https://github.com/StorageKit/StorageKit/issues/6
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
import Foundation | |
import StorageKit | |
import RealmSwift | |
final class SpyStorageContext: StorageContext { | |
fileprivate(set) var createCalledCount = 0 | |
fileprivate(set) var createTypes = [Object.Type]() | |
fileprivate(set) var addCalledCount = 0 | |
fileprivate(set) var addEntityArguments = [StorageEntityType]() | |
} | |
extension SpyStorageContext { | |
func create<T: StorageEntityType>() throws -> T? { | |
guard let entityToCreate = T.self as? Object.Type else { return nil } | |
createCalledCount += 1 | |
createTypes.append(entityToCreate) | |
return entityToCreate.init() as? T | |
} | |
func add<T: StorageEntityType>(_ entity: T) throws { | |
addCalledCount += 1 | |
addEntityArguments.append(entity) | |
} | |
func add<T>(_ entities: [T]) throws where T : StorageEntityType {} | |
} | |
extension SpyStorageContext { | |
func update(transform: @escaping () -> Void) throws {} | |
} | |
extension SpyStorageContext { | |
func fetch<T: StorageEntityType>(predicate: NSPredicate?, sortDescriptors: [SortDescriptor]?, completion: @escaping FetchCompletionClosure<T>) {} | |
} | |
extension SpyStorageContext { | |
func delete<T: StorageEntityType>(_ entity: T) throws {} | |
func delete<T: StorageEntityType>(_ entities: [T]) throws {} | |
func deleteAll<T: StorageEntityType>(_ entityType: T.Type) throws {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment