Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
shopify_iossdk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cemarose
shopify_iossdk
Commits
02d9dfdb
Commit
02d9dfdb
authored
Apr 25, 2016
by
Brent Gulanowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test classes for JSON transformation and value transformation.
parent
cd2b7c7f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
310 additions
and
1 deletions
+310
-1
BUYEntityDescriptionAdditionsTests.m
...Mobile Buy SDK Tests/BUYEntityDescriptionAdditionsTests.m
+57
-0
BUYPropertyDescriptionAdditionsTests.m
...bile Buy SDK Tests/BUYPropertyDescriptionAdditionsTests.m
+57
-0
BUYTransformerTests.m
Mobile Buy SDK/Mobile Buy SDK Tests/BUYTransformerTests.m
+184
-0
project.pbxproj
Mobile Buy SDK/Mobile Buy SDK.xcodeproj/project.pbxproj
+12
-1
No files found.
Mobile Buy SDK/Mobile Buy SDK Tests/BUYEntityDescriptionAdditionsTests.m
0 → 100644
View file @
02d9dfdb
//
// BUYEntityDescriptionAdditionsTests.m
// Mobile Buy SDK
//
// Created by Shopify.
// Copyright (c) 2015 Shopify Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#import <XCTest/XCTest.h>
@interface
BUYEntityDescriptionAdditionsTests
:
XCTestCase
@end
@implementation
BUYEntityDescriptionAdditionsTests
-
(
void
)
setUp
{
[
super
setUp
];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
-
(
void
)
tearDown
{
// Put teardown code here. This method is called after the invocation of each test method in the class.
[
super
tearDown
];
}
-
(
void
)
testExample
{
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
-
(
void
)
testPerformanceExample
{
// This is an example of a performance test case.
[
self
measureBlock
:
^
{
// Put the code you want to measure the time of here.
}];
}
@end
Mobile Buy SDK/Mobile Buy SDK Tests/BUYPropertyDescriptionAdditionsTests.m
0 → 100644
View file @
02d9dfdb
//
// BUYPropertyDescriptionAdditionsTests.m
// Mobile Buy SDK
//
// Created by Shopify.
// Copyright (c) 2015 Shopify Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#import <XCTest/XCTest.h>
@interface
BUYPropertyDescriptionAdditionsTests
:
XCTestCase
@end
@implementation
BUYPropertyDescriptionAdditionsTests
-
(
void
)
setUp
{
[
super
setUp
];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
-
(
void
)
tearDown
{
// Put teardown code here. This method is called after the invocation of each test method in the class.
[
super
tearDown
];
}
-
(
void
)
testExample
{
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
-
(
void
)
testPerformanceExample
{
// This is an example of a performance test case.
[
self
measureBlock
:
^
{
// Put the code you want to measure the time of here.
}];
}
@end
Mobile Buy SDK/Mobile Buy SDK Tests/BUYTransformerTests.m
0 → 100644
View file @
02d9dfdb
//
// BUYModelTransformerTests.m
// Mobile Buy SDK
//
// Created by Shopify.
// Copyright (c) 2015 Shopify Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#import <XCTest/XCTest.h>
#import "BUYFlatCollectionTransformer.h"
@interface
BUYModelTransformerTests
:
XCTestCase
@end
@implementation
BUYModelTransformerTests
-
(
void
)
testIdentityTransformer
{
id
value
=
@"value"
;
NSValueTransformer
*
transformer
=
[
self
identityTransformer
];
id
expected
=
value
;
id
actual
=
[
transformer
transformedValue
:
value
];
XCTAssertEqualObjects
(
actual
,
expected
,
@"transformed value was incorrect"
);
actual
=
[
transformer
reverseTransformedValue
:
value
];
XCTAssertEqualObjects
(
actual
,
expected
,
@"reverse transformed value was incorrect"
);
}
-
(
void
)
testDecimalTransformer
{
id
value
=
[
NSDecimalNumber
decimalNumberWithMantissa
:
256
exponent
:
-
2
isNegative
:
NO
];
id
string
=
@"2.56"
;
NSValueTransformer
*
transformer
=
[
NSValueTransformer
valueTransformerForName
:
@"BUYDecimalNumber"
];
id
expected
=
string
;
id
actual
=
[
transformer
transformedValue
:
value
];
XCTAssertEqualObjects
(
actual
,
expected
,
@"transformed value was incorrect"
);
expected
=
value
;
actual
=
[
transformer
reverseTransformedValue
:
string
];
XCTAssertEqualObjects
(
actual
,
expected
,
@"reverse transformed value was incorrect"
);
}
-
(
void
)
testPublicationDateTransformer
{
NSValueTransformer
*
transformer
=
[
NSValueTransformer
valueTransformerForName
:
@"BUYPublicationsDate"
];
NSDate
*
value
=
[
self
dateForTransformerTestingWithMilliseconds
:
0
];
NSString
*
string
=
@"1970-06-21T08:11:59-0400"
;
id
expected
=
string
;
id
actual
=
[
transformer
transformedValue
:
value
];
XCTAssertEqualObjects
(
actual
,
expected
,
@"Transformed date with incorrect"
);
expected
=
value
;
actual
=
[
transformer
reverseTransformedValue
:
string
];
XCTAssertEqualObjects
(
actual
,
expected
,
@"Reverse transformed date with incorrect"
);
}
-
(
void
)
testShippingDateTransformer
{
NSValueTransformer
*
transformer
=
[
NSValueTransformer
valueTransformerForName
:
@"BUYShippingRateDate"
];
NSDate
*
value
=
[
self
dateForTransformerTestingWithMilliseconds
:
543
];
NSString
*
string
=
@"1970-06-21T08:11:59.543-0400"
;
id
expected
=
string
;
id
actual
=
[
transformer
transformedValue
:
value
];
XCTAssertEqualObjects
(
actual
,
expected
,
@"Transformed date with incorrect"
);
expected
=
value
;
actual
=
[
transformer
reverseTransformedValue
:
string
];
XCTAssertEqualObjects
(
actual
,
expected
,
@"Reverse transformed date with incorrect"
);
}
-
(
NSDate
*
)
dateForTransformerTestingWithMilliseconds
:
(
NSInteger
)
milliseconds
{
NSDateComponents
*
dc
=
[[
NSDateComponents
alloc
]
init
];
dc
.
calendar
=
[
NSCalendar
calendarWithIdentifier
:
NSCalendarIdentifierGregorian
];
dc
.
timeZone
=
[
NSTimeZone
timeZoneWithAbbreviation
:
@"EST"
];
dc
.
year
=
1970
;
dc
.
month
=
6
;
dc
.
day
=
21
;
dc
.
hour
=
8
;
dc
.
minute
=
11
;
dc
.
second
=
59
;
dc
.
nanosecond
=
NSEC_PER_MSEC
*
milliseconds
;
return
dc
.
date
;
}
-
(
void
)
testFlatArrayTransformer
{
NSValueTransformer
*
elementTransformer
=
[
NSValueTransformer
valueTransformerForName
:
@"BUYURL"
];
NSValueTransformer
*
arrayTransformer
=
[
BUYFlatCollectionTransformer
arrayTransformerWithElementTransformer
:
elementTransformer
separator
:
@"||"
];
NSString
*
URLString1
=
@"http://www.shopify.com"
;
NSString
*
URLString2
=
@"https://test-store.myshopify.com/meta.json"
;
NSURL
*
testURL
=
[
self
urlForTesting
];
NSString
*
URLString3
=
[
testURL
absoluteString
];
NSArray
*
array
=
@[
[
NSURL
URLWithString
:
URLString1
],
[
NSURL
URLWithString
:
URLString2
],
testURL
,
];
NSString
*
string
=
[
NSString
stringWithFormat
:
@"%@||%@||%@"
,
URLString1
,
URLString2
,
URLString3
];
id
expected
=
string
;
id
actual
=
[
arrayTransformer
transformedValue
:
array
];
XCTAssertEqualObjects
(
actual
,
expected
,
@"String encoding of flat array of URLs was incorrect"
);
expected
=
array
;
actual
=
[
arrayTransformer
reverseTransformedValue
:
string
];
XCTAssertEqualObjects
(
actual
,
expected
,
@"Array of URLs decoded from string was incorrect"
);
}
-
(
NSURL
*
)
urlForTesting
{
NSURLComponents
*
components
=
[[
NSURLComponents
alloc
]
init
];
components
.
scheme
=
@"ftp"
;
components
.
host
=
@"private.example.com"
;
components
.
path
=
@"/authenticated/internal/account"
;
components
.
port
=
@3322
;
components
.
query
=
@"settings=recent"
;
components
.
user
=
@"user123"
;
components
.
password
=
@"secret!@#$"
;
return
[
components
URL
];
}
-
(
void
)
testFlatSetTransformer
{
NSValueTransformer
*
setTransformer
=
[
BUYFlatCollectionTransformer
setTransformerWithElementTransformer
:[
self
identityTransformer
]
separator
:
@", "
];
// We can't verify the intermediate string version without decoding it into a set directly,
// because we can't control the order of the values
id
expected
=
[
NSSet
setWithObjects
:
@"A"
,
@"B"
,
@"C"
,
nil
];
id
actual
=
[
setTransformer
reverseTransformedValue
:[
setTransformer
transformedValue
:
expected
]];
XCTAssertEqualObjects
(
actual
,
expected
,
@"Set of strings was not the same after round trip transformation"
);
}
-
(
void
)
testFlatOrderedSetTransformer
{
NSValueTransformer
*
orderedSetTransformer
=
[
BUYFlatCollectionTransformer
orderedSetTransformerWithElementTransformer
:[
self
identityTransformer
]
separator
:
@", "
];
NSOrderedSet
*
orderedSet
=
[
NSOrderedSet
orderedSetWithObjects
:
@"1"
,
@"2"
,
@"3"
,
nil
];
NSString
*
string
=
@"1, 2, 3"
;
id
expected
=
string
;
id
actual
=
[
orderedSetTransformer
transformedValue
:
orderedSet
];
XCTAssertEqualObjects
(
actual
,
expected
,
@"String encoding of flat ordered set was incorrect"
);
expected
=
orderedSet
;
actual
=
[
orderedSetTransformer
reverseTransformedValue
:
string
];
XCTAssertEqualObjects
(
actual
,
expected
,
@"Ordered set decoded from string was incorrect"
);
}
-
(
NSValueTransformer
*
)
identityTransformer
{
return
[
NSValueTransformer
valueTransformerForName
:
@"BUYIdentity"
];
}
@end
Mobile Buy SDK/Mobile Buy SDK.xcodeproj/project.pbxproj
View file @
02d9dfdb
...
...
@@ -80,6 +80,9 @@
8491103A1CCE718100E53B93
/* BUYExceptionAdditionsTests.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
849110391CCE718100E53B93
/* BUYExceptionAdditionsTests.m */
;
};
8491103C1CCE731900E53B93
/* BUYURLAdditionsTests.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
8491103B1CCE731900E53B93
/* BUYURLAdditionsTests.m */
;
};
8491103E1CCE988600E53B93
/* BUYFontAdditionsTests.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
8491103D1CCE988600E53B93
/* BUYFontAdditionsTests.m */
;
};
849110401CCE9DFB00E53B93
/* BUYPropertyDescriptionAdditionsTests.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
8491103F1CCE9DFB00E53B93
/* BUYPropertyDescriptionAdditionsTests.m */
;
};
849110421CCE9E0A00E53B93
/* BUYEntityDescriptionAdditionsTests.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
849110411CCE9E0A00E53B93
/* BUYEntityDescriptionAdditionsTests.m */
;
};
849110441CCE9F3F00E53B93
/* BUYTransformerTests.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
849110431CCE9F3F00E53B93
/* BUYTransformerTests.m */
;
};
84980F291CB75AC200CFAB58
/* BUYObjectProtocol.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
84980F281CB75AC200CFAB58
/* BUYObjectProtocol.h */
;
};
84980F2A1CB75AC200CFAB58
/* BUYObjectProtocol.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
84980F281CB75AC200CFAB58
/* BUYObjectProtocol.h */
;
};
84980F2C1CB75B5E00CFAB58
/* BUYModelManagerProtocol.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
84980F2B1CB75B5E00CFAB58
/* BUYModelManagerProtocol.h */
;
};
...
...
@@ -443,6 +446,9 @@
849110391CCE718100E53B93
/* BUYExceptionAdditionsTests.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
BUYExceptionAdditionsTests.m
;
sourceTree
=
"<group>"
;
};
8491103B1CCE731900E53B93
/* BUYURLAdditionsTests.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
BUYURLAdditionsTests.m
;
sourceTree
=
"<group>"
;
};
8491103D1CCE988600E53B93
/* BUYFontAdditionsTests.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
BUYFontAdditionsTests.m
;
sourceTree
=
"<group>"
;
};
8491103F1CCE9DFB00E53B93
/* BUYPropertyDescriptionAdditionsTests.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
BUYPropertyDescriptionAdditionsTests.m
;
sourceTree
=
"<group>"
;
};
849110411CCE9E0A00E53B93
/* BUYEntityDescriptionAdditionsTests.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
BUYEntityDescriptionAdditionsTests.m
;
sourceTree
=
"<group>"
;
};
849110431CCE9F3F00E53B93
/* BUYTransformerTests.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
BUYTransformerTests.m
;
sourceTree
=
"<group>"
;
};
84980F281CB75AC200CFAB58
/* BUYObjectProtocol.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
BUYObjectProtocol.h
;
sourceTree
=
"<group>"
;
};
84980F2B1CB75B5E00CFAB58
/* BUYModelManagerProtocol.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
BUYModelManagerProtocol.h
;
sourceTree
=
"<group>"
;
};
84980F2E1CB75C2900CFAB58
/* NSEntityDescription+BUYAdditions.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
"NSEntityDescription+BUYAdditions.h"
;
sourceTree
=
"<group>"
;
};
...
...
@@ -798,14 +804,17 @@
BEB9AE7A1BA866D000575F8A
/* BUYClientTestBase.h */
,
BEB9AE7C1BA8685600575F8A
/* BUYClientTestBase.m */
,
849110341CCE70CE00E53B93
/* BUYDictionaryAdditionsTests.m */
,
849110411CCE9E0A00E53B93
/* BUYEntityDescriptionAdditionsTests.m */
,
849110391CCE718100E53B93
/* BUYExceptionAdditionsTests.m */
,
8491103D1CCE988600E53B93
/* BUYFontAdditionsTests.m */
,
90F592F81B0D5F4C0026B382
/* BUYIntegrationTest.m */
,
90F592FE1B0D5F4C0026B382
/* BUYLineItemTest.m */
,
90F592FF1B0D5F4C0026B382
/* BUYObjectTests.m */
,
8491103F1CCE9DFB00E53B93
/* BUYPropertyDescriptionAdditionsTests.m */
,
8491102F1CCE708900E53B93
/* BUYRegularExpressionAdditionsTests.m */
,
849110301CCE708900E53B93
/* BUYStringAdditionsTests.m */
,
90F593001B0D5F4C0026B382
/* BUYTestConstants.h */
,
849110431CCE9F3F00E53B93
/* BUYTransformerTests.m */
,
8491103B1CCE731900E53B93
/* BUYURLAdditionsTests.m */
,
BE6C07051BB1E46900BD9F7B
/* mocked_responses.json */
,
BE98DB5A1BB1F4D000C29564
/* OHHTTPStubsResponse+Helpers.h */
,
...
...
@@ -1462,8 +1471,9 @@
files
=
(
BEB9AE7D1BA885E300575F8A
/* BUYClientTestBase.m in Sources */
,
8491103E1CCE988600E53B93
/* BUYFontAdditionsTests.m in Sources */
,
BEB9AE7B1BA866D000575F8A
/* BUYClientTestBase.h
in Sources */
,
849110421CCE9E0A00E53B93
/* BUYEntityDescriptionAdditionsTests.m
in Sources */
,
8491103A1CCE718100E53B93
/* BUYExceptionAdditionsTests.m in Sources */
,
849110441CCE9F3F00E53B93
/* BUYTransformerTests.m in Sources */
,
849110351CCE70CE00E53B93
/* BUYDictionaryAdditionsTests.m in Sources */
,
90F5930A1B0D5F4C0026B382
/* BUYLineItemTest.m in Sources */
,
849110321CCE708900E53B93
/* BUYRegularExpressionAdditionsTests.m in Sources */
,
...
...
@@ -1478,6 +1488,7 @@
849110331CCE708900E53B93
/* BUYStringAdditionsTests.m in Sources */
,
906CF1B11B8B66AE001F7D5B
/* BUYCNPostalAddress.m in Sources */
,
8491103C1CCE731900E53B93
/* BUYURLAdditionsTests.m in Sources */
,
849110401CCE9DFB00E53B93
/* BUYPropertyDescriptionAdditionsTests.m in Sources */
,
906CF1AD1B8B5F7D001F7D5B
/* BUYNSPersonNameComponents.m in Sources */
,
BE98DB5C1BB1F4D000C29564
/* OHHTTPStubsResponse+Helpers.m in Sources */
,
849110311CCE708900E53B93
/* BUYArrayAdditionsTests.m in Sources */
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment