Skip to main content

Posts

Showing posts from 2011

VWD Express 2010 Unit Tests with xUnit and MVC Templates

Microsoft's Visual Web Developer 2010 Express (VWD 2010 Express), by default does not come with a built in unit testing solution. However the ability is there to use unit tests with the Express version as can be seen when creating a new MVC project. Tech spec stuff: Microsoft Windows 7 Microsoft Visual Studio 2010 Express, Version 10.0.40219.1 SP1 Microsfot .NET Framework Version 4.0.30319 SP1 Getting started with xUnit xUnit is a "developer testing framework, built to support Test Driven Development (TDD)". There are other unit testing frameworks available (MSTest, nUnit, etc.). There are pro's to each and some better than others but xUnit is pretty straightforward to get up and running with the VWD 2010 Express version. Download and Install xUnit The xUnit project can be found at:  http://xunit.codeplex.com/ . Downloads are available from  http://xunit.codeplex.com/releases/view/62840 . Download the recommended version (currently 1.8 at time of writi

EF CodeFirst Database.SetInitializser Requires Connection to 'master' Database Error

One of the features of EF CodeFirst is the ability to automatically drop and recreate a database if the model changes or if the database does not exist, which is pretty useful when just doing development work. In a web app this is done in the Global.asax file within "protected void Application_Start()" as per this post from Scott Guthrie -  http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx . An example would be: protected void Application_Start() { Database.SetInitializer<yourdbcontex>(new DropCreateDatabaseIfModelChanges<yourdbcontext>()); AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); } However when using the Database.SetInitializer and trying to rebuild the database, the following exception may be encountered, especially if using SQL Server Express: "This operation requires a connection to the 'master'

Entity Framework Code-First Learning Resources

Some resources to help learn and understand Microsoft's Entity Framework Code-First ORM. Basic Tutorial http://www.asp.net/mvc/tutorials/getting-started-with-mvc3-part1-cs Advanced Tutorial http://www.asp.net/mvc/tutorials/mvc-music-store-part-1 Blog posts with further hints and tips http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx Update to NerdDinner using EF Code-First. Also shows how to synchronise database with the model and seeding database with initial data. http://www.hanselman.com/blog/SimpleCodeFirstWithEntityFramework4MagicUnicornFeatureCTP4.aspx Some useful info demonstrating Data Annotations such as [Key] and [Required]. This post will be added to as time goes by. If there are any other good resources about this MS framework feel free to throw them in to a comment. Updates EF Feature CTP5: Code First Walkthrough http://blogs.msdn.com/b/adonet/archive/2010/12/06/ef-feature-ctp5-code-first-walkthrou

Mounting and Reading ISO Files

An ISO image (International Organization for Standardization) is an archive file (also known as a disc image) of an optical disc, composed of the data contents of every written sector of an optical disc, including the optical disc file system. From  http://en.wikipedia.org/wiki/ISO_image  08/03/2011 Basically an ISO image, in layman's terms, is the file on a CD-ROM or DVD. ISO images can be downloaded and saved onto a CD or DVD and run as usual. Alternatively they can be virtually mounted without the need to burn the image to disc. Some Linux systems have this capability built in. For Windows, you can download some freebie software (or pay for it). A couple of free options are: DAEMON Tools Lite -  http://www.daemon-tools.cc/eng/products/dtLite SlySoft Virtual Clone Drive -  http://www.slysoft.com/en/virtual-clonedrive.html Once this software is downloaded and installed, the ISO image can be selected and "mounted" virtually, which will run the image as though i

.NET Content Management Systems

This is really just a reference of .NET Content Management Systems (CMS) to work through and evaluate for various projects. Of course client requirements need to be factored in, such as ease of use for the client as ultimately they will be the end user, along with development, customisation, both skinning and dev-wise, and how well supported the system is and the size of the community around it. There are loads out there but until a CMS reaches a certain critical mass, it's always a little bit uneasy using a less well tried and tested one for commercial and production purposes, or one that does not have a large user and dev community behind it. If you know anymore or want to mention one, feel free to add a comment. Ta very much. DotNetNuke -  http://www.dotnetnuke.com/ Umbraco -  http://umbraco.org/ Kentico -  http://www.kentico.com mojoPortal -  http://www.mojoportal.com/ Orchard Project -  http://www.orchardproject.net/ Non ASP.NET CMS Joomla -  http://www.joomla

