mirror of
https://github.com/VKCOM/vk-ios-sdk.git
synced 2024-09-11 06:45:37 +03:00
Add two basic test for loading and parsing
This commit is contained in:
parent
906e8b657b
commit
ecf361ff88
@ -80,6 +80,7 @@
|
||||
F32ADDCF1A417CE9009A9FD6 /* ic_vk_activity_logo@2x~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = F32ADDCA1A417C4C009A9FD6 /* ic_vk_activity_logo@2x~ipad.png */; };
|
||||
F32ADDD01A417CE9009A9FD6 /* ic_vk_activity_logo@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = F32ADDCB1A417C4C009A9FD6 /* ic_vk_activity_logo@3x.png */; };
|
||||
F32ADDD11A417CE9009A9FD6 /* ic_vk_activity_logo~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = F32ADDCC1A417C4C009A9FD6 /* ic_vk_activity_logo~ipad.png */; };
|
||||
F34074F61D214AAC00F65798 /* SafariServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F3769E701BE8E41C00AEC4AF /* SafariServices.framework */; };
|
||||
F3454FD01ABB1D1A00B15E85 /* VKRequestsScheduler.m in Sources */ = {isa = PBXBuildFile; fileRef = F3454FCF1ABB1D1A00B15E85 /* VKRequestsScheduler.m */; };
|
||||
F34670201B8B6BF3003EF74B /* VKSdk.h in Copy Files */ = {isa = PBXBuildFile; fileRef = F34670171B8B50E0003EF74B /* VKSdk.h */; };
|
||||
F34670361B8B7C5A003EF74B /* VKSdkFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = F34670351B8B7C5A003EF74B /* VKSdkFramework.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
@ -290,6 +291,8 @@
|
||||
F3BACC481865905B003158DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = F3BACC461865905B003158DA /* InfoPlist.strings */; };
|
||||
F3BACC61186883E8003158DA /* ic_vk_logo_nb.png in Resources */ = {isa = PBXBuildFile; fileRef = F3BACC5F186883E8003158DA /* ic_vk_logo_nb.png */; };
|
||||
F3BACC62186883E8003158DA /* ic_vk_logo_nb@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = F3BACC60186883E8003158DA /* ic_vk_logo_nb@2x.png */; };
|
||||
F3C58CD01D213B2C005E94B5 /* VKSdkTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F3C58CCF1D213B2C005E94B5 /* VKSdkTests.m */; };
|
||||
F3C58CF61D2140F4005E94B5 /* libVKSdk.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F3C7542D182133CC00964716 /* libVKSdk.a */; };
|
||||
F3C68F151C0C7E6600E1EB5E /* SafariServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F3769E701BE8E41C00AEC4AF /* SafariServices.framework */; };
|
||||
F3C68F171C0C855C00E1EB5E /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F3C68F161C0C855C00E1EB5E /* Security.framework */; };
|
||||
F3C68F181C0C857F00E1EB5E /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F3769E6E1BE8E41800AEC4AF /* CoreGraphics.framework */; };
|
||||
@ -307,6 +310,13 @@
|
||||
remoteGlobalIDString = F3BACC3F1865905B003158DA;
|
||||
remoteInfo = VKSdkResources;
|
||||
};
|
||||
F3C58CF41D2140D2005E94B5 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F3C75425182133CB00964716 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = F3C7542C182133CC00964716;
|
||||
remoteInfo = VKSdk;
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
@ -515,6 +525,9 @@
|
||||
F3BACC5718659493003158DA /* VKBundle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VKBundle.m; sourceTree = "<group>"; };
|
||||
F3BACC5F186883E8003158DA /* ic_vk_logo_nb.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ic_vk_logo_nb.png; sourceTree = "<group>"; };
|
||||
F3BACC60186883E8003158DA /* ic_vk_logo_nb@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ic_vk_logo_nb@2x.png"; sourceTree = "<group>"; };
|
||||
F3C58CCD1D213B2C005E94B5 /* VKSdkTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VKSdkTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
F3C58CCF1D213B2C005E94B5 /* VKSdkTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VKSdkTests.m; sourceTree = "<group>"; };
|
||||
F3C58CD11D213B2C005E94B5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
F3C68F161C0C855C00E1EB5E /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
|
||||
F3C7542D182133CC00964716 /* libVKSdk.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libVKSdk.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
F3C75430182133CC00964716 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
@ -551,6 +564,15 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
F3C58CCA1D213B2C005E94B5 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F34074F61D214AAC00F65798 /* SafariServices.framework in Frameworks */,
|
||||
F3C58CF61D2140F4005E94B5 /* libVKSdk.a in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
F3C7542A182133CC00964716 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@ -791,12 +813,22 @@
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F3C58CCE1D213B2C005E94B5 /* VKSdkTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F3C58CCF1D213B2C005E94B5 /* VKSdkTests.m */,
|
||||
F3C58CD11D213B2C005E94B5 /* Info.plist */,
|
||||
);
|
||||
path = VKSdkTests;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F3C75424182133CB00964716 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F3C75432182133CC00964716 /* VKSdk */,
|
||||
F3BACC431865905B003158DA /* Resources */,
|
||||
F34670321B8B7C5A003EF74B /* DynamicFramework */,
|
||||
F3C58CCE1D213B2C005E94B5 /* VKSdkTests */,
|
||||
F3C7542F182133CC00964716 /* Frameworks */,
|
||||
F3C7542E182133CC00964716 /* Products */,
|
||||
);
|
||||
@ -808,6 +840,7 @@
|
||||
F3C7542D182133CC00964716 /* libVKSdk.a */,
|
||||
F3BACC401865905B003158DA /* VKSdkResources.bundle */,
|
||||
F34670311B8B7C5A003EF74B /* VKSdkFramework.framework */,
|
||||
F3C58CCD1D213B2C005E94B5 /* VKSdkTests.xctest */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@ -965,6 +998,24 @@
|
||||
productReference = F3BACC401865905B003158DA /* VKSdkResources.bundle */;
|
||||
productType = "com.apple.product-type.bundle";
|
||||
};
|
||||
F3C58CCC1D213B2C005E94B5 /* VKSdkTests */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = F3C58CD41D213B2C005E94B5 /* Build configuration list for PBXNativeTarget "VKSdkTests" */;
|
||||
buildPhases = (
|
||||
F3C58CC91D213B2C005E94B5 /* Sources */,
|
||||
F3C58CCA1D213B2C005E94B5 /* Frameworks */,
|
||||
F3C58CCB1D213B2C005E94B5 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
F3C58CF51D2140D2005E94B5 /* PBXTargetDependency */,
|
||||
);
|
||||
name = VKSdkTests;
|
||||
productName = VKSdkTests;
|
||||
productReference = F3C58CCD1D213B2C005E94B5 /* VKSdkTests.xctest */;
|
||||
productType = "com.apple.product-type.bundle.ui-testing";
|
||||
};
|
||||
F3C7542C182133CC00964716 /* VKSdk */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = F3C75450182133CC00964716 /* Build configuration list for PBXNativeTarget "VKSdk" */;
|
||||
@ -997,6 +1048,12 @@
|
||||
F34670301B8B7C5A003EF74B = {
|
||||
CreatedOnToolsVersion = 6.4;
|
||||
};
|
||||
F3C58CCC1D213B2C005E94B5 = {
|
||||
CreatedOnToolsVersion = 8.0;
|
||||
DevelopmentTeam = R26JY69RPL;
|
||||
DevelopmentTeamName = VKontakte;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = F3C75428182133CB00964716 /* Build configuration list for PBXProject "VK-ios-sdk" */;
|
||||
@ -1016,6 +1073,7 @@
|
||||
F3C7542C182133CC00964716 /* VKSdk */,
|
||||
F3BACC3F1865905B003158DA /* VKSdkResources */,
|
||||
F34670301B8B7C5A003EF74B /* VKSdkFramework */,
|
||||
F3C58CCC1D213B2C005E94B5 /* VKSdkTests */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
@ -1098,6 +1156,13 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
F3C58CCB1D213B2C005E94B5 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
@ -1187,6 +1252,14 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
F3C58CC91D213B2C005E94B5 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F3C58CD01D213B2C005E94B5 /* VKSdkTests.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
F3C75429182133CC00964716 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@ -1257,6 +1330,11 @@
|
||||
target = F3BACC3F1865905B003158DA /* VKSdkResources */;
|
||||
targetProxy = F34670261B8B7A59003EF74B /* PBXContainerItemProxy */;
|
||||
};
|
||||
F3C58CF51D2140D2005E94B5 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = F3C7542C182133CC00964716 /* VKSdk */;
|
||||
targetProxy = F3C58CF41D2140D2005E94B5 /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
@ -1387,6 +1465,51 @@
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
F3C58CD21D213B2C005E94B5 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
INFOPLIST_FILE = VKSdkTests/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = ru.truba.VKSdkTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE = "";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
F3C58CD31D213B2C005E94B5 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
INFOPLIST_FILE = VKSdkTests/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = ru.truba.VKSdkTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE = "";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
F3C7544E182133CC00964716 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
@ -1522,6 +1645,15 @@
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
F3C58CD41D213B2C005E94B5 /* Build configuration list for PBXNativeTarget "VKSdkTests" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
F3C58CD21D213B2C005E94B5 /* Debug */,
|
||||
F3C58CD31D213B2C005E94B5 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
F3C75428182133CB00964716 /* Build configuration list for PBXProject "VK-ios-sdk" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
|
24
VKSdkTests/Info.plist
Normal file
24
VKSdkTests/Info.plist
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
122
VKSdkTests/VKSdkTests.m
Normal file
122
VKSdkTests/VKSdkTests.m
Normal file
@ -0,0 +1,122 @@
|
||||
//
|
||||
// VKSdkTests.m
|
||||
// VKSdkTests
|
||||
//
|
||||
// Created by Roman Truba on 27.06.16.
|
||||
// Copyright © 2016 VK. All rights reserved.
|
||||
//
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
#import "VKUser.h"
|
||||
#import "VKUtil.h"
|
||||
#import "VKSdk.h"
|
||||
|
||||
@interface VKSdkTests : XCTestCase
|
||||
|
||||
@end
|
||||
|
||||
@implementation VKSdkTests
|
||||
|
||||
- (void)setUp {
|
||||
[super setUp];
|
||||
|
||||
self.continueAfterFailure = NO;
|
||||
|
||||
[VKSdk initializeWithAppId:@"3974615" apiVersion:@"5.50"];
|
||||
}
|
||||
|
||||
- (void)tearDown {
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
[super tearDown];
|
||||
}
|
||||
|
||||
static NSString *const ALL_USER_FIELDS = @"id,first_name,last_name,sex,bdate,city,country,photo_50,photo_100,photo_200_orig,photo_200,photo_400_orig,photo_max,photo_max_orig,online,online_mobile,lists,domain,has_mobile,contacts,connections,site,education,universities,schools,can_post,can_see_all_posts,can_see_audio,can_write_private_message,status,last_seen,relation,relatives,counters";
|
||||
|
||||
- (void)testApi {
|
||||
VKRequest *request = [VKRequest requestWithMethod:@"users.get" parameters:@{VK_API_USER_ID : @1, VK_API_FIELDS : ALL_USER_FIELDS} modelClass:[VKUsersArray class]];
|
||||
[request setPreferredLang:@"ru"];
|
||||
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:[NSString stringWithFormat:@"Api call: %@", request.methodName]];
|
||||
|
||||
[request executeWithResultBlock:^(VKResponse<VKUsersArray*> *response) {
|
||||
XCTAssertNotNil(response.parsedModel);
|
||||
XCTAssertTrue([response.parsedModel isKindOfClass:[VKUsersArray class]]);
|
||||
|
||||
NSError *error = nil;
|
||||
NSDictionary *jsonObject = [NSJSONSerialization JSONObjectWithData:[response.responseString dataUsingEncoding:NSUTF8StringEncoding] options:0 error:&error];
|
||||
XCTAssertNil(error);
|
||||
[self validateUsers:response.parsedModel withJsonData:jsonObject];
|
||||
|
||||
[expectation fulfill];
|
||||
} errorBlock:^(NSError *error) {
|
||||
XCTAssertNil(error);
|
||||
}];
|
||||
|
||||
[self waitForExpectationsWithTimeout:5.f handler:^(NSError * _Nullable error) {
|
||||
NSLog(@"Request timed out %@", error);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)testUserParse {
|
||||
NSString *PaulDurov = @"{\"response\":[{\"id\":1,\"first_name\":\"Павел\",\"last_name\":\"Дуров\",\"sex\":2,\"domain\":\"durov\",\"bdate\":\"10.10.1984\",\"city\":{\"id\":2,\"title\":\"Санкт-Петербург\"},\"country\":{\"id\":1,\"title\":\"Россия\"},\"photo_50\":\"https:\\/\\/pp.vk.me\\/c629231\\/v629231001\\/c543\\/FfB--bOEVOY.jpg\",\"photo_100\":\"https:\\/\\/pp.vk.me\\/c629231\\/v629231001\\/c542\\/fcMCbfjDsv0.jpg\",\"photo_200\":\"https:\\/\\/pp.vk.me\\/c629231\\/v629231001\\/c541\\/TaUV7CG7RHg.jpg\",\"photo_max\":\"https:\\/\\/pp.vk.me\\/c629231\\/v629231001\\/c541\\/TaUV7CG7RHg.jpg\",\"photo_200_orig\":\"https:\\/\\/pp.vk.me\\/c629231\\/v629231001\\/c535\\/Aolq7Qohi2o.jpg\",\"photo_400_orig\":\"https:\\/\\/pp.vk.me\\/c629231\\/v629231001\\/c536\\/dcqdvDEUs4E.jpg\",\"photo_max_orig\":\"https:\\/\\/pp.vk.me\\/c629231\\/v629231001\\/c536\\/dcqdvDEUs4E.jpg\",\"has_mobile\":1,\"online\":0,\"can_post\":0,\"can_see_all_posts\":0,\"can_see_audio\":0,\"can_write_private_message\":0,\"twitter\":\"durov\",\"instagram\":\"durov\",\"site\":\"http:\\/\\/telegram.org\",\"status\":\"道德經\",\"last_seen\":{\"time\":1398447188,\"platform\":7},\"common_count\":2,\"counters\":{\"albums\":2,\"videos\":14,\"audios\":0,\"notes\":6,\"photos\":226,\"friends\":721,\"online_friends\":126,\"mutual_friends\":2,\"followers\":6062370,\"subscriptions\":1,\"pages\":42},\"university\":1,\"university_name\":\"СПбГУ\",\"faculty\":0,\"faculty_name\":\"\",\"graduation\":2006,\"relation\":0,\"universities\":[{\"id\":1,\"country\":1,\"city\":2,\"name\":\"СПбГУ\",\"graduation\":2006}],\"schools\":[{\"id\":\"1035386\",\"country\":88,\"city\":16,\"name\":\"Sc.Elem. Coppino - Falletti di Barolo\",\"year_from\":1990,\"year_to\":1992,\"class\":\"\"},{\"id\":\"1\",\"country\":1,\"city\":2,\"name\":\"Академическая гимназия (АГ) СПбГУ\",\"year_from\":1996,\"year_to\":2001,\"year_graduated\":2001,\"class\":\"о\",\"type\":1,\"type_str\":\"Гимназия\"}],\"relatives\":[]}]}";
|
||||
|
||||
NSError *error = nil;
|
||||
NSDictionary *jsonObject = [NSJSONSerialization JSONObjectWithData:[PaulDurov dataUsingEncoding:NSUTF8StringEncoding] options:0 error:&error];
|
||||
XCTAssertNil(error);
|
||||
|
||||
__block VKUsersArray *users = [[VKUsersArray alloc] initWithDictionary:jsonObject];
|
||||
XCTAssert(users.count == 1);
|
||||
XCTAssert(users.items.count == 1);
|
||||
|
||||
[self validateUsers:users withJsonData:jsonObject];
|
||||
}
|
||||
|
||||
- (void)validateUsers:(VKUsersArray*)users withJsonData:(NSDictionary*)jsonData {
|
||||
|
||||
VKUser *user = users.items.firstObject;
|
||||
|
||||
NSArray *jsonResponse = VK_ENSURE_ARRAY(jsonData[@"response"]);
|
||||
XCTAssertNotNil(jsonResponse);
|
||||
NSDictionary *jsonUser = VK_ENSURE_DICT(jsonResponse.firstObject);
|
||||
|
||||
for (NSString *key in jsonUser) {
|
||||
id userValue = [user valueForKey:key];
|
||||
XCTAssertNotNil(userValue);
|
||||
|
||||
NSDictionary *dictValue = VK_ENSURE_DICT(jsonUser[key]);
|
||||
if (dictValue) {
|
||||
NSLog(@"%@ %@", key, [userValue class]);
|
||||
XCTAssert([userValue isKindOfClass:[VKApiObject class]] == YES);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
XCTAssertNotNil(user);
|
||||
XCTAssertEqualObjects(user.first_name, @"Павел");
|
||||
XCTAssertEqualObjects(user.last_name, @"Дуров");
|
||||
|
||||
XCTAssertNotNil(VK_ENSURE(user.country, [VKCountry class]));
|
||||
XCTAssertEqualObjects(user.country.id, @(1));
|
||||
XCTAssertEqualObjects(user.country.title, @"Россия");
|
||||
|
||||
// Universities
|
||||
XCTAssertNotNil(VK_ENSURE(user.universities, [VKUniversities class]));
|
||||
XCTAssertEqual(user.universities.count, 1);
|
||||
|
||||
VKUniversity *university = user.universities.firstObject;
|
||||
XCTAssertNotNil(university);
|
||||
XCTAssertEqualObjects(university.name, @"СПбГУ");
|
||||
|
||||
// Schools
|
||||
XCTAssertNotNil(VK_ENSURE(user.schools, [VKSchools class]));
|
||||
XCTAssertEqual(user.schools.count, 2);
|
||||
for (VKSchool *school in user.schools) {
|
||||
XCTAssertNotNil(VK_ENSURE(school, [VKSchool class]));
|
||||
XCTAssertNotNil(school.id);
|
||||
XCTAssertNotNil(school.name);
|
||||
XCTAssertNotNil(school.name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@end
|
@ -88,6 +88,7 @@
|
||||
@property(nonatomic, strong) NSString *last_name_dat;
|
||||
@property(nonatomic, strong) NSString *first_name_ins;
|
||||
@property(nonatomic, strong) NSString *last_name_ins;
|
||||
@property(nonatomic, strong) NSString *domain;
|
||||
@property(nonatomic, strong) VKPersonal *personal;
|
||||
@property(nonatomic, strong) NSNumber *sex;
|
||||
@property(nonatomic, strong) NSNumber *invited_by;
|
||||
@ -114,6 +115,7 @@
|
||||
@property(nonatomic, strong) VKExports *exports;
|
||||
@property(nonatomic, strong) NSNumber *wall_comments;
|
||||
@property(nonatomic, assign) BOOL can_write_private_message;
|
||||
@property(nonatomic, assign) BOOL can_see_audio;
|
||||
@property(nonatomic, strong) NSString *phone;
|
||||
@property(nonatomic, strong) NSNumber *online_mobile;
|
||||
@property(nonatomic, strong) NSNumber *faculty;
|
||||
@ -122,6 +124,7 @@
|
||||
@property(nonatomic, strong) VKSchools *schools;
|
||||
@property(nonatomic, strong) NSNumber *graduation;
|
||||
@property(nonatomic, strong) NSNumber *friendState;
|
||||
@property(nonatomic, strong) NSNumber *common_count;
|
||||
@property(nonatomic, strong) NSString *faculty_name;
|
||||
@property(nonatomic, strong) NSString *university_name;
|
||||
@property(nonatomic, strong) NSString *books;
|
||||
@ -153,6 +156,7 @@
|
||||
@property(nonatomic, strong) NSString *twitter;
|
||||
@property(nonatomic, strong) NSString *skype;
|
||||
@property(nonatomic, strong) NSString *facebook;
|
||||
@property(nonatomic, strong) NSString *instagram;
|
||||
@property(nonatomic, strong) NSString *livejournal;
|
||||
@property(nonatomic, strong) NSString *wall_default;
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
//
|
||||
// --------------------------------------------------------------------------------
|
||||
//
|
||||
// Modified by Ruslan Kavetsky
|
||||
|
||||
#import "VKAccessToken.h"
|
||||
#import "VKSdk.h"
|
||||
|
Loading…
Reference in New Issue
Block a user