Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 51 additions & 36 deletions OCMapper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@
15B554C7171B7B3C0058E159 /* Sources */,
15B554C8171B7B3C0058E159 /* Frameworks */,
15B554C9171B7B3C0058E159 /* Resources */,
15B554CA171B7B3C0058E159 /* ShellScript */,
);
buildRules = (
);
Expand All @@ -517,8 +516,16 @@
isa = PBXProject;
attributes = {
LastTestingUpgradeCheck = 0610;
LastUpgradeCheck = 0500;
LastUpgradeCheck = 0820;
ORGANIZATIONNAME = "Aryan Ghassemi";
TargetAttributes = {
15B554AA171B7B3B0058E159 = {
LastSwiftMigration = 0820;
};
15B554CB171B7B3C0058E159 = {
LastSwiftMigration = 0820;
};
};
};
buildConfigurationList = 15B554A5171B7B3B0058E159 /* Build configuration list for PBXProject "OCMapper" */;
compatibilityVersion = "Xcode 3.2";
Expand Down Expand Up @@ -559,22 +566,6 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
15B554CA171B7B3C0058E159 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
15B554A7171B7B3B0058E159 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down Expand Up @@ -676,22 +667,35 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand All @@ -707,19 +711,32 @@
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = iphoneos;
SWIFT_OBJC_BRIDGING_HEADER = "OCMApper/OCMapper-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand All @@ -728,67 +745,65 @@
15B554DF171B7B3C0058E159 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "OCMapper/OCMapper-Prefix.pch";
INFOPLIST_FILE = "OCMapper/OCMapper-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.aryaxt.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = OCMapper;
SWIFT_OBJC_BRIDGING_HEADER = "OCMapper/OCMapper-Bridging-Header.h";
SWIFT_VERSION = 3.0;
WRAPPER_EXTENSION = app;
};
name = Debug;
};
15B554E0171B7B3C0058E159 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "OCMapper/OCMapper-Prefix.pch";
INFOPLIST_FILE = "OCMapper/OCMapper-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.aryaxt.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = OCMapper;
SWIFT_OBJC_BRIDGING_HEADER = "OCMapper/OCMapper-Bridging-Header.h";
SWIFT_VERSION = 3.0;
WRAPPER_EXTENSION = app;
};
name = Release;
};
15B554E2171B7B3C0058E159 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/OCMapper.app/OCMapper";
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
FRAMEWORK_SEARCH_PATHS = (
"\"$(SDKROOT)/Developer/Library/Frameworks\"",
"\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
"$(inherited)",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "OCMapper/OCMapper-Prefix.pch";
INFOPLIST_FILE = "OCMapperTests/OCMapperTests-Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.aryaxt.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = OCMapperTests;
SWIFT_OBJC_BRIDGING_HEADER = "OCMapper/OCMapperTests-Bridging-Header.h";
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUNDLE_LOADER)";
};
name = Debug;
};
15B554E3171B7B3C0058E159 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/OCMapper.app/OCMapper";
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
FRAMEWORK_SEARCH_PATHS = (
"\"$(SDKROOT)/Developer/Library/Frameworks\"",
"\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
"$(inherited)",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "OCMapper/OCMapper-Prefix.pch";
INFOPLIST_FILE = "OCMapperTests/OCMapperTests-Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.aryaxt.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = OCMapperTests;
SWIFT_OBJC_BRIDGING_HEADER = "OCMapper/OCMapperTests-Bridging-Header.h";
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUNDLE_LOADER)";
};
name = Release;
Expand Down
13 changes: 8 additions & 5 deletions OCMapper.xcodeproj/xcshareddata/xcschemes/OCMapperTests.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0630"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -23,10 +23,10 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -48,15 +48,18 @@
ReferencedContainer = "container:OCMapper.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
Expand All @@ -71,10 +74,10 @@
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
Expand Down
2 changes: 1 addition & 1 deletion OCMapper/OCMapper-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.aryaxt.${PRODUCT_NAME:rfc1034identifier}</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
2 changes: 1 addition & 1 deletion OCMapperTests/OCMapperTests-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.aryaxt.${PRODUCT_NAME:rfc1034identifier}</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
Expand Down
52 changes: 26 additions & 26 deletions OCMapperTests/ObjectMapperSwiftTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ObjectMapperSwiftTests : XCTestCase {
// MARK: - Tests -

func testAutomaticMapping() {
let date = NSDate().dateByAddingTimeInterval(-5555)
let date = NSDate().addingTimeInterval(-5555)

let dictionary = [
"firstName": "Aryan",
Expand All @@ -46,9 +46,9 @@ class ObjectMapperSwiftTests : XCTestCase {
["summary": "bla 2", "price": 55],
["summary": "bla 3", "price": 99.99],
]
]
] as [String : Any]

let customer = objectMapper.objectFromSource(dictionary, toInstanceOfClass: Customer.self) as! Customer
let customer = objectMapper.object(fromSource: dictionary, toInstanceOf: Customer.self) as! Customer

XCTAssertTrue(customer.firstName == "Aryan", "FAIL")
XCTAssertTrue(customer.age == 28, "FAIL")
Expand All @@ -60,27 +60,27 @@ class ObjectMapperSwiftTests : XCTestCase {
XCTAssertNotNil(customer.billing, "FAIL")
XCTAssertTrue(customer.billing!.name == "SD", "FAIL")

let purchases = customer.valueForKey("purchases") as! NSArray
let purchases = customer.value(forKey: "purchases") as! NSArray

// Can't access calues directly in unit test target, swift throws exception because it doesn't know which target the models belong to, main target or unit test target. This won't be an issue outside of test environment
XCTAssertTrue(purchases.count == 3, "FAIL")
XCTAssertTrue(purchases[0].valueForKey("summary") as! String == "bla 1", "FAIL")
XCTAssertTrue(purchases[0].valueForKey("price") as! NSNumber == 123.4, "FAIL")
XCTAssertTrue(purchases[1].valueForKey("summary") as! String == "bla 2", "FAIL")
XCTAssertTrue(purchases[1].valueForKey("price") as! NSNumber == 55, "FAIL")
XCTAssertTrue(purchases[2].valueForKey("summary") as! String == "bla 3", "FAIL")
XCTAssertTrue(purchases[2].valueForKey("price") as! NSNumber == 99.99, "FAIL")
XCTAssertTrue((purchases[0] as AnyObject).value(forKey: "summary") as! String == "bla 1", "FAIL")
XCTAssertTrue((purchases[0] as AnyObject).value(forKey: "price") as! NSNumber == 123.4, "FAIL")
XCTAssertTrue((purchases[1] as AnyObject).value(forKey: "summary") as! String == "bla 2", "FAIL")
XCTAssertTrue((purchases[1] as AnyObject).value(forKey: "price") as! NSNumber == 55, "FAIL")
XCTAssertTrue((purchases[2] as AnyObject).value(forKey: "summary") as! String == "bla 3", "FAIL")
XCTAssertTrue((purchases[2] as AnyObject).value(forKey: "price") as! NSNumber == 99.99, "FAIL")
}

func testManualMapping() {
mappingProvider.mapFromDictionaryKey("fName", toPropertyKey: "firstName", forClass: Customer.self)
mappingProvider.mapFromDictionaryKey("ageee", toPropertyKey: "age", forClass: Customer.self)
mappingProvider.mapFromDictionaryKey("dob", toPropertyKey: "dateOfBirth", forClass: Customer.self)
mappingProvider.mapFromDictionaryKey("address", toPropertyKey: "location", withObjectType: Location.self, forClass: Customer.self)
mappingProvider.mapFromDictionaryKey("billing-address", toPropertyKey: "billing", withObjectType: Location.self, forClass: Customer.self)
mappingProvider.mapFromDictionaryKey("orders", toPropertyKey: "purchases", withObjectType: Purchase.self, forClass: Customer.self)
mappingProvider.map(fromDictionaryKey: "fName", toPropertyKey: "firstName", for: Customer.self)
mappingProvider.map(fromDictionaryKey: "ageee", toPropertyKey: "age", for: Customer.self)
mappingProvider.map(fromDictionaryKey: "dob", toPropertyKey: "dateOfBirth", for: Customer.self)
mappingProvider.map(fromDictionaryKey: "address", toPropertyKey: "location", withObjectType: Location.self, for: Customer.self)
mappingProvider.map(fromDictionaryKey: "billing-address", toPropertyKey: "billing", withObjectType: Location.self, for: Customer.self)
mappingProvider.map(fromDictionaryKey: "orders", toPropertyKey: "purchases", withObjectType: Purchase.self, for: Customer.self)

let date = NSDate().dateByAddingTimeInterval(-5555)
let date = NSDate().addingTimeInterval(-5555)

let dictionary = [
"fName": "Aryan",
Expand All @@ -94,9 +94,9 @@ class ObjectMapperSwiftTests : XCTestCase {
["summary": "bla 2", "price": 55],
["summary": "bla 3", "price": 99.99],
]
]
] as [String : Any]

let customer = objectMapper.objectFromSource(dictionary, toInstanceOfClass: Customer.self) as! Customer
let customer = objectMapper.object(fromSource: dictionary, toInstanceOf: Customer.self) as! Customer

XCTAssertTrue(customer.firstName == "Aryan", "FAIL")
XCTAssertTrue(customer.age == 28, "FAIL")
Expand All @@ -111,16 +111,16 @@ class ObjectMapperSwiftTests : XCTestCase {
XCTAssertNotNil(customer.status, "FAIL")
XCTAssertTrue(customer.status!.value == "banned", "FAIL")

let purchases = customer.valueForKey("purchases") as! NSArray
let purchases = customer.value(forKey: "purchases") as! NSArray

// Can't access calues directly in unit test target, swift throws exception because it doesn't know which target the models belong to, main target or unit test target. This won't be an issue outside of test environment
XCTAssertTrue(purchases.count == 3, "FAIL")
XCTAssertTrue(purchases[0].valueForKey("summary") as! String == "bla 1", "FAIL")
XCTAssertTrue(purchases[0].valueForKey("price") as! NSNumber == 123.4, "FAIL")
XCTAssertTrue(purchases[1].valueForKey("summary") as! String == "bla 2", "FAIL")
XCTAssertTrue(purchases[1].valueForKey("price") as! NSNumber == 55, "FAIL")
XCTAssertTrue(purchases[2].valueForKey("summary") as! String == "bla 3", "FAIL")
XCTAssertTrue(purchases[2].valueForKey("price") as! NSNumber == 99.99, "FAIL")
XCTAssertTrue((purchases[0] as AnyObject).value(forKey: "summary") as! String == "bla 1", "FAIL")
XCTAssertTrue((purchases[0] as AnyObject).value(forKey: "price") as! NSNumber == 123.4, "FAIL")
XCTAssertTrue((purchases[1] as AnyObject).value(forKey: "summary") as! String == "bla 2", "FAIL")
XCTAssertTrue((purchases[1] as AnyObject).value(forKey: "price") as! NSNumber == 55, "FAIL")
XCTAssertTrue((purchases[2] as AnyObject).value(forKey: "summary") as! String == "bla 3", "FAIL")
XCTAssertTrue((purchases[2] as AnyObject).value(forKey: "price") as! NSNumber == 99.99, "FAIL")
}

}