Thursday, January 16, 2014

Fixing IISExpress Host Registration Issue

If you have properly added to the applicationhost.config
<binding protocol="http" bindingInformation="*:<portnumber>:<hostname>" />
and you still get the error then try opening an Administrator cmd window and execute
netsh http add urlacl url="http://<hostname>:<portnumber>/" user=everyone

Saturday, June 22, 2013

Why I Re-activated my Facebook Account

Last week I had had enough of Facebook. The most recent issue I've had with it is how spammers are now using your social network graph to make spam look more like legitimate emails by adding from names and cc'ing real people. 

So I left Facebook.

Well actually I am a coward so I only deactivated my account. And for the last week I haven't missed it one bit. 

Then last night I had a vivid dream about my dad, who lost his battle with cancer last August. When I awoke I remembered the dream so vividly and I was overcome with the feeling that if I ever decided to come back to Facebook, my dad would not be there to accept my friend request.

There are a few other friends I have lost in the last couple of years and I find myself occasionally visiting their walls to read the words from others who share the sadness from them missing in our lives. 

So today I re-activated my account. To bring me comfort that there's a virtual space for me to reflect on the loved ones who can no longer accept my friend requests. 

Tuesday, March 5, 2013

Nooks & Crannies

Today I used two features in NUnit that I have never used before and I thought I would share for those who have yet to discover these great features as well.


TestFixture Parameters

Did you know that the TestFixtureAttribute can take parameters?

   1:  [TestFixture("My Name")]

Did you know that you can place more than one on your class?

   1:  [TestFixture("My Name")]
   2:  [TestFixture("Your Name")]
   3:  public class SimpleTests
   4:  {
   5:  }

I have recently been writing normal NUnit tests in a BDD influenced style. I know there are frameworks like SpecFlow and machine.specifications that are better then what I am doing, but at work I am trying to reduce the number of frameworks I introduce in a week, and those two are pretty invasive in that they both require VS2102 integrations for their maximum benefit.

For my BDD-ish test I have taken to making test fixtures that look like this

   1:  [TestFixture]
   2:  public class SimpleGreeterTests
   3:  {
   4:      [SetUp]
   5:      public void SetUp()
   6:      {
   7:          EstablishContext();
   8:          given_I_have_a_name();
   9:          when_the_greeter_greets();
  10:      }
  11:   
  12:      [Test]
  13:      public void then_the_greeting_should_say_hello()
  14:      {
  15:          Assert.That(Result, Is.EqualTo(string.Format("Hello {0}", Name)));
  16:      }
  17:   
  18:      protected string Name { get; set; }
  19:      protected IGreeter Subject { get; set; }
  20:      protected string Result { get; set; }
  21:   
  22:      protected void EstablishContext()
  23:      {
  24:          Subject = new Greeter();
  25:      }
  26:   
  27:      protected void given_I_have_a_name()
  28:      {
  29:          Name = RandomDataHelper.Get<string>();
  30:      }
  31:   
  32:      protected void when_the_greeter_greets()
  33:      {
  34:          Result = Subject.Greet(Name);
  35:      }
  36:  }

This pattern is something I am really enjoying and not the real topic here.

Today I created a test very similar in nature to this. I my case I need to code to return something different based on specific values of name. I thought I would have to write multiple suites. I knew I could execute a test multiple times with the TestCase attribute, but with this BDD structure to my tests, I needed the data to vary within the scope of the SetUp method.

Luckily NUnit introduced TestFixture parameters in 2.5. Which allowed me to make a test like this

   1:  [TestFixture("Jimmy", "Hello Mr. Bosse")]
   2:  [TestFixture("Lisa", "Hello Mrs. Bosse")]
   3:  public class SimpleGreeterTests
   4:  {
   5:      [SetUp]
   6:      public void SetUp()
   7:      {
   8:          EstablishContext();
   9:          given_my_name_is(_name);
  10:          when_the_greeter_greets();
  11:      }
  12:   
  13:      [Test]
  14:      public void then_the_greeting_should_say_hello()
  15:      {
  16:          Assert.That(Result, Is.EqualTo(_greeting));
  17:      }
  18:   
  19:      protected string Name { get; set; }
  20:      protected IGreeter Subject { get; set; }
  21:      protected string Result { get; set; }
  22:   
  23:      public SimpleGreeterTests(string name, string greeting)
  24:      {
  25:          _name = name;
  26:          _greeting = greeting;
  27:      }
  28:   
  29:      protected void EstablishContext()
  30:      {
  31:          Subject = new Greeter();
  32:      }
  33:   
  34:      protected void given_I_have_a_name(string name)
  35:      {
  36:          Name = name;
  37:      }
  38:   
  39:      protected void when_the_greeter_greets()
  40:      {
  41:          Result = Subject.Greet(Name);
  42:      }
  43:  }

