{"id":6774,"date":"2013-01-06T15:20:26","date_gmt":"2013-01-06T20:20:26","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=6774"},"modified":"2013-01-06T15:20:26","modified_gmt":"2013-01-06T20:20:26","slug":"ocmock-examples","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2013\/01\/06\/ocmock-examples\/","title":{"rendered":"OCMock Examples"},"content":{"rendered":"<p><a href=\"http:\/\/ashfurrow.com\/blog\/your-first-objective-c-unit-test\">Ash Furrow<\/a>:<\/p>\n<blockquote cite=\"http:\/\/ashfurrow.com\/blog\/your-first-objective-c-unit-test\"><p>Next, we create a mock connection, just like last time, except now we tell it to also expect a call to <code>cancel<\/code>.<\/p>\n<p>In addition to calling <code>start<\/code>, we&rsquo;re also going to manually invoke the <code>NSURLConnectionDataDelegate<\/code> method <code>connection:didReceiveResponse:<\/code>. This means we&rsquo;ll need a response to pass in as the second parameter. That&rsquo;s where the <code>mockResponse<\/code> object comes in. We&rsquo;ll create a mock <code>NSHTTPURLResponse<\/code> that returns 404 when ask for its status code. This is how we will simulate the connection failure.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Ash Furrow: Next, we create a mock connection, just like last time, except now we tell it to also expect a call to cancel. In addition to calling start, we&rsquo;re also going to manually invoke the NSURLConnectionDataDelegate method connection:didReceiveResponse:. This means we&rsquo;ll need a response to pass in as the second parameter. That&rsquo;s where the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[54,276,71,268],"class_list":["post-6774","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-objective-c","tag-ocmock","tag-programming","tag-testing"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/6774","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=6774"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/6774\/revisions"}],"predecessor-version":[{"id":6775,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/6774\/revisions\/6775"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=6774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=6774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=6774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}