Added test for rxError bug.
This commit is contained in:
parent
2f697fe5d4
commit
420b6809d4
|
|
@ -28,11 +28,18 @@ func rxError(errorCode: RxCocoaError, message: String) -> NSError {
|
|||
return NSError(domain: RxCocoaErrorDomain, code: errorCode.rawValue, userInfo: [NSLocalizedDescriptionKey: message])
|
||||
}
|
||||
|
||||
#if !RELEASE
|
||||
public func _rxError(errorCode: RxCocoaError, message: String, userInfo: NSDictionary) -> NSError {
|
||||
return rxError(errorCode, message, userInfo)
|
||||
}
|
||||
#endif
|
||||
|
||||
func rxError(errorCode: RxCocoaError, message: String, userInfo: NSDictionary) -> NSError {
|
||||
let mutableDictionary = NSMutableDictionary(dictionary: userInfo as! [NSObject : AnyObject])
|
||||
mutableDictionary[NSLocalizedDescriptionKey] = message
|
||||
// swift compiler :(
|
||||
let resultInfo: [NSObject: AnyObject] = (userInfo as NSObject) as! [NSObject: AnyObject]
|
||||
var resultInfo: [NSObject: AnyObject] = [:]
|
||||
resultInfo[NSLocalizedDescriptionKey] = message
|
||||
for k in userInfo.allKeys {
|
||||
resultInfo[k as! NSObject] = userInfo[k as! NSCopying]
|
||||
}
|
||||
return NSError(domain: RxCocoaErrorDomain, code: Int(errorCode.rawValue), userInfo: resultInfo)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// RxCocoaTests.swift
|
||||
// RxTests
|
||||
//
|
||||
// Created by Krunoslav Zaher on 7/6/15.
|
||||
//
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import XCTest
|
||||
import RxSwift
|
||||
import RxCocoa
|
||||
|
||||
class RxCocoaTest : RxTest {
|
||||
#if !RELEASE
|
||||
func testRxError() {
|
||||
let result = _rxError(RxCocoaError.NetworkError, "my bad", ["a": 1])
|
||||
|
||||
let dUserInfo = NSDictionary(dictionary: result.userInfo!)
|
||||
XCTAssertTrue(dUserInfo.isEqualToDictionary([NSLocalizedDescriptionKey: "my bad", "a" : 1]))
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
@ -81,6 +81,7 @@
|
|||
C897EC4B1B1123DA009C2CB0 /* Observable+MultipleTest+Zip.swift in Sources */ = {isa = PBXBuildFile; fileRef = C897EC491B1123DA009C2CB0 /* Observable+MultipleTest+Zip.swift */; };
|
||||
C8AF26EF1B499E5C00131C03 /* DelegateProxyTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8AF26EE1B499E5C00131C03 /* DelegateProxyTest.swift */; };
|
||||
C8AF26F01B499E5C00131C03 /* DelegateProxyTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8AF26EE1B499E5C00131C03 /* DelegateProxyTest.swift */; };
|
||||
C8B5BEA11B4A6A82000D732C /* RxCocoaTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8B5BEA01B4A6A82000D732C /* RxCocoaTests.swift */; };
|
||||
C8B787FA1AF55CDE00206D02 /* Observable+ConcurrencyTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8B787F91AF55CDE00206D02 /* Observable+ConcurrencyTest.swift */; };
|
||||
C8E381231B2063CC008CDC33 /* Observable+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8E381221B2063CC008CDC33 /* Observable+Extensions.swift */; };
|
||||
C8E381281B207D03008CDC33 /* PrimitiveHotObservable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8E381271B207D03008CDC33 /* PrimitiveHotObservable.swift */; };
|
||||
|
|
@ -134,6 +135,7 @@
|
|||
C897EC461B112070009C2CB0 /* Observable+MultipleTest+Zip.tt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "Observable+MultipleTest+Zip.tt"; sourceTree = "<group>"; };
|
||||
C897EC491B1123DA009C2CB0 /* Observable+MultipleTest+Zip.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Observable+MultipleTest+Zip.swift"; sourceTree = "<group>"; };
|
||||
C8AF26EE1B499E5C00131C03 /* DelegateProxyTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DelegateProxyTest.swift; sourceTree = "<group>"; };
|
||||
C8B5BEA01B4A6A82000D732C /* RxCocoaTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RxCocoaTests.swift; sourceTree = "<group>"; };
|
||||
C8B787F91AF55CDE00206D02 /* Observable+ConcurrencyTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Observable+ConcurrencyTest.swift"; sourceTree = "<group>"; };
|
||||
C8E381221B2063CC008CDC33 /* Observable+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Observable+Extensions.swift"; sourceTree = "<group>"; };
|
||||
C8E381271B207D03008CDC33 /* PrimitiveHotObservable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PrimitiveHotObservable.swift; sourceTree = "<group>"; };
|
||||
|
|
@ -208,6 +210,7 @@
|
|||
C814CEA61AF642D600E98087 /* UI+RxTests.swift */,
|
||||
5E5D10BA1B48355200432B25 /* UIControl+RxTests.swift */,
|
||||
C8633AE41B0A9FF300375D60 /* KVOObservableTests.swift */,
|
||||
C8B5BEA01B4A6A82000D732C /* RxCocoaTests.swift */,
|
||||
);
|
||||
path = RxCocoaTests;
|
||||
sourceTree = SOURCE_ROOT;
|
||||
|
|
@ -419,6 +422,7 @@
|
|||
C811085D1AF50E2A001C13E4 /* AssumptionsTest.swift in Sources */,
|
||||
C81108501AF50E2A001C13E4 /* ConnectableObservable.swift in Sources */,
|
||||
C814CEA31AF5622600E98087 /* VariableTest.swift in Sources */,
|
||||
C8B5BEA11B4A6A82000D732C /* RxCocoaTests.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue