<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>TJ Solutions - Testing</title>
    <link>http://www.tjsolutions.nl/</link>
    <description />
    <language>en-us</language>
    <copyright>Tijmen van de Kamp, Tom de Koning</copyright>
    <lastBuildDate>Tue, 01 Dec 2009 17:56:46 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>blog@tjsolutions.nl</managingEditor>
    <webMaster>blog@tjsolutions.nl</webMaster>
    <item>
      <trackback:ping>http://www.tjsolutions.nl/Trackback.aspx?guid=e17144a2-3592-4e5f-9389-a4ffc152bc47</trackback:ping>
      <pingback:server>http://www.tjsolutions.nl/pingback.aspx</pingback:server>
      <pingback:target>http://www.tjsolutions.nl/PermaLink,guid,e17144a2-3592-4e5f-9389-a4ffc152bc47.aspx</pingback:target>
      <dc:creator>Tom</dc:creator>
      <wfw:comment>http://www.tjsolutions.nl/CommentView,guid,e17144a2-3592-4e5f-9389-a4ffc152bc47.aspx</wfw:comment>
      <wfw:commentRss>http://www.tjsolutions.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=e17144a2-3592-4e5f-9389-a4ffc152bc47</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <h1>
        </h1>
        <h1>Manipulating the DOM with Firebug
</h1>
        <p>
Currently I"m working more and more with jQuery and JavaScript to get behavior into
my pages. This was quite painful in the beginning as I was depended a bit too much
on alert"('this happens!').
</p>
        <p>
But I guess this is where you get started and then find out about the excellent <a href="https://addons.mozilla.org/en-US/firefox/addon/1843">firebug</a>.
With the console you can then fire your JavaScript and jQuery commands to the page
like so:
</p>
        <p>
 
</p>
        <p>
 <a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/image_6.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/image_thumb_2.png" width="508" height="481" /></a></p>
        <p>
        </p>
        <p>
 
</p>
        <p>
I'm querying on of Holland's main news sites for their logo. Firebug conveniently
comes up with the link to the element and when clicked it will show where it's located
on the page.
</p>
        <p>
This is all nice but let's change the boring logo of <a href="www.nu.nl">nu.nl</a> to
that of our own!
</p>
        <p>
Easy enough, just use the following to change the picture in the page:
</p>
        <code>$('#sidemenu a img').attr('src', 'http://www.tjsolutions.nl/themes/tjs/images/headerbg.jpg') </code>
        <p>
 
</p>
        <p>
 
</p>
        <p>
          <a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/image_8.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/image_thumb_3.png" width="516" height="488" />
          </a>
        </p>
        <p>
 
</p>
        <p>
But changing the elements in a page is just the beginning. You can just as easily
add new functionality by binding a click event handler to one or more elements in
the page. 
</p>
        <p>
 
</p>
        <h1>Viewing registered events
</h1>
        <p>
You can also use the console to inspect what events are registered to an element on
the page. All you need to do is use this syntax:
</p>
        <code>$(selector).data("events"); </code>
        <p>
 
</p>
        <p>
When we try that on the last input (randomly chosen) you get an overview of all the
events bound (in this case only one).
</p>
        <p>
 
</p>
        <p>
          <a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/events_2.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="events" border="0" alt="events" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/events_thumb.png" width="557" height="147" />
          </a>
        </p>
        <p>
 
</p>
        <p>
If you the click on the object and hover over "function" you'll end up with the code
itself:
</p>
        <p>
 
</p>
        <p>
          <a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/function_2.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="function" border="0" alt="function" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/function_thumb.png" width="559" height="157" />
          </a>
        </p>
        <p>
 
</p>
        <p>
