{"id":263062,"date":"2015-08-06T18:06:02","date_gmt":"2015-08-06T14:06:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=263062"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=263062","title":{"rendered":"\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 iOS"},"content":{"rendered":"<br \/>\n<h4><b>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435:<\/b><\/h4>\n<p>  <\/p>\n<ul>\n<li>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2013 \u0447\u0442\u043e \u044d\u0442\u043e?<\/li>\n<li>\u0422\u0440\u0438 \u0437\u0430\u043a\u043e\u043d\u0430 TDD<\/li>\n<li>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f<\/li>\n<li>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438<\/li>\n<li>\u041b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0430 \u0438 \u0441\u0441\u044b\u043b\u043a\u0438<\/li>\n<\/ul>\n<h4><b>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2013 \u0447\u0442\u043e \u044d\u0442\u043e?<\/b><\/h4>\n<p>  <\/p>\n<blockquote><p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (Test-driven development) \u2014 \u0442\u0435\u0445\u043d\u0438\u043a\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0447\u0435\u0440\u0435\u0437 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432. \u0412 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0442\u0440\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u0448\u0430\u0433\u0430:<br \/>   \u2014 \u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442 \u0434\u043b\u044f \u043d\u043e\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c;<br \/>   \u2014 \u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u0442\u0435\u0441\u0442;<br \/>   \u2014 \u041f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u043d\u043e\u0432\u043e\u0433\u043e \u0438 \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<p>   <a href=\"http:\/\/martinfowler.com\/bliki\/TestDrivenDevelopment.html\">\u041c\u0430\u0440\u0442\u0438\u043d \u0424\u0430\u0443\u043b\u0435\u0440<\/a><\/p><\/blockquote>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/ecd\/be6\/686\/ecdbe66867f245008fb0db3d12d54222.png\"\/><br \/>  <a name=\"habracut\"><\/a><\/p>\n<h4><b>\u0422\u0440\u0438 \u0437\u0430\u043a\u043e\u043d\u0430 TDD<\/b><\/h4>\n<p>  \u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u043d\u043e\u0433\u0438\u0435 \u0437\u043d\u0430\u044e\u0442, \u0447\u0442\u043e TDD \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442 \u043d\u0430\u0441 \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0442\u0435\u0441\u0442\u044b, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c production \u043a\u043e\u0434. \u041d\u043e \u044d\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u2014 \u043b\u0438\u0448\u044c \u0432\u0435\u0440\u0445\u0443\u0448\u043a\u0430 \u0430\u0439\u0441\u0431\u0435\u0440\u0433\u0430. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0432\u0430\u043c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0442\u0440\u0438 \u0437\u0430\u043a\u043e\u043d\u0430:  <\/p>\n<ol>\n<li>\u041d\u0435 \u043f\u0438\u0448\u0435\u0442\u0441\u044f production \u043a\u043e\u0434, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0442\u0435\u0441\u0442;<\/li>\n<li>\u041d\u0435 \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u043e\u0434\u0430 \u044e\u043d\u0438\u0442 \u0442\u0435\u0441\u0442\u0430, \u0447\u0435\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u0435\u0433\u043e \u043e\u0448\u0438\u0431\u043a\u0438. \u0418 \u043d\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c \u2014 \u044d\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430;<\/li>\n<li>\u041d\u0435 \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 production \u043a\u043e\u0434\u0430, \u0447\u0435\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043d\u0435\u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0433\u043e \u0442\u0435\u0441\u0442\u0430.<\/li>\n<\/ol>\n<p>  \u042d\u0442\u0438 \u0442\u0440\u0438 \u0437\u0430\u043a\u043e\u043d\u0430 \u0443\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430 \u0432 \u0446\u0438\u043a\u043b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043b\u0438\u0442\u0441\u044f \u043e\u043a\u043e\u043b\u043e \u043c\u0438\u043d\u0443\u0442\u044b. \u0422\u0435\u0441\u0442\u044b \u0438 production \u043a\u043e\u0434 \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u0441 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u0432\u0441\u0435\u0433\u043e \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u043a\u0443\u043d\u0434 \u0432\u043f\u0435\u0440\u0435\u0434\u0438 production \u043a\u043e\u0434\u0430.<br \/>  \u0415\u0441\u043b\u0438 \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u044d\u0442\u0438\u043c \u043f\u0443\u0442\u0435\u043c, \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0442\u0435\u0441\u0442\u043e\u0432 \u0432 \u0434\u0435\u043d\u044c, \u0441\u043e\u0442\u043d\u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u043c\u0435\u0441\u044f\u0446, \u0442\u044b\u0441\u044f\u0447\u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0433\u043e\u0434. \u0415\u0441\u043b\u0438 \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u044d\u0442\u0438\u043c \u043f\u0443\u0442\u0435\u043c, \u0442\u043e \u043d\u0430\u0448\u0438 \u0442\u0435\u0441\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0448 production \u043a\u043e\u0434.<\/p>\n<h4><b>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f<\/b><\/h4>\n<p>  <\/p>\n<h5>\u041f\u0440\u0438\u043c\u0435\u0440 1. \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432<\/h5>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (\u0441\u043e\u0431\u044b\u0442\u0438\u0439). \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0438\u0448\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043d\u043e\u0432\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 (\u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0445\u0430\u043e\u0442\u0438\u0447\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439):<\/p>\n<p>  \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<pre><code class=\"objectivec\">    - (NSArray *)sortEvents:(NSArray *)events <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043f\u0438\u0448\u0435\u043c \u0442\u0435\u0441\u0442:<br \/>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u043e\u0442\u0430\u0446\u0438\u044e given, when, then \u0434\u043b\u044f \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0430 \u043d\u0430 \u0442\u0440\u0438 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0431\u043b\u043e\u043a\u0430:  <\/p>\n<ul>\n<li>\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f, \u043f\u0440\u0435\u0434\u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0442\u0435\u0441\u0442\u0430;<\/li>\n<li>\u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0432\u044b\u0437\u043e\u0432 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430;<\/li>\n<li>\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/li>\n<\/ul>\n<p>  \u0422\u0435\u0441\u0442:<\/p>\n<pre><code class=\"objectivec\">    - (void)testSortEvents {     \/\/ given     id firstEvent = [self mockEventWithClass:kCinemaEventType name:@&quot;\u0412&quot;];     id secondEvent = [self mockEventWithClass:kCinemaEventType name:@&quot;\u0413&quot;];     id thirdEvent = [self mockEventWithClass:kPerfomanceEventType name:@&quot;\u0410&quot;];     id fourthEvent = [self mockEventWithClass:kPerfomanceEventType name:@&quot;\u0411&quot;];          NSArray *correctSortedArray = @[firstEvent, secondEvent, thirdEvent, fourthEvent];     NSArray *incorrectSortedArray = @[thirdEvent, secondEvent, fourthEvent, firstEvent];          \/\/ when     NSArray *sortedWithTestingMethodArray = [self.service sortEvents:incorrectSortedArray];          \/\/ then     XCTAssertEqualObjects(correctSortedArray, sortedWithTestingMethodArray, @&quot;\u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u044d\u0432\u0435\u043d\u0442\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e&quot;);     } <\/code><\/pre>\n<p>  \u0422\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b \u0443\u0431\u0435\u0434\u0438\u043b\u0438\u0441\u044c, \u0447\u0442\u043e \u0442\u0435\u0441\u0442 \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f, \u043f\u0438\u0448\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<pre><code class=\"objectivec\">    - (NSArray *)sortEvents:(NSArray *)events {     \/\/ \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 (\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043a\u0438\u043d\u043e, \u0437\u0430\u0442\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435, \u043e\u0431\u0435 \u0441\u0435\u043a\u0446\u0438\u0438 \u043f\u043e \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0443)     NSMutableArray *cinemaEvents = [[NSMutableArray alloc] init];     NSMutableArray *otherEvents = [[NSMutableArray alloc] init];          for (Event *event in events) {     if ([event.type isEqualToString:kCinemaEventType]) {     [cinemaEvents addObject:event];     } else {     [otherEvents addObject:event];     }     }          NSComparisonResult (^sortBlock)(Event *firstEvent, Event *secondEvent) = ^NSComparisonResult(Event *firstEvent, Event *secondEvent) {     return [firstEvent.type compare:secondEvent.type     options:NSNumericSearch];     };          [cinemaEvents sortUsingComparator:sortBlock];     [otherEvents sortUsingComparator:sortBlock];          return [cinemaEvents arrayByAddingObjectsFromArray:otherEvents];     } <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u0432\u0441\u0435 \u0442\u0435\u0441\u0442\u044b, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043d\u0430\u0448 \u043d\u043e\u0432\u044b\u0439, \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f. \u041f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043c \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u0412\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u0437\u0435\u043b\u0435\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0432 \u0437\u0435\u043b\u0435\u043d\u043e\u0435, \u0442.\u0435. \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0442\u0435\u0441\u0442\u044b \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b.<\/p>\n<p>  \u041e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u0430\u044f \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c TDD \u2013 \u044d\u0442\u043e \u0438\u043d\u0432\u0435\u0440\u0441\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438. \u041f\u0440\u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u041f\u041e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u043f\u043e\u0441\u043b\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0441\u0430\u043c\u043e\u043b\u0438\u0447\u043d\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0433\u043e\u043d\u044f\u0435\u0442 \u043a\u043e\u0434 \u0432 \u0434\u0435\u0431\u0430\u0433\u0433\u0435\u0440\u0435, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0432\u0441\u0435\u0447 if-\u043e\u0432. \u0412 TDD \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0435\u0441\u0442\u044b \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u044e\u0442 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/5a1\/59a\/a2a\/5a159aa2acd549f0a8debf2cccbf720b.png\"\/><\/p>\n<h5>\u041f\u0440\u0438\u043c\u0435\u0440 2. \u041c\u0430\u043f\u043f\u0435\u0440<\/h5>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u2013 \u043c\u0430\u043f\u043f\u0435\u0440 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0432\u044b\u0434\u0430\u0447\u0438 \u0432 \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b.<\/p>\n<p>  \u041c\u0430\u043f\u043f\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c:<br \/>  1) \u043c\u0430\u043f\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b (\u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e)<br \/>  2) \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043a\u0440\u0438\u0432\u0443\u044e \u0432\u044b\u0434\u0430\u0447\u0443 (Null, \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u0439 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0435\u0432\u0435\u0440\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0432\u044b\u0434\u0430\u0447\u0438)<br \/>  3) \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u0438\u0441\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445 (\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439)<\/p>\n<p>  \u041f\u0438\u0448\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434, \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c:<\/p>\n<p>  \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<pre><code class=\"objectivec\">    - (NSArray *)mapEvents:(id)responseObject <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043f\u0438\u0448\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u0442\u0435\u0441\u0442, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0449\u0438\u0439 \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439, \u0442.\u0435. \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u0440\u0438 \u0430\u0434\u0435\u043a\u0432\u0430\u0442\u043d\u043e\u0439 \u0432\u044b\u0434\u0430\u0447\u0435. \u041c\u044b \u043d\u0435 \u043f\u0438\u0448\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u0432\u0441\u0435 \u0442\u0435\u0441\u0442\u044b, \u043d\u0435 \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u043a\u0440\u044b\u0442\u044c \u0432\u0441\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u043c\u0430\u043f\u043f\u0435\u0440, \u0430 \u043f\u0438\u0448\u0435\u043c \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0442\u0435\u0441\u0442 \u043a \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<p>  \u0422\u0435\u0441\u0442:<\/p>\n<pre><code class=\"objectivec\">    - (void)testMapEventsResponseSuccessful {     \/\/ given     NSDictionary *responseObject = @{@&quot;event&quot; : @[@{@&quot;type&quot; : @1,     @&quot;name&quot; : @&quot;test&quot;,     @&quot;description&quot; : @&quot;test&quot;}]};          \/\/ when     NSArray *events = [self.mapper mapEvents:responseObject];          \/\/ then     Event *event = events[0];     [self checkObject:event     forKeyExistence:@[@&quot;type&quot;, @&quot;name&quot;, @&quot;description&quot;]];     } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434-\u0445\u0435\u043b\u043f\u0435\u0440 \u043d\u0430 KVC:<\/p>\n<pre><code class=\"objectivec\">    - (void)checkObject:(id)object     forKeyExistence:(NSArray *)keys {     for (NSString *key in keys) {     if (![object valueForKey:key]) {     XCTFail(@&quot;\u041e\u0431\u044a\u0435\u043a\u0442 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u043f\u043e\u043b\u044f - %@&quot;, key);     }     }     } <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043d\u0430\u0448\u0435\u043c\u0443 \u0442\u0435\u0441\u0442\u0443 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u0442\u0435\u0441\u0442 \u0431\u0443\u0434\u0435\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u0440\u043e\u0439\u0434\u0435\u043d. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043c\u0430\u043f\u043f\u0435\u0440\u0430 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0434\u0432\u0438\u0436\u043e\u043a \u043e\u0442 RESTKit, \u043d\u043e \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u043d\u0430\u0448 \u043c\u0435\u0442\u043e\u0434 \u043a\u0430\u043a \u0447\u0435\u0440\u043d\u0443\u044e \u043a\u043e\u0440\u043e\u0431\u043a\u0443, \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f. \u041d\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0441\u0442\u0430\u043d\u0443\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u0438\u043c\u0438.<\/p>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<pre><code class=\"objectivec\">    - (NSArray *)mapEvents:(id)responseObject {     NSDictionary *mappingsDictionary = @{kEventResponseKey : [self eventResponseMapping]};          RKMappingResult *mappingResult = [self mapResponseObject:responseObject     withMappingsDictionary:mappingsDictionary];          if (mappingResult) {     return [mappingResult array];     }          return @[];     } <\/code><\/pre>\n<p>  \u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043f\u043e\u0441\u043b\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0442\u0435\u0441\u0442 \u0434\u043b\u044f \u043c\u0430\u043f\u043f\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0447\u0442\u043e \u043c\u0430\u043f\u043f\u0435\u0440 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u0432 \u0432\u044b\u0434\u0430\u0447\u0435, \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435 id, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u0442\u0435\u0441\u0442\u0435. \u0417\u0430\u0434\u0430\u0447\u0430 \u0442\u0435\u0441\u0442\u0430 \u2013 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u043a\u0440\u0430\u0448\u0430, \u0438 \u043c\u0435\u0442\u043e\u0434 \u0432\u0435\u0440\u043d\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e\u0441\u043b\u0435 \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430.<\/p>\n<p>  \u0422\u0435\u0441\u0442:<\/p>\n<pre><code class=\"objectivec\">    - (void)testMapEventsResponseWithMissingMandatoryFields {     \/\/ given     NSDictionary *responseObject = @{kEventResponseKey : @[@{@&quot;name&quot; : @&quot;test&quot;}]};          \/\/ when     NSArray *events = [self.mapper mapEvents:responseObject];          \/\/ then     XCTAssertFalse([events count]);     } <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c \u043d\u0430\u0448 \u043c\u0435\u0442\u043e\u0434, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0435\u0433\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043d\u0430 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u043b\u0435\u0439.<\/p>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<pre><code class=\"objectivec\">    - (NSArray *)mapEvents:(id)responseObject {     NSDictionary *mappingsDictionary = @{kEventResponseKey : [self eventResponseMapping]};          RKMappingResult *mappingResult = [self mapResponseObject:responseObject     withMappingsDictionary:mappingsDictionary];          if (mappingResult) {     \/\/\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0435     NSArray *events = [self checkMandatoryFields:[mappingResult array]];     return events;     }          return @[];     } <\/code><\/pre>\n<p>  \u0418\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439, \u043d\u0430\u0448 \u043c\u0430\u043f\u043f\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0441\u0435\u0431\u044f \u0432\u0435\u0441\u0442\u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043b\u0438\u0447\u0438\u044f Null-\u043e\u0432 \u0432 \u0432\u044b\u0434\u0430\u0447\u0435, \u043f\u0438\u0448\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0449\u0438\u0439 \u044d\u0442\u043e \u0442\u0435\u0441\u0442:<\/p>\n<pre><code class=\"objectivec\">    - (void)testMapEventsResponseWithNulls {     \/\/ given     NSDictionary *responseObject = @{kEventResponseKey : @[@{@&quot;type&quot; : @1,     @&quot;name&quot; : [NSNull null],     @&quot;description&quot; : [NSNull null]}]};          \/\/ when     NSArray *events = [self.mapper mapEvents:responseObject];          \/\/ then     Event *event = events[0];     XCTAssertNotNil(event.type, @&quot;&quot;);     XCTAssertNil(event.name, @&quot;&quot;);     } <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u0430 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043e\u043d \u0441\u0440\u0430\u0437\u0443 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f. \u0414\u0430, \u0442\u0430\u043a\u043e\u0435 \u0442\u043e\u0436\u0435 \u0431\u044b\u0432\u0430\u0435\u0442, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0443\u0436\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c. \u0412 \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043c\u044b, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u043d\u0435 \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u044d\u0442\u043e\u0442 \u0442\u0435\u0441\u0442, \u0442.\u043a. \u0435\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u0438 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c, \u043f\u0440\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0430\u043f\u043f\u0435\u0440\u0430, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u044c \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b. \u0414\u0430\u043b\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u0435\u0441\u0442 \u0434\u043b\u044f \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u043c\u0435\u0441\u0442\u043e \u0447\u0438\u0441\u043b\u0430 \u2013 \u0441\u0442\u0440\u043e\u043a\u0430. \u041c\u0430\u043f\u043f\u0438\u043d\u0433 \u0434\u0432\u0438\u0436\u043e\u043a \u043e\u0442 RestKit \u0443\u043c\u0435\u0435\u0442 \u0438 \u0441 \u044d\u0442\u0438\u043c \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f, \u0442\u0430\u043a \u0447\u0442\u043e \u0442\u0435\u0441\u0442 \u043e\u043f\u044f\u0442\u044c \u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0433\u043e\u0440\u0435\u0442\u044c \u0437\u0435\u043b\u0435\u043d\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c.<\/p>\n<pre><code class=\"objectivec\">    - (void)testMapEventsResponseWithWrongType {     \/\/ given     NSDictionary *responseObject = @{kEventResponseKey : @[@{@&quot;type&quot; : @&quot;123&quot;}]};          \/\/ when     NSArray *events = [self.mapper mapEvents:responseObject];               \/\/ then     Event *event = events[0];     XCTAssertTrue([event.type isEqual:@123]);     } <\/code><\/pre>\n<h5>\u041f\u0440\u0438\u043c\u0435\u0440 3. \u0421\u0435\u0440\u0432\u0438\u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439<\/h5>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (\u0441\u043e\u0431\u044b\u0442\u0438\u0439), \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b:<\/p>\n<pre><code class=\"objectivec\">    @interface EventService : NSObject          - (instancetype)initWithClient:(id&lt;Client&gt;)client         mapper:(id&lt;Mapper&gt;)mapper;                          - (NSArray *)obtainEventsForType:(EventType)eventType;                          - (void)updateEventsForType:(EventType)eventType             success:(SuccessBlock)success             failure:(ErrorBlock)failure;             @end <\/code><\/pre>\n<p>  \u0421\u0435\u0440\u0432\u0438\u0441 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 CoreData, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u043e\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u044d\u043a CoreData \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 CoreData \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 MagicalRecord, \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c [MagicalRecord cleanUp] \u0432 teardown. \u0412 \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0438\u0441 \u0438\u043d\u0436\u0435\u043a\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u043a\u043b\u0438\u0435\u043d\u0442 \u0438 \u043c\u0430\u043f\u043f\u0435\u0440, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0438\u0445 \u043c\u043e\u043a\u0438.<\/p>\n<pre><code class=\"objectivec\">    @interface EventServiceTests : XCTestCase          @property (nonatomic, strong) EventService *eventService;     @property (nonatomic, strong) id&lt;Client&gt; clientMock;         @property (nonatomic, strong) id&lt;Mapper&gt; mapperMock;                          @end                          @implementation EventServiceTests                          - (void)setUp {             [super setUp];                          [MagicalRecord setDefaultModelFromClass:[self class]];             [MagicalRecord setupCoreDataStackWithInMemoryStore];                          self.clientMock = OCMProtocolMock(@protocol(Client));             self.mapperMock = OCMProtocolMock(@protocol(Mapper));                          self.eventService = [[EventService alloc] initWithClient:self.clientMock             mapper:self.mapperMock];             }                          - (void)tearDown {             self.eventService = nil;             self.clientMock = nil;             self.mapperMock = nil;             [MagicalRecord cleanUp];                          [super tearDown];             } <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u0435\u0441\u0442 \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430 obtain \u2014 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"objectivec\">    - (void)testObtainEventsForType {     \/\/ given     Event *event = [Event MR_createEntity];     event.eventType = EventTypeCinema;          \/\/ when     NSArray *events = [self.eventService obtainEventsForType:EventTypeCinema];          \/\/ then     XCTAssertEqualObjects(event, [events firstObject]);     } <\/code><\/pre>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 obtain \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430:<\/p>\n<pre><code class=\"objectivec\">    - (instancetype)initWithClient:(id&lt;Client&gt;)client         mapper:(id&lt;Mapper&gt;)mapper {             self = [super init];             if (self) {             _client = client;             _mapper = mapper;             }             return self;             }                          - (NSArray *)obtainEventsForType:(EventType)eventType {             NSPredicate *predicate = [NSPredicate predicateWithFormat:@&quot;eventType = %d&quot;, eventType];             NSArray *events = [Event MR_findAllWithPredicate:predicate];                          return events;             } <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u0435\u0441\u0442 \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430 update \u2013 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u043b\u0438\u0435\u043d\u0442, \u0437\u0430\u0442\u0435\u043c \u043c\u0430\u043f\u043f\u0438\u0442 \u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0432 \u0431\u0430\u0437\u0443. \u0421\u0442\u0430\u0431\u0430\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b success \u0431\u043b\u043e\u043a. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0438\u0441 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u043a \u043c\u0430\u043f\u043f\u0435\u0440\u0443 \u0438 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 success \u0431\u043b\u043e\u043a:<\/p>\n<pre><code class=\"objectivec\">    - (void)testUpdateEventsForTypeSuccessful {     \/\/ given     XCTestExpectation *expectation = [self expectationWithDescription:@&quot;Callback&quot;];     OCMStub([self.clientMock requestEventsForType:EventTypeCinema     success:OCMOCK_ANY     failure:OCMOCK_ANY).andDo(^(NSInvocation *invocation) {     SuccessBlock block;     [invocation getArgument:&block atIndex:3];     block();     });          \/\/ when     [self.eventService updateEventsForType:EventTypeCinema     success:^{     [expectation fulfill];          } failure:^(NSError *error) {          }];          \/\/ then     [self waitForExpectationsWithTimeout:DefaultTestExpectationTimeout handler:nil];     OCMVerify([self.mapperMock mapEvents:OCMOCK_ANY     forType:EventTypeCinema     mappingContext:OCMOCK_ANY]);     } <\/code><\/pre>\n<p>  \u041f\u0438\u0448\u0435\u043c \u0442\u0435\u0441\u0442 \u043d\u0430 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u043e\u0448\u0438\u0431\u043a\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 update, \u0441\u0442\u0430\u0431\u0430\u0435\u043c \u043a\u043b\u0438\u0435\u043d\u0442 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b \u043e\u0448\u0438\u0431\u043a\u0443:<\/p>\n<pre><code class=\"objectivec\">    - (void)testUpdateEventsForTypeFailure {     \/\/ given     XCTestExpectation *expectation = [self expectationWithDescription:@&quot;Callback&quot;];     NSError *clientError = [NSError errorWithDomain:@&quot;&quot;     code:1     userInfo:nil];          OCMStub([self.clientMock requestEventsForType:EventTypeCinema     success:OCMOCK_ANY     failure:OCMOCK_ANY).andDo(^(NSInvocation *invocation) {     ErrorBlock block;     [invocation getArgument:&block atIndex:4];     block(error);     });          \/\/ when     [self.eventService updateEventsForType:EventTypeCinema     success:^{          } failure:^(NSError *error) {     XCTAssertEqual(clientError, error)     [expectation fulfill];     }];          \/\/ then     [self waitForExpectationsWithTimeout:DefaultTestExpectationTimeout handler:nil];     } <\/code><\/pre>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 update:<\/p>\n<pre><code class=\"objectivec\">    - (void)updateEventsForType:(EventType)eventType     success:(SuccessBlock)success     failure:(ErrorBlock)failure {     @weakify(self);     [self.client requestEventsForType:eventType     success:^(id responseObject) {     @strongify(self);          NSManagedObjectContext *context = [NSManagedObjectContext MR_rootSavingContext];     NSArray *events = [self.mapper mapEvents:responseObject     forType:eventType     mappingContext:context];     [context MR_saveToPersistentStoreAndWait];          success();          } failure:^(NSError *error) {     failure(error);     }];     } <\/code><\/pre>\n<p>  <\/p>\n<h4><b>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438<\/b><\/h4>\n<p>  <\/p>\n<h5>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430<\/h5>\n<p>  <\/p>\n<ul>\n<li><b>\u041f\u0440\u043e\u0434\u0443\u043c\u044b\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0434\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/b><br \/>   \u041e\u0434\u043d\u043e \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432, TDD \u0432\u044b\u043d\u0443\u0436\u0434\u0430\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430 \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u043e\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0430 \u043f\u043e\u0442\u043e\u043c \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0435.\n<\/li>\n<li><b>\u041c\u0435\u043d\u044c\u0448\u0435 \u043e\u0442\u043b\u0430\u0434\u043a\u0438<\/b><br \/>   \u0412\u044b\u0441\u043e\u043a\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u044f \u043a\u043e\u0434\u0430 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443, \u043d\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u044f \u0434\u043e\u043b\u0433\u0438\u0435 \u0447\u0430\u0441\u044b \u0432 \u0434\u0435\u0431\u0430\u0433\u0433\u0435\u0440\u0435.\n<\/li>\n<li><b>\u0423\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438<\/b><br \/>   \u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u0441 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0435\u0439, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0438 \u043a\u043e\u0434 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435, \u0430 \u0441\u043b\u043e\u043c\u0430\u043b\u043e\u0441\u044c \u0447\u0442\u043e-\u0442\u043e \u0432 \u0441\u043e\u0432\u0441\u0435\u043c \u0434\u0440\u0443\u0433\u043e\u043c \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a \u043f\u043b\u043e\u0445\u043e\u0433\u043e \u0434\u0438\u0437\u0430\u0439\u043d\u0430 \u043a\u043e\u0434\u0430. \u041f\u043e\u043a\u0440\u044b\u0442\u0438\u0435 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u0434\u0430\u0435\u0442 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0438\u043b\u0438 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u0438 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u0430\u0432\u0430\u0440\u0438\u0439\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u0442\u0435\u0441\u0442\u044b \u0441\u0440\u0430\u0437\u0443 \u0435\u0435 \u043e\u0442\u043b\u043e\u0432\u044f\u0442.\n<\/li>\n<li><b>\u041c\u0435\u043d\u044c\u0448\u0435 \u043e\u0448\u0438\u0431\u043e\u043a<\/b><br \/>   \u0414\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0437\u0430 \u0441\u0447\u0435\u0442 \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432 TDD, \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0437\u0430 \u0441\u0447\u0435\u0442 \u043f\u0440\u043e\u0434\u0443\u043c\u044b\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0438 \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u044f \u0442\u0435\u0441\u0442\u0430\u043c\u0438.\n<\/li>\n<li><b>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0442\u0435\u0441\u0442\u0430\u043c\u0438<\/b><br \/>   \u0422\u0435\u0441\u0442\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b. \u0427\u0430\u0441\u0442\u043e \u043f\u0440\u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u0440\u043e\u0449\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043a\u043e\u0434\u043e\u043c \u043d\u0430 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u0430 \u0442\u0435\u0441\u0442 \u2013 \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u0440\u0438 \u043f\u043e\u043b\u043d\u043e\u043c \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u0435 \u043a\u043e\u0434\u0430 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u2013 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u043e \u0441\u0443\u0442\u0438 \u043e\u0431\u0448\u0438\u0440\u043d\u0443\u044e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043a\u043e\u0434\u0430.\n<\/li>\n<li><b>\u041c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/b><br \/>   \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0432\u0441\u0435 \u0432\u0435\u0442\u0432\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u0432\u0441\u0435 if-\u044b \u0432\u044b\u043d\u0443\u0436\u0434\u0430\u0435\u0442 \u043d\u0430\u0441 \u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e, \u0438\u0431\u043e \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435\u043c\u043e\u0433\u0443\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0440\u0430\u0437\u0443 10 \u0434\u0435\u043b \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u0430\u0445. \u041c\u044b \u0441\u0442\u0440\u0435\u043c\u0438\u043c\u0441\u044f \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u043a\u0430\u0436\u0434\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0432\u043e\u044e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043e\u0431\u0449\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b. (\u0421\u043b\u0435\u0434\u0443\u044f \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 single responsibility).\n<\/li>\n<li><b>\u041f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b<\/b><br \/>   \u041f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u043f\u0438\u0441\u0430\u043b\u0438 \u0442\u0435\u0441\u0442\u044b, \u043d\u043e \u043d\u0435 \u0432\u0441\u0435 \u043f\u0438\u0441\u0430\u043b\u0438 \u0438\u0445 \u043f\u043e TDD \u0438 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043e\u0449\u0443\u0442\u0438\u043c\u0430. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u044b \u043e\u0447\u0435\u043d\u044c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u043c\u043e\u0436\u0435\u043c \u043d\u0435 \u0443\u0447\u0435\u0441\u0442\u044c \u0432\u0441\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430, \u0438 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b. \u041c\u044b \u0441\u0447\u0438\u0442\u0430\u0435\u043c, \u0447\u0442\u043e \u043d\u0430\u0448 \u043c\u0435\u0442\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u0435\u0441\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 \u043d\u0435 \u043f\u043e\u043a\u0440\u044b\u0442\u044b \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u0432\u0441\u0435 if-\u044b, \u0430 \u043f\u0440\u0438 TDD \u0442\u0430\u043a\u043e\u0435 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e if \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u0434\u0435 \u0431\u0435\u0437 \u0442\u0435\u0441\u0442\u0430. <\/li>\n<\/ul>\n<h5>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438<\/h5>\n<p>  <\/p>\n<ul>\n<li><b>\u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f (\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445, UI, \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445)<\/b><br \/>   \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0447\u0430\u0441\u0442\u043e \u043c\u044b \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0435\u0449\u0438 \u0441\u043b\u043e\u0436\u043d\u043e \u0438\u043b\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0418\u043d\u043e\u0433\u0434\u0430 \u0431\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u0441\u0445\u043e\u0434\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u0434\u0443\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.\n<\/li>\n<li><b>\u0411\u043e\u043b\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/b><br \/>   \u041a\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0448\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e TDD \u2013 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u043e\u0436\u0435\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c\u0441\u044f \u0434\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0440\u0430\u0437. \u041d\u043e, \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u0431\u0443\u0434\u0435\u0442 \u0443\u0436\u0435 \u0441\u043b\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0431\u0435\u0437 \u043d\u0435\u0433\u043e. \u0412 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u0435 \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u043e\u043f\u044b\u0442\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f TDD, \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0431\u0443\u0434\u0435\u0442 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0442\u044c\u0441\u044f. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0449\u0443\u0449\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u0438, \u043d\u0430 \u0434\u043e\u043b\u0433\u043e\u0436\u0438\u0432\u0443\u0449\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445.\n<\/li>\n<li><b>\u041b\u043e\u0436\u043d\u043e\u0435 \u043e\u0449\u0443\u0449\u0435\u043d\u0438\u0435 \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u0438, \u043e\u0448\u0438\u0431\u043a\u0430 \u0432 \u0442\u0435\u0441\u0442\u0435<\/b><br \/>   \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u043d\u044f\u043b\u0438 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f. \u0412 \u0438\u0442\u043e\u0433\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043e\u0448\u0438\u0431\u043a\u0443 \u0432 \u043a\u043e\u0434\u0435, \u0432 \u0442\u0435\u0441\u0442\u0435 \u0438 \u0432 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0438. \u0418 \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e \u043c\u044b \u0443\u0432\u0435\u0440\u0435\u043d\u044b \u0447\u0442\u043e \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u0435\u0441\u0442\u044b \u0433\u043e\u0440\u044f\u0442 \u0437\u0435\u043b\u0435\u043d\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c. \u042d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043e\u043f\u0430\u0441\u043d\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0438 \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043b\u0438\u0442\u044c\u0441\u044f \u0432 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043f\u043e\u0442\u0435\u0440\u044e.\n<\/li>\n<li><b>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432<\/b><br \/>   \u041a\u043e\u0434\u043e\u0432\u0430\u044f \u0431\u0430\u0437\u0430 \u043f\u0440\u0438 \u043f\u043e\u043b\u043d\u043e\u043c \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u0438 \u043a\u043e\u0434\u0430 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432 \u0434\u0432\u0430 \u0440\u0430\u0437\u0430. \u0418 \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u0435\u0441\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c, \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0442\u044c \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. <\/li>\n<\/ul>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/82b\/e19\/eed\/82be19eed59543119f1b6c1b13dfe929.png\"\/><\/p>\n<blockquote><p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043e\u0449\u0440\u044f\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0434\u0438\u0437\u0430\u0439\u043d \u0438 \u0432\u043d\u0443\u0448\u0430\u0435\u0442 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c.<br \/>   TDD encourages simple designs and inspires confidence.<\/p>\n<p>   \u041a\u0435\u043d\u0442 \u0411\u0435\u043a  <\/p><\/blockquote>\n<p>  <\/p>\n<h4><b>\u041b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0430 \u0438 \u0441\u0441\u044b\u043b\u043a\u0438<\/b><\/h4>\n<p>  <a href=\"https:\/\/books.google.co.uk\/books\/about\/Test_driven_Development.html?id=gFgnde_vwMAC\">Kent Beck \u2013 Test-Driven Development: By example<\/a><br \/>  <a href=\"https:\/\/books.google.co.uk\/books?id=dwSfGQAACAAJ&amp;dq=Robert+C.+Martin+%E2%80%93+Clean+code&amp;hl=en&amp;sa=X&amp;ved=0CDUQ6AEwAWoVChMIlNictofnxgIVpO9yCh3OXQ7M\">Robert C. Martin \u2013 Clean code<\/a><br \/>  <a href=\"http:\/\/www.objc.io\/issue-15\/\">www.objc.io\/issue-15<\/a><br \/>  <a href=\"https:\/\/en.wikipedia.org\/wiki\/Test-driven_development\">en.wikipedia.org\/wiki\/Test-driven_development<\/a><br \/>  <a href=\"http:\/\/qualitycoding.org\/objective-c-tdd\/\">qualitycoding.org\/objective-c-tdd<\/a><br \/>  <a href=\"http:\/\/agiledata.org\/essays\/tdd.html#WhatIsTDD\">agiledata.org\/essays\/tdd.html#WhatIsTDD<\/a><br \/>  <a href=\"http:\/\/www.basilv.com\/psd\/blog\/2009\/test-driven-development-benefits-limitations-and-techniques\">www.basilv.com\/psd\/blog\/2009\/test-driven-development-benefits-limitations-and-techniques<\/a><br \/>  <a href=\"http:\/\/martinfowler.com\/articles\/is-tdd-dead\/\">martinfowler.com\/articles\/is-tdd-dead<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/206828\/\">habrahabr.ru\/post\/206828<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/216923\/\">habrahabr.ru\/post\/216923<\/a><br \/>  <a href=\"http:\/\/iosunittesting.com\/\">iosunittesting.com<\/a>     \t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/263087\/\"> http:\/\/habrahabr.ru\/post\/263087\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<br \/>\n<h4><b>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435:<\/b><\/h4>\n<p>  <\/p>\n<ul>\n<li>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2013 \u0447\u0442\u043e \u044d\u0442\u043e?<\/li>\n<li>\u0422\u0440\u0438 \u0437\u0430\u043a\u043e\u043d\u0430 TDD<\/li>\n<li>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f<\/li>\n<li>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438<\/li>\n<li>\u041b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0430 \u0438 \u0441\u0441\u044b\u043b\u043a\u0438<\/li>\n<\/ul>\n<h4><b>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2013 \u0447\u0442\u043e \u044d\u0442\u043e?<\/b><\/h4>\n<p>  <\/p>\n<blockquote><p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 (Test-driven development) \u2014 \u0442\u0435\u0445\u043d\u0438\u043a\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0447\u0435\u0440\u0435\u0437 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432. \u0412 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0442\u0440\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u0448\u0430\u0433\u0430:<br \/>   \u2014 \u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442 \u0434\u043b\u044f \u043d\u043e\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c;<br \/>   \u2014 \u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u0442\u0435\u0441\u0442;<br \/>   \u2014 \u041f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u043d\u043e\u0432\u043e\u0433\u043e \u0438 \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<p>   <a href=\"http:\/\/martinfowler.com\/bliki\/TestDrivenDevelopment.html\">\u041c\u0430\u0440\u0442\u0438\u043d \u0424\u0430\u0443\u043b\u0435\u0440<\/a><\/p><\/blockquote>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/ecd\/be6\/686\/ecdbe66867f245008fb0db3d12d54222.png\"\/>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-263062","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/263062","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=263062"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/263062\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=263062"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=263062"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=263062"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}