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
c5e652a3
Commit
c5e652a3
authored
May 04, 2016
by
Dima Bart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add BUYAccountCredentials tests with 100% code coverage.
parent
f71fad65
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
155 additions
and
0 deletions
+155
-0
BUYAccountCredentialsTests.m
...Buy SDK/Mobile Buy SDK Tests/BUYAccountCredentialsTests.m
+151
-0
project.pbxproj
Mobile Buy SDK/Mobile Buy SDK.xcodeproj/project.pbxproj
+4
-0
No files found.
Mobile Buy SDK/Mobile Buy SDK Tests/BUYAccountCredentialsTests.m
0 → 100644
View file @
c5e652a3
//
// BUYAccountCredentialsTests.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 <Buy/Buy.h>
@interface
BUYAccountCredentialsTests
:
XCTestCase
@end
@implementation
BUYAccountCredentialsTests
#pragma mark - Init -
-
(
void
)
testInitWithoutItems
{
BUYAccountCredentials
*
credentials
=
[
BUYAccountCredentials
credentialsWithItems
:
nil
];
XCTAssertNotNil
(
credentials
);
XCTAssertEqual
(
credentials
.
count
,
0
);
}
-
(
void
)
testInitWithItems
{
BUYAccountCredentials
*
credentials
=
[
BUYAccountCredentials
credentialsWithItems
:[
self
sampleWithValidItems
]];
XCTAssertNotNil
(
credentials
);
XCTAssertEqual
(
credentials
.
count
,
2
);
}
#pragma mark - Validation -
-
(
void
)
testValidationWithValidItems
{
BUYAccountCredentials
*
credentials
=
[
BUYAccountCredentials
credentialsWithItems
:[
self
sampleWithValidItems
]];
XCTAssertEqual
(
credentials
.
count
,
2
);
XCTAssertTrue
(
credentials
.
isValid
);
}
-
(
void
)
testValidationWithInvalidItems
{
BUYAccountCredentials
*
credentials
=
[
BUYAccountCredentials
credentialsWithItems
:[
self
sampleWithInvalidItems
]];
XCTAssertEqual
(
credentials
.
count
,
3
);
XCTAssertFalse
(
credentials
.
isValid
);
}
#pragma mark - Mutation -
-
(
void
)
testAddingUniqueItems
{
BUYAccountCredentials
*
credentials
=
[
BUYAccountCredentials
credentials
];
XCTAssertEqual
(
credentials
.
count
,
0
);
[
credentials
setCredentialItem
:[
self
emailItem
]];
XCTAssertEqual
(
credentials
.
count
,
1
);
[
credentials
setCredentialItems
:@[
[
self
passwordItem
],
[
self
passwordConfirmationItem
],
]];
XCTAssertEqual
(
credentials
.
count
,
3
);
}
-
(
void
)
testAddingDuplicateItems
{
/* ----------------------------------
* A duplicate item is considered the
* same based on the item key, not
* the value.
*/
BUYAccountCredentials
*
credentials
=
[
BUYAccountCredentials
credentials
];
XCTAssertEqual
(
credentials
.
count
,
0
);
[
credentials
setCredentialItem
:[
BUYAccountCredentialItem
itemEmailWithValue
:
@"john@appleseed.com"
]];
XCTAssertEqual
(
credentials
.
count
,
1
);
[
credentials
setCredentialItem
:[
BUYAccountCredentialItem
itemEmailWithValue
:
@"john@doe.com"
]];
XCTAssertEqual
(
credentials
.
count
,
1
);
}
#pragma mark - Serialization -
-
(
void
)
testJSONSerialization
{
BUYAccountCredentials
*
credentials
=
[
BUYAccountCredentials
credentialsWithItems
:[
self
sampleWithValidItems
]];
[
credentials
setCredentialItems
:@[
[
BUYAccountCredentialItem
itemEmailWithValue
:
@"john@doe.com"
],
[
BUYAccountCredentialItem
itemFirstNameWithValue
:
@"John"
],
[
BUYAccountCredentialItem
itemLastNameWithValue
:
@"Doe"
],
[
BUYAccountCredentialItem
itemPasswordWithValue
:
@"pass"
],
[
BUYAccountCredentialItem
itemPasswordConfirmationWithValue
:
@"pass"
],
]];
NSDictionary
*
json
=
[
credentials
JSONRepresentation
];
NSDictionary
*
customer
=
json
[
@"customer"
];
XCTAssertNotNil
(
json
);
XCTAssertEqual
(
json
.
count
,
1
);
XCTAssertNotNil
(
customer
);
XCTAssertEqual
(
customer
[
BUYAccountEmailKey
],
@"john@doe.com"
);
XCTAssertEqual
(
customer
[
BUYAccountFirstNameKey
],
@"John"
);
XCTAssertEqual
(
customer
[
BUYAccountLastNameKey
],
@"Doe"
);
XCTAssertEqual
(
customer
[
BUYAccountPasswordKey
],
@"pass"
);
XCTAssertEqual
(
customer
[
BUYAccountPasswordConfirmationKey
],
@"pass"
);
}
#pragma mark - Utilities -
-
(
BUYAccountCredentialItem
*
)
emailItem
{
return
[
BUYAccountCredentialItem
itemEmailWithValue
:
@"john@smith.com"
];
}
-
(
BUYAccountCredentialItem
*
)
passwordItem
{
return
[
BUYAccountCredentialItem
itemPasswordWithValue
:
@"password"
];
}
-
(
BUYAccountCredentialItem
*
)
passwordConfirmationItem
{
return
[
BUYAccountCredentialItem
itemPasswordConfirmationWithValue
:
@"password"
];
}
-
(
NSArray
*
)
sampleWithValidItems
{
NSMutableArray
*
items
=
[
NSMutableArray
new
];
[
items
addObject
:[
self
emailItem
]];
[
items
addObject
:[
self
passwordItem
]];
return
items
;
}
-
(
NSArray
*
)
sampleWithInvalidItems
{
NSMutableArray
*
items
=
[
NSMutableArray
new
];
[
items
addObject
:[
self
emailItem
]];
[
items
addObject
:[
BUYAccountCredentialItem
itemPasswordWithValue
:
@""
]];
[
items
addObject
:[
BUYAccountCredentialItem
itemPasswordConfirmationWithValue
:
@""
]];
return
items
;
}
@end
Mobile Buy SDK/Mobile Buy SDK.xcodeproj/project.pbxproj
View file @
c5e652a3
...
...
@@ -302,6 +302,7 @@
9A3B2DDE1CD28D7300BFF49C
/* BUYSerializable.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A3B2DDC1CD28D6F00BFF49C
/* BUYSerializable.m */
;
};
9A3B2DE01CD28E9900BFF49C
/* BUYShopifyErrorCodes.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A3B2DDF1CD28E9900BFF49C
/* BUYShopifyErrorCodes.h */
;
};
9A3B2DE11CD28E9900BFF49C
/* BUYShopifyErrorCodes.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A3B2DDF1CD28E9900BFF49C
/* BUYShopifyErrorCodes.h */
;
};
9A6B03791CDA5D4F0054C26E
/* BUYAccountCredentialsTests.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A6B03781CDA5D4F0054C26E
/* BUYAccountCredentialsTests.m */
;
};
9A9C03431CD9369400AE79BD
/* BUYCheckout_Private.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A9C03421CD9369400AE79BD
/* BUYCheckout_Private.h */
;
};
9A9C03441CD9369600AE79BD
/* BUYCheckout_Private.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A9C03421CD9369400AE79BD
/* BUYCheckout_Private.h */
;
};
BE1007951B6038150031CEE7
/* BUYProductVariant+Options.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
BE1007931B6038150031CEE7
/* BUYProductVariant+Options.h */
;
};
...
...
@@ -591,6 +592,7 @@
9A3B2DDF1CD28E9900BFF49C
/* BUYShopifyErrorCodes.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
BUYShopifyErrorCodes.h
;
sourceTree
=
"<group>"
;
};
9A3B2DE81CD2990E00BFF49C
/* BUYError+BUYAdditions.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
"BUYError+BUYAdditions.h"
;
sourceTree
=
"<group>"
;
};
9A3B2DE91CD2990E00BFF49C
/* BUYError+BUYAdditions.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
"BUYError+BUYAdditions.m"
;
sourceTree
=
"<group>"
;
};
9A6B03781CDA5D4F0054C26E
/* BUYAccountCredentialsTests.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
BUYAccountCredentialsTests.m
;
sourceTree
=
"<group>"
;
};
9A9C03421CD9369400AE79BD
/* BUYCheckout_Private.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
BUYCheckout_Private.h
;
sourceTree
=
"<group>"
;
};
BE1007931B6038150031CEE7
/* BUYProductVariant+Options.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
"BUYProductVariant+Options.h"
;
sourceTree
=
"<group>"
;
};
BE1007941B6038150031CEE7
/* BUYProductVariant+Options.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
"BUYProductVariant+Options.m"
;
sourceTree
=
"<group>"
;
};
...
...
@@ -832,6 +834,7 @@
84CA59BA1CD1378100B2A956
/* BUYTestModel.xcdatamodeld */
,
90F592F91B0D5F4C0026B382
/* BUYApplePayAdditionsTest.m */
,
8491102E1CCE708900E53B93
/* BUYArrayAdditionsTests.m */
,
9A6B03781CDA5D4F0054C26E
/* BUYAccountCredentialsTests.m */
,
90F592FA1B0D5F4C0026B382
/* BUYCartTest.m */
,
90F592FB1B0D5F4C0026B382
/* BUYCheckoutTest.m */
,
90F592FC1B0D5F4C0026B382
/* BUYClientTest_Storefront.m */
,
...
...
@@ -1551,6 +1554,7 @@
849110331CCE708900E53B93
/* BUYStringAdditionsTests.m in Sources */
,
906CF1B11B8B66AE001F7D5B
/* BUYCNPostalAddress.m in Sources */
,
84CA59BC1CD1378100B2A956
/* BUYTestModel.xcdatamodeld in Sources */
,
9A6B03791CDA5D4F0054C26E
/* BUYAccountCredentialsTests.m in Sources */
,
8491103C1CCE731900E53B93
/* BUYURLAdditionsTests.m in Sources */
,
849110401CCE9DFB00E53B93
/* BUYCoreDataModelAdditionsTests.m in Sources */
,
84CA59C01CD1609400B2A956
/* TestModel.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