Esqarrouth/EZSwiftExtensions

NSDictionary Tests

lfarah opened this issue · 6 comments

We have a problem on NSDictionaryExtensions.swift test coverage.

NSDictionaryExtensionTests

class NSDictionaryTests: XCTestCase {
    
    func testDicToJSON() {
        let dic: NSDictionary = ["foo":"bar"]
        let json = dic.formatJSON()
        let str = "{\"foo\":\"bar\"}"
        XCTAssertEqual(json, str)
    }
    
    func testJSONtoDic() {
        
        let str = "{\"foo\":\"bar\"}"
        let dic = NSDictionary(json: str)
        let dicExpected: NSDictionary = ["foo":"bar"]
        XCTAssertEqual(dic, dicExpected)
    }
}

Coverage

screen shot 2016-10-30 at 10 29 45 pm

Hm, what it could be?

@piv199 I'm thinking about it now... Should we have NSDictionaryExtensions at all? Ray Wenderlich's Style Guide says this:

Types

Always use Swift's native types when available. Swift offers bridging to Objective-C so you can still use the full set of methods as needed.

Preferred:

let width = 120.0                                    // Double
let widthString = (width as NSNumber).stringValue    // String

Not Preferred:

let width: NSNumber = 120.0                          // NSNumber
let widthString: NSString = width.stringValue        // NSString

Whats the problem, I don't get it?

Changing this to standard Dictionary would work the same right? If it does no problem in changing it

@piv199 what do you think?

@lfarah I agree with @goktugyil, change everything to Dictionary 👍