This is a very neat trick that I wish I had stumbled upon earlier. Hope it helps.
</p>
        <img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=e17144a2-3592-4e5f-9389-a4ffc152bc47" />
      </body>
      <title>Getting started with Firebug and jQuery</title>
      <guid isPermaLink="false">http://www.tjsolutions.nl/PermaLink,guid,e17144a2-3592-4e5f-9389-a4ffc152bc47.aspx</guid>
      <link>http://www.tjsolutions.nl/2009/12/01/GettingStartedWithFirebugAndJQuery.aspx</link>
      <pubDate>Tue, 01 Dec 2009 17:56:46 GMT</pubDate>
      <description>&lt;h1&gt;
&lt;/h1&gt;
&lt;h1&gt;Manipulating the DOM with Firebug
&lt;/h1&gt;
&lt;p&gt;
Currently I"m working more and more with jQuery and JavaScript to get behavior into
my pages. This was quite painful in the beginning as I was depended a bit too much
on alert&amp;quot;('this happens!').
&lt;/p&gt;
&lt;p&gt;
But I guess this is where you get started and then find out about the excellent &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/1843"&gt;firebug&lt;/a&gt;.
With the console you can then fire your JavaScript and jQuery commands to the page
like so:
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
&amp;#160;&lt;a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/image_thumb_2.png" width="508" height="481" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
I'm querying on of Holland's main news sites for their logo. Firebug conveniently
comes up with the link to the element and when clicked it will show where it's located
on the page.
&lt;/p&gt;
&lt;p&gt;
This is all nice but let's change the boring logo of &lt;a href="www.nu.nl"&gt;nu.nl&lt;/a&gt; to
that of our own!
&lt;/p&gt;
&lt;p&gt;
Easy enough, just use the following to change the picture in the page:
&lt;/p&gt;
&lt;code&gt;$('#sidemenu a img').attr('src', 'http://www.tjsolutions.nl/themes/tjs/images/headerbg.jpg') &lt;/code&gt; 
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/image_8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/image_thumb_3.png" width="516" height="488" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
But changing the elements in a page is just the beginning. You can just as easily
add new functionality by binding a click event handler to one or more elements in
the page. 
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;h1&gt;Viewing registered events
&lt;/h1&gt;
&lt;p&gt;
You can also use the console to inspect what events are registered to an element on
the page. All you need to do is use this syntax:
&lt;/p&gt;
&lt;code&gt;$(selector).data(&amp;quot;events&amp;quot;); &lt;/code&gt; 
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
When we try that on the last input (randomly chosen) you get an overview of all the
events bound (in this case only one).
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/events_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="events" border="0" alt="events" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/events_thumb.png" width="557" height="147" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
If you the click on the object and hover over "function" you'll end up with the code
itself:
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/function_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="function" border="0" alt="function" src="http://www.tjsolutions.nl/content/binary/WindowsLiveWriter/GettingstartedwithFirebugandjQuery_10A6B/function_thumb.png" width="559" height="157" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;p&gt;
This is a very neat trick that I wish I had stumbled upon earlier. Hope it helps.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=e17144a2-3592-4e5f-9389-a4ffc152bc47" /&gt;</description>
      <comments>http://www.tjsolutions.nl/CommentView,guid,e17144a2-3592-4e5f-9389-a4ffc152bc47.aspx</comments>
      <category>BDD</category>
      <category>Javascript</category>
      <category>Testing</category>
    </item>
    <item>
      <trackback:ping>http://www.tjsolutions.nl/Trackback.aspx?guid=eedd4d22-2ac2-4e85-b62b-626cea249eb2</trackback:ping>
      <pingback:server>http://www.tjsolutions.nl/pingback.aspx</pingback:server>
      <pingback:target>http://www.tjsolutions.nl/PermaLink,guid,eedd4d22-2ac2-4e85-b62b-626cea249eb2.aspx</pingback:target>
      <dc:creator>Tijmen</dc:creator>
      <wfw:comment>http://www.tjsolutions.nl/CommentView,guid,eedd4d22-2ac2-4e85-b62b-626cea249eb2.aspx</wfw:comment>
      <wfw:commentRss>http://www.tjsolutions.nl/SyndicationService.asmx/GetEntryCommentsRss?guid=eedd4d22-2ac2-4e85-b62b-626cea249eb2</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Nothing much to, just that it took me some time to figure it out today. The code below
