mirror of
https://github.com/NohamR/knowledge-kit.git
synced 2026-05-25 12:27:15 +00:00
docs: senstive words
This commit is contained in:
@@ -93,18 +93,18 @@ BDD 编写的测试用例针对的是行为,测试范围更大一些,适合
|
|||||||
{
|
{
|
||||||
XCTestExpectation *exception = [self expectationWithDescription:@"测试数据库插入功能"];
|
XCTestExpectation *exception = [self expectationWithDescription:@"测试数据库插入功能"];
|
||||||
// given
|
// given
|
||||||
[dbInstance removeAllLogsInTableType:PCTLogTableTypeMeta];
|
[dbInstance removeAllLogsInTableType:HCTLogTableTypeMeta];
|
||||||
NSMutableArray *insertModels = [NSMutableArray array];
|
NSMutableArray *insertModels = [NSMutableArray array];
|
||||||
for (NSInteger index = 1; index <= 10000; index++) {
|
for (NSInteger index = 1; index <= 10000; index++) {
|
||||||
PCTLogMetaModel *model = [[PCTLogMetaModel alloc] init];
|
HCTLogMetaModel *model = [[HCTLogMetaModel alloc] init];
|
||||||
model.log_id = index;
|
model.log_id = index;
|
||||||
// ...
|
// ...
|
||||||
[insertModels addObject:model];
|
[insertModels addObject:model];
|
||||||
}
|
}
|
||||||
// when
|
// when
|
||||||
[dbInstance add:insertModels inTableType:PCTLogTableTypeMeta];
|
[dbInstance add:insertModels inTableType:HCTLogTableTypeMeta];
|
||||||
// then
|
// then
|
||||||
[dbInstance recordsCountInTableType:PCTLogTableTypeMeta completion:^(NSInteger count) {
|
[dbInstance recordsCountInTableType:HCTLogTableTypeMeta completion:^(NSInteger count) {
|
||||||
XCTAssert(count == insertModels.count, @"「数据增加」功能:异常");
|
XCTAssert(count == insertModels.count, @"「数据增加」功能:异常");
|
||||||
[exception fulfill];
|
[exception fulfill];
|
||||||
}];
|
}];
|
||||||
@@ -163,21 +163,21 @@ BDD 编写的测试用例针对的是行为,测试范围更大一些,适合
|
|||||||
|
|
||||||
```objective-c
|
```objective-c
|
||||||
#import <XCTest/XCTest.h>
|
#import <XCTest/XCTest.h>
|
||||||
#import "PCTLogPayloadModel.h"
|
#import "HCTLogPayloadModel.h"
|
||||||
|
|
||||||
@interface PCTLogPayloadModelTest : PCTTestCase
|
@interface HCTLogPayloadModelTest : HCTTestCase
|
||||||
{
|
{
|
||||||
PCTLogPayloadModel *_sut;
|
HCTLogPayloadModel *_sut;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation PCTLogPayloadModelTest
|
@implementation HCTLogPayloadModelTest
|
||||||
|
|
||||||
- (void)setUp
|
- (void)setUp
|
||||||
{
|
{
|
||||||
[super setUp];
|
[super setUp];
|
||||||
PCTLogPayloadModel *model = [[PCTLogPayloadModel alloc] init];
|
HCTLogPayloadModel *model = [[HCTLogPayloadModel alloc] init];
|
||||||
model.log_id = 1;
|
model.log_id = 1;
|
||||||
// ...
|
// ...
|
||||||
_sut = model;
|
_sut = model;
|
||||||
@@ -195,7 +195,7 @@ BDD 编写的测试用例针对的是行为,测试范围更大一些,适合
|
|||||||
XCTAssert([(NSString *)payloadDictionary[@"report_id"] isEqualToString:@"001"] &&
|
XCTAssert([(NSString *)payloadDictionary[@"report_id"] isEqualToString:@"001"] &&
|
||||||
[payloadDictionary[@"size"] integerValue] == 102 &&
|
[payloadDictionary[@"size"] integerValue] == 102 &&
|
||||||
[(NSString *)payloadDictionary[@"meta"] containsString:@"meiying"],
|
[(NSString *)payloadDictionary[@"meta"] containsString:@"meiying"],
|
||||||
@"PCTLogPayloadModel 的 「getDictionary」功能异常");
|
@"HCTLogPayloadModel 的 「getDictionary」功能异常");
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@@ -614,12 +614,12 @@ Xcode 自带的测试系统是 `XCTest`,使用简单。开发步骤如下
|
|||||||
1. XCTestCase 类和其他类一样,你可以定义基类,这里面封装一些常用的方法。
|
1. XCTestCase 类和其他类一样,你可以定义基类,这里面封装一些常用的方法。
|
||||||
|
|
||||||
```
|
```
|
||||||
// PCTTestCase.h
|
// HCTTestCase.h
|
||||||
#import <XCTest/XCTest.h>
|
#import <XCTest/XCTest.h>
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface PCTTestCase : XCTestCase
|
@interface HCTTestCase : XCTestCase
|
||||||
|
|
||||||
@property (nonatomic, assign) NSTimeInterval networkTimeout;
|
@property (nonatomic, assign) NSTimeInterval networkTimeout;
|
||||||
|
|
||||||
@@ -648,11 +648,11 @@ Xcode 自带的测试系统是 `XCTest`,使用简单。开发步骤如下
|
|||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
||||||
// PCTTestCase.m
|
// HCTTestCase.m
|
||||||
#import "PCTTestCase.h"
|
#import "HCTTestCase.h"
|
||||||
#import ...
|
#import ...
|
||||||
|
|
||||||
@implementation PCTTestCase
|
@implementation HCTTestCase
|
||||||
|
|
||||||
#pragma mark - life cycle
|
#pragma mark - life cycle
|
||||||
|
|
||||||
@@ -718,20 +718,20 @@ Xcode 自带的测试系统是 `XCTest`,使用简单。开发步骤如下
|
|||||||
|
|
||||||
**例子**
|
**例子**
|
||||||
|
|
||||||
这里举个例子,是测试一个数据库操作类 `PCTDatabase`,代码只放某个方法的测试代码。
|
这里举个例子,是测试一个数据库操作类 `HCTDatabase`,代码只放某个方法的测试代码。
|
||||||
|
|
||||||
```objective-c
|
```objective-c
|
||||||
- (void)testRemoveLatestRecordsByCount
|
- (void)testRemoveLatestRecordsByCount
|
||||||
{
|
{
|
||||||
XCTestExpectation *exception = [self expectationWithDescription:@"测试数据库删除最新数据功能"];
|
XCTestExpectation *exception = [self expectationWithDescription:@"测试数据库删除最新数据功能"];
|
||||||
// 1. 先清空数据表
|
// 1. 先清空数据表
|
||||||
[dbInstance removeAllLogsInTableType:PCTLogTableTypeMeta];
|
[dbInstance removeAllLogsInTableType:HCTLogTableTypeMeta];
|
||||||
// 2. 再插入一批数据
|
// 2. 再插入一批数据
|
||||||
NSMutableArray *insertModels = [NSMutableArray array];
|
NSMutableArray *insertModels = [NSMutableArray array];
|
||||||
NSMutableArray *reportIDS = [NSMutableArray array];
|
NSMutableArray *reportIDS = [NSMutableArray array];
|
||||||
|
|
||||||
for (NSInteger index = 1; index <= 100; index++) {
|
for (NSInteger index = 1; index <= 100; index++) {
|
||||||
PCTLogMetaModel *model = [[PCTLogMetaModel alloc] init];
|
HCTLogMetaModel *model = [[HCTLogMetaModel alloc] init];
|
||||||
model.log_id = index;
|
model.log_id = index;
|
||||||
// ...
|
// ...
|
||||||
if (index > 90 && index <= 100) {
|
if (index > 90 && index <= 100) {
|
||||||
@@ -739,20 +739,20 @@ Xcode 自带的测试系统是 `XCTest`,使用简单。开发步骤如下
|
|||||||
}
|
}
|
||||||
[insertModels addObject:model];
|
[insertModels addObject:model];
|
||||||
}
|
}
|
||||||
[dbInstance add:insertModels inTableType:PCTLogTableTypeMeta];
|
[dbInstance add:insertModels inTableType:HCTLogTableTypeMeta];
|
||||||
|
|
||||||
// 3. 将早期的数据删除掉(id > 90 && id <= 100)
|
// 3. 将早期的数据删除掉(id > 90 && id <= 100)
|
||||||
[dbInstance removeLatestRecordsByCount:10 inTableType:PCTLogTableTypeMeta];
|
[dbInstance removeLatestRecordsByCount:10 inTableType:HCTLogTableTypeMeta];
|
||||||
|
|
||||||
// 4. 拿到当前的前10条数据和之前存起来的前10条 id 做比较。再判断当前表中的总记录条数是否等于 90
|
// 4. 拿到当前的前10条数据和之前存起来的前10条 id 做比较。再判断当前表中的总记录条数是否等于 90
|
||||||
[dbInstance getLatestRecoreds:10 inTableType:PCTLogTableTypeMeta completion:^(NSArray<PCTLogModel *> * _Nonnull records) {
|
[dbInstance getLatestRecoreds:10 inTableType:HCTLogTableTypeMeta completion:^(NSArray<HCTLogModel *> * _Nonnull records) {
|
||||||
NSArray<PCTLogModel *> *latestRTentRecords = records;
|
NSArray<HCTLogModel *> *latestRTentRecords = records;
|
||||||
|
|
||||||
[dbInstance getOldestRecoreds:100 inTableType:PCTLogTableTypeMeta completion:^(NSArray<PCTLogModel *> * _Nonnull records) {
|
[dbInstance getOldestRecoreds:100 inTableType:HCTLogTableTypeMeta completion:^(NSArray<HCTLogModel *> * _Nonnull records) {
|
||||||
NSArray<PCTLogModel *> *currentRecords = records;
|
NSArray<HCTLogModel *> *currentRecords = records;
|
||||||
|
|
||||||
__block BOOL isEarlyData = NO;
|
__block BOOL isEarlyData = NO;
|
||||||
[latestRTentRecords enumerateObjectsUsingBlock:^(PCTLogModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
[latestRTentRecords enumerateObjectsUsingBlock:^(HCTLogModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||||
if ([reportIDS containsObject:obj.report_id]) {
|
if ([reportIDS containsObject:obj.report_id]) {
|
||||||
isEarlyData = YES;
|
isEarlyData = YES;
|
||||||
}
|
}
|
||||||
@@ -833,16 +833,16 @@ Kiwi 的使用分为:[Specs](https://github.com/kiwi-bdd/Kiwi/wiki/Specs)、 [
|
|||||||
|
|
||||||
```
|
```
|
||||||
XCTestExpectation *exception = [self expectationWithDescription:@"测试数据库插入功能"];
|
XCTestExpectation *exception = [self expectationWithDescription:@"测试数据库插入功能"];
|
||||||
[dbInstance removeAllLogsInTableType:PCTLogTableTypeMeta];
|
[dbInstance removeAllLogsInTableType:HCTLogTableTypeMeta];
|
||||||
NSMutableArray *insertModels = [NSMutableArray array];
|
NSMutableArray *insertModels = [NSMutableArray array];
|
||||||
for (NSInteger index = 1; index <= 10000; index++) {
|
for (NSInteger index = 1; index <= 10000; index++) {
|
||||||
PCTLogMetaModel *model = [[PCTLogMetaModel alloc] init];
|
HCTLogMetaModel *model = [[HCTLogMetaModel alloc] init];
|
||||||
model.log_id = index;
|
model.log_id = index;
|
||||||
// 。。。
|
// 。。。
|
||||||
[insertModels addObject:model];
|
[insertModels addObject:model];
|
||||||
}
|
}
|
||||||
[dbInstance add:insertModels inTableType:PCTLogTableTypeMeta];
|
[dbInstance add:insertModels inTableType:HCTLogTableTypeMeta];
|
||||||
[dbInstance recordsCountInTableType:PCTLogTableTypeMeta completion:^(NSInteger count) {
|
[dbInstance recordsCountInTableType:HCTLogTableTypeMeta completion:^(NSInteger count) {
|
||||||
XCTAssert(count == insertModels.count, @"**Database「数据增加」功能:异常");
|
XCTAssert(count == insertModels.count, @"**Database「数据增加」功能:异常");
|
||||||
[exception fulfill];
|
[exception fulfill];
|
||||||
}];
|
}];
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -196,16 +196,16 @@ BSD Socket 提供了转换函数
|
|||||||
|
|
||||||
// 2.1. 遍历拼接model,取出 meta,用 \n 拼接
|
// 2.1. 遍历拼接model,取出 meta,用 \n 拼接
|
||||||
[rawArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
[rawArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||||
if (PCT_IS_CLASS(obj, PCTLogPayloadModel)) {
|
if (HCT_IS_CLASS(obj, HCTLogPayloadModel)) {
|
||||||
|
|
||||||
PCTLogPayloadModel *payloadModel = (PCTLogPayloadModel *)obj;
|
HCTLogPayloadModel *payloadModel = (HCTLogPayloadModel *)obj;
|
||||||
BOOL shouldAppendLineBreakSymbol = idx < (rawArray.count - 1);
|
BOOL shouldAppendLineBreakSymbol = idx < (rawArray.count - 1);
|
||||||
[metaStrings appendString:[NSString stringWithFormat:@"%@%@", payloadModel.meta, shouldAppendLineBreakSymbol ? @"\n" : @""]];
|
[metaStrings appendString:[NSString stringWithFormat:@"%@%@", payloadModel.meta, shouldAppendLineBreakSymbol ? @"\n" : @""]];
|
||||||
|
|
||||||
// 2.2 判断是否需要上传 payload 信息。如果需要则将 payload 取出。(Payload 可能为空)
|
// 2.2 判断是否需要上传 payload 信息。如果需要则将 payload 取出。(Payload 可能为空)
|
||||||
if ([self needUploadPayload:payloadModel]) {
|
if ([self needUploadPayload:payloadModel]) {
|
||||||
if (payloadModel.payload) {
|
if (payloadModel.payload) {
|
||||||
NSData *payloadData = [PCTDataSerializer compressAndEncryptWithData:payloadModel.payload];
|
NSData *payloadData = [HCTDataSerializer compressAndEncryptWithData:payloadModel.payload];
|
||||||
[payloads addObject:payloadData];
|
[payloads addObject:payloadData];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -216,7 +216,7 @@ BSD Socket 提供了转换函数
|
|||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSData *metaData = [PCTDataSerializer compressAndEncryptWithString:metaStrings];
|
NSData *metaData = [HCTDataSerializer compressAndEncryptWithString:metaStrings];
|
||||||
|
|
||||||
__block NSMutableData *headerData = [NSMutableData data];
|
__block NSMutableData *headerData = [NSMutableData data];
|
||||||
unsigned short metaLength = (unsigned short)metaData.length;
|
unsigned short metaLength = (unsigned short)metaData.length;
|
||||||
|
|||||||
Reference in New Issue
Block a user