Weebly - Online Content Management System

A recent project needed to get on-line quickly, easily, cheaply and with minimal effort. The site had to be able to be administered easily by non-tech types and also contain a few features such as a blog, contact forms, the ability to include custom HTML for Twitter feeds, PayPal, sharing links, etc., etc. http://www.weebly.com A number of options would fit these parameters, and obviously a content management system of some sort would be ideal. Installing, configuring, finding and paying for a host can be troublesome at times, which led me to Weebly - an on-line Content Management System with free hosting, no set up fees or issues, feature rich and easy user interface. You can pay for a pro version which gives the usual obvious benefits of own domain (instead of subdomain of Weebly), better stats (but you can just plug in your own Google Analytics code), a couple more features to include on your website, removal of the Weebly link in the footer .... anyway, you get the idea.

API Arrived for Goo.gl, Google's URL Shortener

After some waiting around since goo.gl went live and became available to the general public in September 2010, the API has finally been released this week. Documentation can be found at http://code.google.com/apis/urlshortener/overview.html and a "Getting Started" guide can be found at http://code.google.com/apis/urlshortener/v1/getting_started.html There has been eager anticipation waiting for the release of the API and this should be pretty cool for allowing developers to use Google's URL Shortener in their own applications and projects. Thanks to Google and the URL Shortener Team for releasing this. Blog post announcing release:  http://googlecode.blogspot.com/2011/01/google-url-shortener-gets-api.html

SQL Server - Function to Convert String to Proper Case

Below is just a quick and simple function to convert a short string to proper case. It's not the most efficient but will do its job for short strings. The first character of the string is converted to upper case, subsequent characters that are preceded by a space are converted to upper case. e.g. "this IS A TEST sentence. followed BY ANOTHER." will be changed to "This Is A Test Sentence. Followed By Another." Function: CREATE FUNCTION [dbo].[fncProperCase](@string VarChar(1000)) RETURNS VarChar(1000) AS BEGIN DECLARE @pos int DECLARE @len int DECLARE @char VarChar(1) DECLARE @temp VarChar(1000) SET @string = LOWER(LTRIM(RTRIM(@string))) SET @temp = '' SET @pos = 1 SET @len = LEN(@string) WHILE @pos <= @len BEGIN SET @char = SUBSTRING(@string, @pos, 1) IF @pos = 1 BEGIN SET @temp = @temp + UPPER(@char) END ELSE BEGIN IF SUBSTRING(@string, @pos - 1, 1) = ' ' BEGIN SET

SQL Server - Remove Non-Alphanumeric Characters from String

The following SQL function will remove and strip all non-alphanumeric characters from a string. CREATE FUNCTION [dbo].[fncRemoveNonAlphanumericChars](@Temp VarChar(1000)) RETURNS VarChar(1000) AS BEGIN WHILE PatIndex('%[^A-Za-z0-9]%', @Temp) > 0 SET @Temp = Stuff(@Temp, PatIndex('%[^A-Za-z0-9]%', @Temp), 1, '') RETURN @TEmp END Example: SELECT dbo.fncRemoveNonAlphanumericChars('abc...DEF,,,GHI(((123)))456jklmn') Result: abcDEFGHI123456jklmn

Riskiest OS: Mac OS X. Most Dangerous Website: Google.

Not really as alarming as the post title suggests but a post from Trend Micro's blog highlights a few surprising and a few unsurprising dangers on the internet from 2010. Trend Micro's blog:  http://blog.trendmicro.com/ Original post:  http://blog.trendmicro.com/2010s-most-dangerous-list/ In summary: Riskiest hardware: German ID card readers Riskiest website software: Wordpress Most dangerous IP:  Internet Relay Chat (IRC) Riskiest OS:  Apple’s Mac OS X Most dangerous website: Google Most dangerous social network: Facebook Most dangerous top level domain: CO.CC Riskiest file format: PDF More details are given in the original post from Trend Micro.