gpt4 book ai didi

ios - OCMockito 如何捕获 block 并匹配任何其他原始参数?

转载 作者:行者123 更新时间:2023-11-28 21:18:54 25 4
gpt4 key购买 nike

方法签名:

- (void)updateFeaturesButtons:(NSInteger)gameId
category:(FeatruesCategory)category
parentId:(NSInteger)parentId
success:(void (^)(NSDictionary* featuresJson))success
failure:(void (^)(NSError* error))failure

我 try catch 成功 block 参数并忽略其他类似参数:

HCArgumentCaptor* captor = [[HCArgumentCaptor alloc] init];
[verify(mockManager) updateFeaturesButtons:0 category:0 parentId:0 success:(id)captor failure:anything()];

我只想用我的 json 调用成功 block :

SuccessBlock block = captor.value;
block(json);

但我得到的只是 argument(s) are different! 错误。我可以为其他参数做些什么?

最佳答案

在 OCMockito 文档中,请参阅 How do you specify matchers for non-object arguments

所以你需要指定

[[[[verify(mockManager)
withMatcher:anything() forArgument:0]
withMatcher:anything() forArgument:1]
withMatcher:anything() forArgument:2]
updateFeaturesButtons:0 category:0 parentId:0 success:(id)captor failure:anything()];

关于ios - OCMockito 如何捕获 block 并匹配任何其他原始参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40661488/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com