tests whether DivisionID is actually set in the presenter.
</p>
        <p>
 
</p>
        <pre class="code">
          <span style="color: blue;">public class </span>
          <span style="color: rgb(43, 145, 175);">Presenter </span>{ <span style="color: blue;">readonly </span><span style="color: rgb(43, 145, 175);">IRepository </span>repository; <span style="color: blue;">public </span>Presenter(<span style="color: rgb(43, 145, 175);">IRepository </span>repository)
{ <span style="color: blue;">this</span>.repository = repository; } <span style="color: blue;">public </span><span style="color: rgb(43, 145, 175);">IView </span>View
{ <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; } <span style="color: blue;">public
void </span>GetDivision() { View.DivisionID = repository.GetDivisionID(); } } <span style="color: blue;">public
interface </span><span style="color: rgb(43, 145, 175);">IView </span>{ <span style="color: blue;">int </span>DivisionID
{ <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }
} [<span style="color: rgb(43, 145, 175);">TestFixture</span>] <span style="color: blue;">public
class </span><span style="color: rgb(43, 145, 175);">PresenterTests </span>{ <span style="color: rgb(43, 145, 175);">Presenter </span>sut; <span style="color: rgb(43, 145, 175);">IView </span>view; <span style="color: rgb(43, 145, 175);">IRepository </span>repository;
[<span style="color: rgb(43, 145, 175);">SetUp</span>] <span style="color: blue;">public
void </span>SetUp() { view = <span style="color: rgb(43, 145, 175);">MockRepository</span>.GenerateMock&lt;<span style="color: rgb(43, 145, 175);">IView</span>&gt;();
repository = <span style="color: rgb(43, 145, 175);">MockRepository</span>.GenerateMock&lt;<span style="color: rgb(43, 145, 175);">IRepository</span>&gt;();
sut = <span style="color: blue;">new </span><span style="color: rgb(43, 145, 175);">Presenter</span>(repository){View
= view}; } [<span style="color: rgb(43, 145, 175);">Test</span>] <span style="color: blue;">public
void </span>when_on_the_sut_GetDivisionID_is_called_it_should_set_the_divisionID_on_the_view()
{ <span style="color: green;">//AAA mocking style //Arrange </span><span style="color: blue;">const
int </span>divisionID = 1; repository.Stub(s =&gt; s.GetDivisionID()).Return(divisionID); <span style="color: green;">//note:
the expectation is set when DivisionID is set to divisionID </span>view.Expect(s =&gt;
s.DivisionID = divisionID); <span style="color: green;">//Act </span>sut.GetDivision(); <span style="color: green;">//Assert </span>view.VerifyAllExpectations();
} }</pre>
        <a href="http://11011.net/software/vspaste">
        </a>
        <img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=eedd4d22-2ac2-4e85-b62b-626cea249eb2" />
      </body>
      <title>RhinoMocks - set expectations on setter for automatic properties</title>
      <guid isPermaLink="false">http://www.tjsolutions.nl/PermaLink,guid,eedd4d22-2ac2-4e85-b62b-626cea249eb2.aspx</guid>
      <link>http://www.tjsolutions.nl/2009/09/16/RhinoMocksSetExpectationsOnSetterForAutomaticProperties.aspx</link>
      <pubDate>Wed, 16 Sep 2009 21:00:20 GMT</pubDate>
      <description>&lt;p&gt;
