Two Ways to Mock System.Web.HttpContext

The other day I was writing some unit tests for testing my MVC application's forms authentication classes.  I needed to Mock the System.Web.HttpContext object.  There are a couple of ways to do this depending on the version of Visual Studio you are using (i.e. Professional, Premium/Ultimate/Enterprise) and how deep you wish to provide some default data.   One takes a little more leg work and requires some manual data setting, but gives you greater control.  While the other requires less coding for simple basic use.

Read more


Fakes Issue with System.Web

The other day I was writing some unit tests on an MVC project.  I needed to mock (fake) an HttpRequest object using the System.Web assembly.  However, there was a strange issue in creating the fakes assembly and adding it to my Visual Studio solution.  Namely, it didn't show up.Read more


Unit Testing an MVC Model

Do your MVC model properties contain attributes?  Have you ever wanted to unit test the properties to verify that the ModelState fails or succeeds based on given values?  Below is a static method that can be used for your unit tests as you test your models.
Read more


Slipstream SQL Installation

The other day I needed to install SQL Server 2008 R2 SP1 on a machine.  Because I was installing it on a Windows Server 2003, I couldn't simply install SQL 2008, I needed to install R2 SP1 because SQL Server 2008 doesn't like being installed on Windows Server 2003.  Unfortunately, SQL Server 2008 R2 SP1 doesn't have a base installer - there's only an upgrade installer.  So, I was required to perform a procedure call "slipstreaming".  A slipstream installation is one in which the upgrade pack is added to the base installer and installed initially instead of installing the base and upgrading.  In this way, SQL Server 2008 R2 SP1, because it's compatible with Windows Server 2003, would not complain at install time.

Read more


Exploring SharePoint Export

I'm currently working with a client for whom I'm upgrading their mixed 2007 and 2010 farm to SharePoint 2013.  Unfortunately, a site collection on a SharePoint 2007 farm they no longer have access to was exported instead of backed up.  What makes matters worse, whoever performed the export, expanded the .cmp file.  My client wanted the files from export.

While there are a few sites that give instructions on how to perform imports (like, here, here and here), as anyone who has worked with SharePoint 2007, it can be very finicky - everything, including the stars, must line up.  I also tried "re-compressing" the export file since the .cmp file is nothing more than a .cab file.  However, I had additional issues with the resulting .cab file since we were dealing with a 7GB file on a Windows 2003 machine (they don't play nicely together).  I also tried using a tool from Mike Smith to convert the files from the export file.  But, being that Mike hadn't worked on the solution since many years ago, of course, the application was giving me cryptic exception errors.

After all failed attempts, I was finally required to write a PowerShell script that reads the Manifest.xml and converts all of the .dat files to their original filenames in the original SharePoint 2007 file structure.  I've posted the PowerShell script on GitHub.

Have fun!


Windows Server 2012 WDS Capture Image - winload.exe corrupt or missing

The other day I was setting up a new Windows Deployment Services image for a TFS/SharePoint Hyper-V environment.  The host machine was running Windows Server 2012 R2.  Per the normal process, I imported the Install.wim and Boot.wim images from the Windows Server 2012 media to my Install Images and Boot Images folders, respectively, in WDS.  This process operated as expected and were imported successfully.

I, then, needed to create a capture image in order to capture my Windows Server 2012 images for redeployment.  Therefore, I right-clicked on the Boot.wim image in Windows Deployment Services and clicked on "Create Capture Image..." to create my capture image.  The capture image was created successfully, or so I thought...Read more


AjaxOnly Attribute for MVC Actions

Ever wanted to restrict actions to only responding to Ajax requests?  How about restricting them through the use of a custom attribute?

Read more


'Hello World' with Node.js and Visual Studio Code

As I've shared in other posts, I like trying new things. One new thing I've been working with over the past couple of weeks is Visual Studio Code (VSC) - a lightweight editor from Microsoft that recognizes and offers IntelliSense for many different file formats. Unlike the commercial or even community editions of Visual Studio, VSC is not solution- or project-based. Instead, VSC is based on directory structures.

For those of you interested in building native JavaScript applications using Node.js, I wanted to provide a demo in how to accomplish this using Visual Studio Code. While full versions of Visual Studio do support Node.js applications, it can sometimes be overkill, especially if you're not needing pre-compiled libraries based on the .NET Framework (VSC does support referencing external libraries and compilation with MSBuild, but then we get into the discussion of should we use VSC vs. Visual Studio, which is not the point of this blog post). Again, the demonstration below is to assist you as you look to build native JavaScript applications.
Read more


R with Visual Studio Code

I always love to learn new things. Right now, I'm experimenting with R and statistical computing. Additionally, I'm playing around with the new lightweight development environment from Microsoft, Visual Studio Code.  So, this is a post that demonstrates setting up Visual Studio Code to run R applications.Read more


Automation Testing with SeleniumHQ

In an earlier post, I provided step-by-step instructions in how to perform Behavior Driven Development using Visual Studio, SpecFlow, WatiN and DryRunner.  However, I've had a lot of students and blog readers ask me about Selenium, a more-common browser automation tool.  So, I'm writing this post to show how to accomplish BDD and automated test driven development (ATDD) using Selenium.Read more