REQUEST A DEMO

Tag: c#

Extension Methods I Use A Lot

September 23, 2009 C# extensions have been around for some time and it was a fad for a while to post your favorites. I am following way behind the extension party bus with this post of my favorite extensions. Most of these are poached from Chad and Jeremy and Josh with a few sadly only one of my own mixed in. Below is the Basic Extensions class that is common to a lot of our Dovetail projects. I am not a big believer in class libraries for simple little things like these as extensions that are useful on one project will be useless on another. using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Web.Script.Serialization; namespace Dovetail.Commons { public static class BasicExtensions { /// <summary> /// Write string to the console. /// </summary> public static void WriteToConsole(this string stringValue) { Console.WriteLine(stringValue); } ///…

Getting WebDev.WebHost to work on 64 bit Windows

October 2, 2008 In the past I wrote on how we are doing integration testing of a web services using the WebDev.WebHost assembly. This technique has found its way into Dovetail Seeker and is really handy to do an end to end test against a live web server. I ran into trouble running the tests now that I am running a 64bit OS.   You get this error when trying to spin up the test web server:   An attempt was made to load a program with an incorrect format.   It turns out the WebDev.WebHost assembly is flagged as a 32bit which forces it to be run only within a 32bit version of the framework. In my build automation nunitconsole.exe is the test runner and it is likely flagged as Any CPU and thus running in 64bit mode by default. After checking out Scott Hanselman’s post…

Scenario Testing With Watin

July 16, 2008   We are starting to use WatiN to automate the testing of a web application. So far it is working pretty well. One of the things I found confusing was handling confirmation alerts like this:       Pop-ups like this need to be handled by Watin. The code for handling this looks like this.   //setup a handler with Watin var confirmDialogHandler = new ConfirmDialogHandler(); browser.DialogWatcher.Add(confirmDialogHandler); //click the button that causes a confirmation pop-up browser.Element("buttonId").ClickNoWait(); //Clickon the ok button of the confirmation window. confirmDialogHandler.WaitUntilExists(); confirmDialogHandler.OKButton.Click(); browser.WaitForComplete(); //You may want to test that the message is correct. //cleanup browser.DialogWatcher.RemoveAll(confirmDialogHandler);   There is a lot of setup and teardown for the simply clicking a button. Using some .Net 3.5 goodness I created an extension method to make this a little more terse.   //usage Browser.OkButtonClickedOnConfirmDialog(ClickOnUnMarkMasterButton); //could use a lambda but this utilty method…