CollectionAssert.Order

The next little gem I discovered was the more robust asserts NUnit lets you do against collections. For years I have been testing that my arrays contain the same elements

Assert.That(thisArray, Is.EquivalentTo(thatArray));

but today I needed to make sure my array was in the correct order. Through the magic of intellisense I was able to find this little nugget

Assert.That(thisArray, Is.Ordered.By("LastName"));

Lesson Learned

While my approach to new frameworks is often to find out just enough to get me going on the thing I  am building right now, I think I will try harder to fight TL;DR; and spend more time in the nooks and crannies.

Friday, December 21, 2012

Using Dynamic Instead of Type Casting

Yesterday I was writing some NUnit tests for an MVC controller. My test was making sure that a property on the model being placed in the view had a property set correctly:

   1:  var sut = new MyController(fakeProvider);
   2:  var result = (ViewResult) sut.Index(id);
   3:  var model = result.Model;
   4:  Assert.That(model.MyProperty, Is.EqualTo(expectedValue);

Often type casting can be full of syntactic noise. I could refactor that code to remove a line:

   1:  var sut = new MyController(fakeProvider);
   2:  var model = ((ViewResult) sut.Index(id)).Model;
   3:  Assert.That(model.MyProperty, Is.EqualTo(expectedValue);

All those parenthesis on line two are like fingernails on a chalkboard to me. Luckily I was having a problem with the razor view when I was trying to preview the controller that resulted in me hacking away at my code until it looked like:

   1:  var sut = new MyController(fakeProvider);
   2:  dynamic result = sut.Index(id);
   3:  Assert.That(result.Model.MyProperty, Is.EqualTo(expectedValue);

I didn’t even notice until this morning when working on another action in the controller that I had removed the need for casting my ActionResult to a ViewResult in my test. What a happy accident. I suspect that the compiler is doing the type casting for me under the covers, but I leave ILDASM to @vcsjones, so I’ll never know for sure.

I am filing that little tidbit in my bag of tricks and will definitely be using that in the future.

Tuesday, December 4, 2012

Mani-Pedis with Kyro


I just finished reading a well written article "Why I'm No Metrosexual" Kyro Beshay in which he laments the lack of skuomorphism (or at least a beveled button) in Windows 8.

The foundation of his argument is that we need this visual cues to tell us how to interact with an interface. I find this argument without merit in as much as I'm sure Kyro has managed to navigate his way around the internet using hyperlinks and not just buttons. Nothing in the physical world would translate an underlined word as something to interact with, yet billions of hyperlinks are clicked each day.

Then how do we know to click on these underlined words? Someone taught us. There was probably a time in each of our lives when we first looked at an HTML hyperlink and never thought to click the word. Then one day we saw someone else browsing a page, and they clicked a word and it took them to another part of the page, or a whole new document. From then on we looked for clues that the words in the text we were reading would take us to some other, releated content.

In recent months, or in the coming months, you will be introduced to the new Windows Start screen. "Can I click on on those tiles?" Kyro asks. This is as valid a qeustion as, "Can I click on those words?"  It takes only a few seconds to be taught that every tile on the Start screen will open an application for you, and just a few minutes more to learn that the live tiles are infinately more helpful in providing information, even to the point of preventing you from needing to launch the application in the first place. Why can't a button also be a billboard?

So Kyro, why not come out with me for a mani-pedi, and I'll teach you the visual language of Windows 8. Its really not that hard.

Friday, October 12, 2012

Wednesday, October 10, 2012

Influencer Appreciation Week: Jonathan Cogley


In 2008, I was the only developer where I worked. While it afforded my the opportunity to "work the whole stack". it also meant I could often get stuck, and getting unstuck was hard. I decided that there was probably a user group that I could join to spend some time with my peers. An internet search landed me at the RockNUG website. As it happened they had just had their monthly meeting and the speaker, Jonathan Cogley, had given a talk on TDD. Since I had discovered TDD the previous year, I clicked on his bio to learn a bit more. On his site I happened across a job posting. There are very few moments in life you can attribute to "fate", but here I was staring at a job description that read as if I had written it in response to the question "write a job posting for your dream job". A week later I had a new job. Working at Thycotic was an amazing experience. I learned about what doing development right looks like and I got to help many other companies see the benefits of Agile and TDD as well.

Thank you Jonathan for giving me the opportunity to learn and spread the joys of Agile and TDD.
Follow me on App.net