MockUserDefaults 1.1.0

MockUserDefaults 1.1.0

Maintained by 417.72KI.



MockUserDefaults

Build Status Version Platform GitHub release Swift4.2 Swift5 GitHub license

MockUserDefaults is a simple replacement for NSUserDefaults/UserDefaults to make test easier.

Installation

CocoaPods

pod 'MockUserDefaults', '~> 1.0'

Carthage

github "417-72KI/MockUserDefaults" ~> 1.0

Usage

Objective-C

NSUserDefaults *userDefaults = [NSUserDefaults mockedUserDefaults];
[userDefaults setObject:@"string" forKey:@"key"];

XCTAssertEqualObjects([userDefaults objectForKey:@"key"], @"string");

Swift

let userDefaults: UserDefaults = .mocked
userDefaults.set("string", forKey: "key")

XCTAssertEqual(userDefaults.string(forKey: "key"), "string")