Friday, July 12, 2013

Continous Testing with SpecWatchr

I was impressed with Amir Rajan's talk at Austin .Net this week, and was intrigued by his use of the Continuous Testing framework SpecWatchr, so I decided to give it a spin. You can download it at here. I found the installation instructions very clear and concise. You need to download Ruby 1.9.2 and Growl.

By default it assumes nspec, but it was easy enough to change it in dotnet.watchr.rb to be NUnit.

By default SpecWatchr assumes all the tests for MyClass.cs are in a file named "describe_MyClass.cs", which mine were not. Mine tests are in MyClassTest.cs. But since this is open source, I cracked open "watcher_dot_net.rb" and changed half a dozen lines of Ruby and got it to recognize my convention. It worked like a charm.

Amir encouged the .Net group to reduce the friction in development. One of these frictions is to manually save and run tests. With SpecWatchr all you have to do is save a file and it will automagically compile and run affected tests. When all is happy you get this in the corner of your screen for a few seconds.  :
If you have a compile time error you get this:
Things to like about SpecWatchr:
  • It's free!
  • It works.
  • It's well documented.
  • It's easy to install.
Things not to like: You have to annotate your tests with a category, which is the name of the class affected.   I don't see anyway around this without some serious introspection of the code.

Overall SpecWatchr is  a great tool.

Thursday, July 11, 2013

Pictures from Austin .Net Users Group July 8, 2013: Getting things done with dynamic ASP.NET

Amir Rajan (@amirrajan) gave an interesting talk on how to use C# 4.0's dynamic objects in MVC using the Oak framework to the 50 members present. Here's a few pics just in case you were wondering what a geekfest looks like.

My jumbled notes:
  • Hey, Amir is using Emacs - my people!
  • Recommends AngularJS and Knockout
  • Rake used to build and populate system
  • used conEmu for console
  • Oak has a DynamicDB and DymanicRepository
  • "ghost methods" are not present at compile time, but added dynamically
  • Use "System.Diagnostics.Debugger.Launch();" in code to bring up the debugger
  • Amir recommended http://www.infoq.com/presentations/Simple-Made-Easy
  • The Gemini extends the properties of System.Dynamic.DynamicObject to be more Rubyesque.
  • Amir used specWatchr for automatic compiling and testing
  • For GUI testing use "canopy F#", which is a layer above Selenium.
  • Three things: reduce friction, dynamic typing, increase feedback
  • dynamic is a thing. SignalR uses it.

Tuesday, July 02, 2013

How to disable Viewstate in .Net

Viewstate reminds me of a monster in a horror movie that just won't stay dead - it keeps coming back, and back.  No matter how many silver bullets you pump into its chest, it keeps coming.
You can turn off viewstate by adding the attribute "EnableViewState" to your page.

 <%@ Page language="c#" EnableViewState="false" Inherits="MyAwesomeApp.table" %>

But it didn't work in my page.  The value of EnableViewState is overridden by the MasterPage's value.
You can also change "EnableViewState" in web.configs with

<pages enableViewState=“false” />

But depending on which subdirectory the web.config is in, it may be overridden by something else.
The way I finally killed viewstate was by explicitly setting  the "EnableViewState" variable on the page:


private void Page_Load(object sender, EventArgs e)
  {
        this.EnableViewState = false;
        ...
   }

Then it stayed dead. 
Hmmm.... hey wait ... is that a heartbeat I'm hearing?

Monday, June 17, 2013

How to tell if you have .Net 4.5 installed

Since 4.5 is a drop in replacement for 4.0 you can't just look at the version and build number, v4.0.30319..
You have to look in the registry for HKLM\Software\Microsoft\NET Framework Setup\NDP\v4\Full.
If you have only version 4.0, "Version" is "4.0" and there is no "Release" key.
The official Microsoft documentation says that if the "Release" key exists and it's value is greater than 378389, then it's 4.5.
 My observation of looking at exactly two machines: If you already have .Net 4.5 installed, the value of "Version" is 4.5.50709.

Monday, June 10, 2013

Visual Studio 2012 Error: Could not find ... specified for Main method

This morning I ran into a problem while trying to compile.  Visual Studio 2012 gave me this error:
"Could not find 'Test.GetWebPage' specified for Main method"
I tried removing the file with the method from the project - since I could find no other bit of code referencing "GetWebPage", but Visual Studio still would not compile, complaining that file "CSC" needed it.
The issue was I had set GetWebPage as the startup object and now the method was gone.
To fix: inside Solution Explorer, right click on the project and select "Properties...".  Then under "Applicaiton" set the "Startup object:" to "(Not set)".

Wednesday, April 24, 2013

Photos from Austin on Rails Apr 23, 2013

Just in case you wanted to know what the Austin on Rails group looks like in an IPhone panorama shot: 70 people listened as Matt Swain talked about Amazon's cloud solution and how to use Elastic Beanstalk, the Amazon tool for configuring virtual servers. (It took me way too long to get the Jack and The Beanstalk/Cloud connection).


 

Mike Myers from HomeAway gave a good overview of using a JRuby/Rails front end with a Java backend.

I talked with Jeff Hennigan, the main recruiter at KForce, before the meeting and he said a few interesting things: The Ruby job market is hot. Java and .Net are still good. This new generation of Ruby programmers is different than the Java/.Net crowd. Some of the startups use social media to communicate and don't even have a phone number.


My random jumble of notes:
AWS comes with Route53 for DNS and Cloudfront for CDN.
"eb" is a
Command Line Interpreter for Elastic Beanstalk; so you can do "eb init", "eb stop". It just abstracts our the
JSON file that really defines an AWS service.
Amazon offers a free virtual server for those wanting to try out the system. 750 hours per month free.
Amazon tunes the kernal in their own version of linux for different sized machines.
JRuby gives real Native Threads, while Ruby only has green threads.

Monday, April 08, 2013

Pictures from Austin .Net Meeting April 8th, 2013

Ryan Vice gave an interesting overview of Web API to 65 software professionals.




My brief jumbled notes:
AustinApi will be having it's first meeting Wednesday, April 24, 2013 for those interested in producing and comsuming web APIs.
The HTTP PUT verb is used for idempotent actions, otherwise use POST. "application/json" is the header for passing JSON.
Fiddler is a great tool to use for testing APIs.
Response.AddHeader("location", "http://example.com/Accounts/4")
The MVC4 model binder can grab values from the url, the body, or the headers.
Microsoft, to their credit, is using the open source JSON.NET serializer. You can customize the variables returned by using a custom ContractResolver. (return "first-choice", or "firstChoice" or "first_choice").
IAPIExplorer can document your APIs similar to a WSDL.
You can download the WebAPI "Help Pages" from nuget.
I liked Ryan's last comment about Web API bringing us closer to the "elusive dream of concentrating on business logic." (Not necessarily because I think Web API will do that for us, but it should be the focus of frameworks to remove all the mundane tasks that slow us down. Perhaps in 40 years we will get there.)