Posted by admin on Oct 4, 2010 in code
Visual Studio 2005
Yesterday I brought into work an application that I had developed at home. The application was written in VB.Net using Visual Studio 2008.
My work Development environment is Visual Studio 2005 and I needed to update the source code so I tried to load up the solution file and I received the error “The Selected file cannot be opened as a solution or project. Please select a solution file or project file “.
I know from past experience that .sln (solution) files are just text files with references to other code and the development environment.
So if you ever receive the above message and your moving code from Visual Studio 2008 to 2005 then load the sln file in a decent text editor (Notepad ++ will do)
change the top to lines from
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
save the solution file and now open it in your 2005 development environment.
You may have to refactor some code if you have used new objects or syntax which are new to 2008.
However you should be able to to just code as normal.
Posted by admin on Jul 5, 2010 in code
Visual Studio Webtest Logo
I use Visual Studio Team Testers Edition everyday at work and one of the things that seemed really strange to me was that Microsoft had missed so many tricks when they decided to release it.
Maybe they just decided to build in reasons for users to upgrade, knowing that there will always be another version of VSTS around the corner.
One of the things which is sorely missing is the ability to verify HTML source code against a datasource. Sure you can load a data source and then verify what is returned on the page when that row of the data-source is called however there is no functionality to check that the value of the row that you have submitted is returned somewhere in the HTML source (known as the response in VSTS).
So as per usual when you need something doing then, do it yourself, and hence I wrote a small piece of code that looks at the source code and then checks the value of the datasource row to make sure that the item you are submitting is returned in the HTML response.
All the data is dynamic from your source so you can’t just hard code validation rules, as there could be thousands of rows.
For an example take a Google search test. Imagine I want to check that my datasource of 10,000 records is retuned on every response.
So if I search for “System Testers” as a parameter value
“Parameter Name = q” and
“Parameter Value = Google DataSource.Directory_03062010#csv.SearchParams”
In the above QueryString Parameter you can see
the Datasource is called “Google DataSource”
the Actual FileName is “Directory_03062010″ (and it’s a CSV file)
the Column name is SearchParams
I’ve commented my code to make it easier to understand however if you need any help just ask.
‘Author = Martin Hall
‘Purpose = To load text from a DataSource and then to compare that text
‘ against the source code on the page your testing.
‘Date = 07th June 2010
Public Class RegressionAllHeadingLocationsRule
‘ Specify a name for use in the user interface.
‘ The user sees this name in the Add Validation dialog box.
Public Overrides ReadOnly Property RuleName() As String
‘ Specify a description for use in the user interface.
‘ The user sees this description in the Add Validation dialog box.
Public Overrides ReadOnly Property RuleDescription() As String
Return “This should Compare text from a datasource parameter in a CSV file against the page sourcecode.”
‘ The name of the expected string
Private ExpectedStringValue As String
Public Property ExpectedString() As String
Set(ByVal value As String)
ExpectedStringValue = value
‘ Validate is called with the test case Context and the request context.
‘ These allow the rule to examine both the request and the response.
Public Overrides Sub Validate(ByVal sender As Object, ByVal e As ValidationEventArgs)
Dim result2 As String
‘we only want request2 to match the source code on the returned web page.
‘the SourceCode could be different on the other pages.
result2 = (e.WebTest.Context(“Google DataSource.Directory_03062010#csv.SearchParams”).ToString())
‘This should check the response for text
‘The text in question is the ParamValue we are supplying as new fake
‘parameter name and value
If e.Response.BodyString.ToLower.Contains(result2) = False Then
e.IsValid = False
e.Message = (“fail – - “) & result2
If e.Response.BodyString.ToLower.Contains(result2) Then
e.IsValid = True
e.Message = (“pass – - “) & result2
Catch ex As Exception
The above script is in Visual Basic.Net and it should work for you and if you need any help in how to install and run it then either send an email or reply in the comments.
One last thing to mention is that the values from the data source are loaded in a fake Parameter Name (Just make one up) which will be ignored by the Website however it will show as a Context Name in the Visual Studio Web Test, so we are really just comparing two Context Names