News


Add to Technorati Favorites

My Stats

  • Posts - 51
  • Comments - 209
  • Trackbacks - 20

Twitter












Tag Cloud


Recent Comments


Recent Posts


Archives


Post Categories


Image Galleries


Blogs I read


Company Links


Fun Stuff


Kansas City User Groups


My CMS Projects


October 2009 Entries

Geek Humor | C#/RhinoMocks


nerd

I was IM’ing with a co-worker recently, and both of us were working on writing Unit Tests for code we had just completed. He was saying that his car was having trouble, was in the shop, and that they really didn’t know what was wrong with it.

I was going to tell him to not take any excuses from the mechanic, when the RhinoMocks IgnoreArguments()option popped into my head. I said something like “'tell him ‘FixMyCar.IgnoreArguments()’”, and it was a downward spiral of geek humor from there.

Below is a list that we have compile from that IM, and subsequent discussions. Feel free to leave comments with your own crap.

-Doug

 

 

I said to my wife:

   1: Expect.Call(GoingFishing()).IgnoreArguments().Return(true);

She said:

   1: Expect.Call(GettingLoving()).Return(null);

And:

   1: Expect.Call(SleepLocation()).Return(LocationConstant.Couch);

 

Here’s the result of a bad expectation:

   1: ExpectationException(MowLawn(): Expected, 1, Actual 0)

I then suggested that the humor shouldn’t be limited to just RhinoMocks, but should include C# (and other languages in general)…

   1: if ( You.Want(MyBody) && You.Think(IAmSexy) )
   2: {
   3:     ComeOnBaby.LetMeKnow();
   4: }

posted @ Thursday, October 22, 2009 5:09 PM | Feedback (0) |


ReSharper | Surround With


Just stumbled across some pretty cool functionality with Jet Brains ReSharper 4.0 (you may already be familiar with it, but who cares, it’s still cool!)

 

Basically, ReSharper has a Surround With tool that allows you to surround a selection of code with… more code. It comes with a bunch of predefined templates, like if..else, using, while, try..catch blocks, but you can edit existing templates and also create and organize your own custom templates.

To get to the Templates Explorer, select ReSharper > Live Templates… from the file menu. Select the Surround Templates tab. Once you’re in there, click on the New Template icon and a new File will open in the IDE, and filled by default with the text $SELECTION$. This is the code selection that will be wrapped when your template is applied. Below is a cap of a sample wrapper with some sample template code.

 

resharper_templates_explorer

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

To apply the template, highlight your code selection

 

resharper_pre_change

 

 

 

 

 

 

Select ReSharper > Code > Surround With… from the File menu (or CTRL + E, U).

 

resharper_wrap_menu

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Choose More… from the menu. Find your  template in the dialog and click OK.

 

resharper_find_template

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

When your template is applied, your selection will be replaced with the wrapped text, like below.

 

resharper_post_change

 

 

 

 

 

 

 

This is just the basic stuff. You can categorize your templates, choose which language they will apply to, add them to the quicklist (so they get assigned a quick key), and a whole bunch of other stuff that can be found on the ReSharper help pages.

 

posted @ Thursday, October 15, 2009 6:00 PM | Feedback (3) |


WCF Service Reference | 'extendedProtectionPolicy'


I was trying to regenerate a Silverlight proxy, but I kept getting this error:

extendedProtectionPolicy

 

 

 

 

 

 

 

 

 

 

Turns out, Win 7 sometimes adds an <extendedProtectionPolicy policyEnforcement="Never" /> element to your Web.config.

 

Here’s the workaround according to the Silverlight Web Services team:

On Windows 7, when you use the Silverlight-enabled WCF Service item template, an <extendedProtectionPolicy /> element may be generated in Web.config. This element is not supported by Silverlight. Simply remove the element from Web.config and try regenerating the Silverlight proxy.

 

Here’s the link to the article that talks about this, and other issues in Silverlight 3 Beta.

 

posted @ Friday, October 09, 2009 8:08 AM | Feedback (0) |