{"id":74,"date":"2008-08-11T21:24:58","date_gmt":"2008-08-12T04:24:58","guid":{"rendered":"http:\/\/lookforwardconsulting.com\/wordpress\/?p=74"},"modified":"2026-07-11T10:07:12","modified_gmt":"2026-07-11T09:07:12","slug":"fake-objects","status":"publish","type":"post","link":"https:\/\/thescrumacademy.com\/es\/2008\/08\/11\/fake-objects\/","title":{"rendered":"Fake Objects"},"content":{"rendered":"<p>I was writing some tests today around some legacy code (its about 2 weeks old and not written with TDD) and wanted to make sure that some method was called when the parent method was invoked.\u00a0 Unfortunately, I was having some problems with getting\u00a0<a href=\"https:\/\/hibernatingrhinos.com\/oss\/rhino-mocks\">RhinoMocks<\/a>\u00a0working.\u00a0 Since I was getting frustrated with some \u201cstupid\u201d tool and not making any progress, I decided to go back to first principles to look for a simpler way to write my test.<\/p>\n<p>This was the code I was working with and I wanted to write a test that proved line 28 was called:<\/p>\n<pre>22  public virtual void AcceptMessage(IBusMessage message)\r\n23  {\r\n24      if (!Power)\r\n25      {\r\n26          return;\r\n27      }\r\n28      ProcessMessage(message);\r\n29  }<\/pre>\n<p>If you look at the rest of the code, this method comes from an abstract base class and the method in question (line 28) is abstract, protected\u00a0<strong>AND\u00a0<\/strong>void, so just calling it and looking at the return value is not a strategy I can use.\u00a0 To write the other tests I had written earlier in the day I had used the\u00a0<a href=\"http:\/\/xunitpatterns.com\/Fake%20Object.html\">Fake Object<\/a>\u00a0concept just so I can get the object in the testing harness.\u00a0 Keep in mind, I am not trying to fake any collaborator, just test the base class since it does real things I want to make sure happen (or get updated) as the design evolves (you might be thinking this is a dumb place to start with a test, but you have to start somewhere).<\/p>\n<p>Since I have complete control over my fake object and the method I want to make sure is abstract, I can insert a\u00a0sensing variable\u00a0in my fake object and set its state when the method (ProcessMethod) is called, like so:<\/p>\n<pre>10  public bool MessageProcessed = false;\r\n11\r\n12  protected override void ProcessMessage(IBusMessage message)\r\n13  {\r\n14      MessageProcessed = true;\r\n15  }<\/pre>\n<p>Here is my test:<\/p>\n<pre>63\u00a0 [TestMethod]\r\n64  public void AcceptMessageWithPowerTest()\r\n65\u00a0 {\r\n66\u00a0     \/\/ setup\r\n67\u00a0\u00a0\u00a0\u00a0\u00a0 FakeDevice test = new FakeDevice();\r\n68\u00a0\u00a0\u00a0\u00a0\u00a0 test.Power = true;\r\n69\r\n70\u00a0\u00a0\u00a0\u00a0  IBusMessage message = new BusMessage();\r\n71\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n72\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ exercise\r\n73\u00a0\u00a0\u00a0\u00a0\u00a0 test.AcceptMessage(message);\r\n74\r\n75\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ verify\r\n76\u00a0\u00a0\u00a0\u00a0\u00a0 Assert.IsTrue(test.MessageProcessed, \"Process message not called.\");\r\n77\r\n78\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ clean-up\r\n79  }<\/pre>\n<p>OK, kinda like using a sledgehammer to hit a carpet nail, but it got me unstuck and back to a green bar.\u00a0 Now, maybe I can spend sometime with RhinoMocks and figure out the easier way to do this.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was writing some tests today around some legacy code (its about 2 weeks old and not written with TDD) and wanted to make sure that some method was called  [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":7489,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_price":"","_stock":"","_tribe_ticket_header":"","_tribe_default_ticket_provider":"","_tribe_ticket_capacity":"0","_ticket_start_date":"","_ticket_end_date":"","_tribe_ticket_show_description":"","_tribe_ticket_show_not_going":false,"_tribe_ticket_use_global_stock":"","_tribe_ticket_global_stock_level":"","_global_stock_mode":"","_global_stock_cap":"","_tribe_rsvp_for_event":"","_tribe_ticket_going_count":"","_tribe_ticket_not_going_count":"","_tribe_tickets_list":"[]","_tribe_ticket_has_attendee_info_fields":false,"footnotes":""},"categories":[7,19,10,6,24,206,26,210,5,53,36,17],"tags":[],"class_list":["post-74","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-agile-scrum","category-design-excellence","category-developers","category-extreme-programming","category-legacy-code","category-practitioners","category-refactoring","category-scrum-framework","category-scrum-methodology","category-simple-design","category-test-driven-development","category-testing"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Fake Objects - The Scrum Academy<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/thescrumacademy.com\/es\/2008\/08\/11\/fake-objects\/\" \/>\n<meta property=\"og:locale\" content=\"es_ES\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Fake Objects - The Scrum Academy\" \/>\n<meta property=\"og:description\" content=\"I was writing some tests today around some legacy code (its about 2 weeks old and not written with TDD) and wanted to make sure that some method was called [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/thescrumacademy.com\/es\/2008\/08\/11\/fake-objects\/\" \/>\n<meta property=\"og:site_name\" content=\"The Scrum Academy\" \/>\n<meta property=\"article:published_time\" content=\"2008-08-12T04:24:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-07-11T09:07:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/thescrumacademy.com\/wp-content\/uploads\/2008\/08\/vecteezy_man-holding-a-hammer_49151667.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"673\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Carlton Nettleton\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"Carlton Nettleton\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tiempo de lectura\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/thescrumacademy.com\\\/es\\\/2008\\\/08\\\/11\\\/fake-objects\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/thescrumacademy.com\\\/es\\\/2008\\\/08\\\/11\\\/fake-objects\\\/\"},\"author\":{\"name\":\"Carlton Nettleton\",\"@id\":\"https:\\\/\\\/thescrumacademy.com\\\/es\\\/#\\\/schema\\\/person\\\/2a0fb199044ecd4af3704c734747fc6a\"},\"headline\":\"Fake Objects\",\"datePublished\":\"2008-08-12T04:24:58+00:00\",\"dateModified\":\"2026-07-11T09:07:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/thescrumacademy.com\\\/es\\\/2008\\\/08\\\/11\\\/fake-objects\\\/\"},\"wordCount\":312,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/thescrumacademy.com\\\/es\\\/2008\\\/08\\\/11\\\/fake-objects\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/thescrumacademy.com\\\/wp-content\\\/uploads\\\/2008\\\/08\\\/vecteezy_man-holding-a-hammer_49151667.jpg\",\"articleSection\":[\"Agile Scrum\",\"Design Excellence\",\"Developers\",\"Extreme Programming\",\"Legacy Code\",\"Practitioners\",\"Refactoring\",\"Scrum Framework\",\"Scrum Methodology\",\"Simple Design\",\"Test-Driven Development\",\"Testing\"],\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/thescrumacademy.com\\\/es\\\/2008\\\/08\\\/11\\\/fake-objects\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/thescrumacademy.com\\\/es\\\/2008\\\/08\\\/11\\\/fake-objects\\\/\",\"url\":\"https:\\\/\\\/thescrumacademy.com\\\/es\\\/2008\\\/08\\\/11\\\/fake-objects\\\/\",\"name\":\"Fake Objects - The Scrum Academy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/thescrumacademy.com\\\/es\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/thescrumacademy.com\\\/es\\\/2008\\\/08\\\/11\\\/fake-objects\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/thescrumacademy.com\\\/es\\\/2008\\\/08\\\/11\\\/fake-objects\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/thescrumacademy.com\\\/wp-content\\\/uploads\\\/2008\\\/08\\\/vecteezy_man-holding-a-hammer_49151667.jpg\",\"datePublished\":\"2008-08-12T04:24:58+00:00\",\"dateModified\":\"2026-07-11T09:07:12+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/thescrumacademy.com\\\/es\\\/#\\\/schema\\\/person\\\/2a0fb199044ecd4af3704c734747fc6a\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/thescrumacademy.com\\\/es\\\/2008\\\/08\\\/11\\\/fake-objects\\\/#breadcrumb\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/thescrumacademy.com\\\/es\\\/2008\\\/08\\\/11\\\/fake-objects\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\\\/\\\/thescrumacademy.com\\\/es\\\/2008\\\/08\\\/11\\\/fake-objects\\\/#primaryimage\",\"url\":\"https:\\\/\\\/thescrumacademy.com\\\/wp-content\\\/uploads\\\/2008\\\/08\\\/vecteezy_man-holding-a-hammer_49151667.jpg\",\"contentUrl\":\"https:\\\/\\\/thescrumacademy.com\\\/wp-content\\\/uploads\\\/2008\\\/08\\\/vecteezy_man-holding-a-hammer_49151667.jpg\",\"width\":1200,\"height\":673,\"caption\":\"A man is shown holding a hammer in his hand, his grip firm and focused. The tool appears sturdy and wellused, suggesting it is ready for a task at hand.\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/thescrumacademy.com\\\/es\\\/2008\\\/08\\\/11\\\/fake-objects\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/thescrumacademy.com\\\/es\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Fake Objects\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/thescrumacademy.com\\\/es\\\/#website\",\"url\":\"https:\\\/\\\/thescrumacademy.com\\\/es\\\/\",\"name\":\"The Scrum Academy\",\"description\":\"Everyone anywhere can do better Scrum\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/thescrumacademy.com\\\/es\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"es\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/thescrumacademy.com\\\/es\\\/#\\\/schema\\\/person\\\/2a0fb199044ecd4af3704c734747fc6a\",\"name\":\"Carlton Nettleton\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6d69c37c349230a49a1ec6c77c21c4b35043de9fbcce8a202d61f707025cd537?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6d69c37c349230a49a1ec6c77c21c4b35043de9fbcce8a202d61f707025cd537?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6d69c37c349230a49a1ec6c77c21c4b35043de9fbcce8a202d61f707025cd537?s=96&d=mm&r=g\",\"caption\":\"Carlton Nettleton\"},\"description\":\"My name is Carlton Nettleton and I am the President of Look Forward Consulting. I am an international speaker, trainer and author of the book, Fourteen Observations of Good Scrum Practice and my book has been translated into Spanish. My passion is to share my excitement, enthusiasm and encouragement with teams and organizations as they reach for higher levels of performance and engagement. My business is to help your business grow and flourish.\",\"url\":\"https:\\\/\\\/thescrumacademy.com\\\/es\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Fake Objects - The Scrum Academy","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/thescrumacademy.com\/es\/2008\/08\/11\/fake-objects\/","og_locale":"es_ES","og_type":"article","og_title":"Fake Objects - The Scrum Academy","og_description":"I was writing some tests today around some legacy code (its about 2 weeks old and not written with TDD) and wanted to make sure that some method was called [...]","og_url":"https:\/\/thescrumacademy.com\/es\/2008\/08\/11\/fake-objects\/","og_site_name":"The Scrum Academy","article_published_time":"2008-08-12T04:24:58+00:00","article_modified_time":"2026-07-11T09:07:12+00:00","og_image":[{"width":1200,"height":673,"url":"https:\/\/thescrumacademy.com\/wp-content\/uploads\/2008\/08\/vecteezy_man-holding-a-hammer_49151667.jpg","type":"image\/jpeg"}],"author":"Carlton Nettleton","twitter_card":"summary_large_image","twitter_misc":{"Escrito por":"Carlton Nettleton","Tiempo de lectura":"2 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/thescrumacademy.com\/es\/2008\/08\/11\/fake-objects\/#article","isPartOf":{"@id":"https:\/\/thescrumacademy.com\/es\/2008\/08\/11\/fake-objects\/"},"author":{"name":"Carlton Nettleton","@id":"https:\/\/thescrumacademy.com\/es\/#\/schema\/person\/2a0fb199044ecd4af3704c734747fc6a"},"headline":"Fake Objects","datePublished":"2008-08-12T04:24:58+00:00","dateModified":"2026-07-11T09:07:12+00:00","mainEntityOfPage":{"@id":"https:\/\/thescrumacademy.com\/es\/2008\/08\/11\/fake-objects\/"},"wordCount":312,"commentCount":0,"image":{"@id":"https:\/\/thescrumacademy.com\/es\/2008\/08\/11\/fake-objects\/#primaryimage"},"thumbnailUrl":"https:\/\/thescrumacademy.com\/wp-content\/uploads\/2008\/08\/vecteezy_man-holding-a-hammer_49151667.jpg","articleSection":["Agile Scrum","Design Excellence","Developers","Extreme Programming","Legacy Code","Practitioners","Refactoring","Scrum Framework","Scrum Methodology","Simple Design","Test-Driven Development","Testing"],"inLanguage":"es","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/thescrumacademy.com\/es\/2008\/08\/11\/fake-objects\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/thescrumacademy.com\/es\/2008\/08\/11\/fake-objects\/","url":"https:\/\/thescrumacademy.com\/es\/2008\/08\/11\/fake-objects\/","name":"Fake Objects - The Scrum Academy","isPartOf":{"@id":"https:\/\/thescrumacademy.com\/es\/#website"},"primaryImageOfPage":{"@id":"https:\/\/thescrumacademy.com\/es\/2008\/08\/11\/fake-objects\/#primaryimage"},"image":{"@id":"https:\/\/thescrumacademy.com\/es\/2008\/08\/11\/fake-objects\/#primaryimage"},"thumbnailUrl":"https:\/\/thescrumacademy.com\/wp-content\/uploads\/2008\/08\/vecteezy_man-holding-a-hammer_49151667.jpg","datePublished":"2008-08-12T04:24:58+00:00","dateModified":"2026-07-11T09:07:12+00:00","author":{"@id":"https:\/\/thescrumacademy.com\/es\/#\/schema\/person\/2a0fb199044ecd4af3704c734747fc6a"},"breadcrumb":{"@id":"https:\/\/thescrumacademy.com\/es\/2008\/08\/11\/fake-objects\/#breadcrumb"},"inLanguage":"es","potentialAction":[{"@type":"ReadAction","target":["https:\/\/thescrumacademy.com\/es\/2008\/08\/11\/fake-objects\/"]}]},{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/thescrumacademy.com\/es\/2008\/08\/11\/fake-objects\/#primaryimage","url":"https:\/\/thescrumacademy.com\/wp-content\/uploads\/2008\/08\/vecteezy_man-holding-a-hammer_49151667.jpg","contentUrl":"https:\/\/thescrumacademy.com\/wp-content\/uploads\/2008\/08\/vecteezy_man-holding-a-hammer_49151667.jpg","width":1200,"height":673,"caption":"A man is shown holding a hammer in his hand, his grip firm and focused. The tool appears sturdy and wellused, suggesting it is ready for a task at hand."},{"@type":"BreadcrumbList","@id":"https:\/\/thescrumacademy.com\/es\/2008\/08\/11\/fake-objects\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/thescrumacademy.com\/es\/"},{"@type":"ListItem","position":2,"name":"Fake Objects"}]},{"@type":"WebSite","@id":"https:\/\/thescrumacademy.com\/es\/#website","url":"https:\/\/thescrumacademy.com\/es\/","name":"The Scrum Academy","description":"Everyone anywhere can do better Scrum","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/thescrumacademy.com\/es\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"es"},{"@type":"Person","@id":"https:\/\/thescrumacademy.com\/es\/#\/schema\/person\/2a0fb199044ecd4af3704c734747fc6a","name":"Carlton Nettleton","image":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/secure.gravatar.com\/avatar\/6d69c37c349230a49a1ec6c77c21c4b35043de9fbcce8a202d61f707025cd537?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/6d69c37c349230a49a1ec6c77c21c4b35043de9fbcce8a202d61f707025cd537?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6d69c37c349230a49a1ec6c77c21c4b35043de9fbcce8a202d61f707025cd537?s=96&d=mm&r=g","caption":"Carlton Nettleton"},"description":"My name is Carlton Nettleton and I am the President of Look Forward Consulting. I am an international speaker, trainer and author of the book, Fourteen Observations of Good Scrum Practice and my book has been translated into Spanish. My passion is to share my excitement, enthusiasm and encouragement with teams and organizations as they reach for higher levels of performance and engagement. My business is to help your business grow and flourish.","url":"https:\/\/thescrumacademy.com\/es\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/thescrumacademy.com\/es\/wp-json\/wp\/v2\/posts\/74","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thescrumacademy.com\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thescrumacademy.com\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thescrumacademy.com\/es\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thescrumacademy.com\/es\/wp-json\/wp\/v2\/comments?post=74"}],"version-history":[{"count":1,"href":"https:\/\/thescrumacademy.com\/es\/wp-json\/wp\/v2\/posts\/74\/revisions"}],"predecessor-version":[{"id":8841,"href":"https:\/\/thescrumacademy.com\/es\/wp-json\/wp\/v2\/posts\/74\/revisions\/8841"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/thescrumacademy.com\/es\/wp-json\/wp\/v2\/media\/7489"}],"wp:attachment":[{"href":"https:\/\/thescrumacademy.com\/es\/wp-json\/wp\/v2\/media?parent=74"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thescrumacademy.com\/es\/wp-json\/wp\/v2\/categories?post=74"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thescrumacademy.com\/es\/wp-json\/wp\/v2\/tags?post=74"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}