Nothing much to, just that it took me some time to figure it out today. The code below
tests whether DivisionID is actually set in the presenter.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue;"&gt;public class &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;Presenter &lt;/span&gt;{ &lt;span style="color: blue;"&gt;readonly &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;IRepository &lt;/span&gt;repository; &lt;span style="color: blue;"&gt;public &lt;/span&gt;Presenter(&lt;span style="color: rgb(43, 145, 175);"&gt;IRepository &lt;/span&gt;repository)
{ &lt;span style="color: blue;"&gt;this&lt;/span&gt;.repository = repository; } &lt;span style="color: blue;"&gt;public &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;IView &lt;/span&gt;View
{ &lt;span style="color: blue;"&gt;get&lt;/span&gt;; &lt;span style="color: blue;"&gt;set&lt;/span&gt;; } &lt;span style="color: blue;"&gt;public
void &lt;/span&gt;GetDivision() { View.DivisionID = repository.GetDivisionID(); } } &lt;span style="color: blue;"&gt;public
interface &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;IView &lt;/span&gt;{ &lt;span style="color: blue;"&gt;int &lt;/span&gt;DivisionID
{ &lt;span style="color: blue;"&gt;get&lt;/span&gt;; &lt;span style="color: blue;"&gt;set&lt;/span&gt;; }
} [&lt;span style="color: rgb(43, 145, 175);"&gt;TestFixture&lt;/span&gt;] &lt;span style="color: blue;"&gt;public
class &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;PresenterTests &lt;/span&gt;{ &lt;span style="color: rgb(43, 145, 175);"&gt;Presenter &lt;/span&gt;sut; &lt;span style="color: rgb(43, 145, 175);"&gt;IView &lt;/span&gt;view; &lt;span style="color: rgb(43, 145, 175);"&gt;IRepository &lt;/span&gt;repository;
[&lt;span style="color: rgb(43, 145, 175);"&gt;SetUp&lt;/span&gt;] &lt;span style="color: blue;"&gt;public
void &lt;/span&gt;SetUp() { view = &lt;span style="color: rgb(43, 145, 175);"&gt;MockRepository&lt;/span&gt;.GenerateMock&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;IView&lt;/span&gt;&amp;gt;();
repository = &lt;span style="color: rgb(43, 145, 175);"&gt;MockRepository&lt;/span&gt;.GenerateMock&amp;lt;&lt;span style="color: rgb(43, 145, 175);"&gt;IRepository&lt;/span&gt;&amp;gt;();
sut = &lt;span style="color: blue;"&gt;new &lt;/span&gt;&lt;span style="color: rgb(43, 145, 175);"&gt;Presenter&lt;/span&gt;(repository){View
= view}; } [&lt;span style="color: rgb(43, 145, 175);"&gt;Test&lt;/span&gt;] &lt;span style="color: blue;"&gt;public
void &lt;/span&gt;when_on_the_sut_GetDivisionID_is_called_it_should_set_the_divisionID_on_the_view()
{ &lt;span style="color: green;"&gt;//AAA mocking style //Arrange &lt;/span&gt;&lt;span style="color: blue;"&gt;const
int &lt;/span&gt;divisionID = 1; repository.Stub(s =&amp;gt; s.GetDivisionID()).Return(divisionID); &lt;span style="color: green;"&gt;//note:
the expectation is set when DivisionID is set to divisionID &lt;/span&gt;view.Expect(s =&amp;gt;
s.DivisionID = divisionID); &lt;span style="color: green;"&gt;//Act &lt;/span&gt;sut.GetDivision(); &lt;span style="color: green;"&gt;//Assert &lt;/span&gt;view.VerifyAllExpectations();
} }&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;img width="0" height="0" src="http://www.tjsolutions.nl/aggbug.ashx?id=eedd4d22-2ac2-4e85-b62b-626cea249eb2" /&gt;</description>
      <comments>http://www.tjsolutions.nl/CommentView,guid,eedd4d22-2ac2-4e85-b62b-626cea249eb2.aspx</comments>
      <category>Testing</category>
    </item>
  </channel>
</rss>