-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented subscript based data access. Added tests. Closes #55 Rela…
…tes to #43
- Loading branch information
Showing
5 changed files
with
70 additions
and
7 deletions.
There are no files selected for viewing
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
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
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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// SubscriptTests.swift | ||
// | ||
// | ||
// Created by Veljko Tekelerovic on 20.12.23. | ||
// | ||
|
||
import XCTest | ||
import Foundation | ||
|
||
@testable import Fridge | ||
|
||
final class CustomSubscriptTests: XCTestCase { | ||
private func freezeTestObject() throws { | ||
let testObject = FridgeMockObject() | ||
try Fridge.freeze🧊(testObject, id: STORAGE_IDENTIFIER) | ||
} | ||
|
||
func testInvalidIdentifierThrows_UsingSubscript() { | ||
do { | ||
let _ : FridgeMockObject = try Fridge["non_existant_id"] | ||
XCTFail("Should'ev thrown an error") | ||
} catch let err as FridgeErrors { | ||
print("** Fridge error raised: ", err) | ||
} catch let generalError { | ||
print("General error is: ", generalError) | ||
} | ||
} | ||
|
||
func testCanUnFreee_UsingSubscript() throws { | ||
try freezeTestObject() | ||
|
||
let frozenObject: FridgeMockObject = try Fridge[STORAGE_IDENTIFIER] | ||
|
||
XCTAssert(frozenObject.string_field == "Some f🧊ncy string") | ||
XCTAssert(frozenObject.int_field == Int.max) | ||
XCTAssert(frozenObject.bool_field == false) | ||
} | ||
|
||
override class func tearDown() { | ||
Fridge.drop🗑(STORAGE_IDENTIFIER) | ||
print("\n** <Fridge.Tests> Test object removed from the file system **\n") | ||
} | ||
} |