.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

Installing SP1 caused unit tests to fail (checking for classes derived from UserControl)

Posted By:      Posted Date: October 28, 2010    Points: 0   Category :.NET Framework

I have unit tests that check to see if a certain class is derived from a given abstract class. Once I installed Visual Studio 2008 SP1 and KB971092, these unit tests start failing.

However, the odd part is, they only fail when I am checking for a class that is derived from an abstract user control.  So if I use the algorithm to see if Class1 is derived from AbstractClass1, the unit test passes.  If I check to see if View1 is derived from AbstractView1 : UserControl, the unit test fails.  The actual line of code the unit test is failing on is



The code around the failing line is


 // Try to load the assembly
Assembly ____ = Assembly.LoadFrom(assemPath);
// Now that the assembly is loaded get all the types
Type[] types = ____.GetTypes();
// Loop through all the types only returning nonabstract classes
// That are subclasses of the given class
foreach (Type type in types)
  if ((type.IsSubclassOf(subClass)) && (type.IsInterface == false

View Complete Post

More Related Resource Links

Generation Test: Automated Unit Tests for Legacy Code with Pex


Creating and maintaining a unit test suite for legacy code can be a challenge. Pex automatically produces a small test suite with high code and assertion coverage.

Nikhil Sachdeva

MSDN Magazine December 2009

Bugslayer: Strengthening Visual Studio Unit Tests


Visual Studio 2005 brought so many new features to the table that it can seem almost overwhelming. One of the most exciting additions is the new unit testing features found in the Test menu on the main menu bar.

John Robbins

MSDN Magazine March 2006

Unit Testing Tips: Write Maintainable Unit Tests That Will Save You Time And Tears


Everybody's talking about unit testing and you want to get into the game too. But you don't want the tests to take up all your development time and energy. Fortunately Roy Osherove is here to dispel some testing myths and put you on the road to efficient unit testing.

Roy Osherove

MSDN Magazine January 2006

Installing .NET Framework 3.5 without checking certificates - Registry Key ?

Hallo, could you tell me, how to install .NET Framework 3.5 without checking certificates? For each check there should be access to the internet. But during installation I don't have access to the internet. We want to install automatically and in a very quick manner! EAMuecke  

enabling ASP.NET MVC2 unit tests in VWD

As stated in http://forums.asp.net/t/1535916.aspx the unit tests are missing from the ASP.NET MVC 2 RTM source code, but are available on CodePlex at http://aspnet.codeplex.com/releases/view/41742).   After installing ASP.NET MVC2 RTM on Visual Web Developer 2008 Express, apparently unit tests are not enabled for VWD - when I create a new MVC2 project I don't get the "Create Unit Test Project" dialog box where I can say"Yes, create a unit test project". (I thought I was presented with that dialog box in earlier versions of either MVC2 RC or MVC1, but maybe not...) Given the source code on codeplex, is it possible to use that to enable unit tests for MVC2 for VWD Express?  If so, are the steps one have to take detailed somewhere?

Unit testing CodeFirst classes


is there some property where I can tell Code First to work against a static in memory lists ?

I am thinking on creating some generic class to work against code first like in the ASP.NET MVC Unleashed book and I was wondering if maybe there is simple way or something which is already made instead of me creating all the generic fakes ?

+ if i use Code First , should I still create a repository to work against this domain model ?

Unit tests for Action which uses RedirectToAction


I have Action method in a controller which uses RedirectToAction(actionName, routeValues[]) 

I want to write the unit test for action method to check the following - 

1. action name

2. ViewData after executing the RedirectToAction.

Someone know how to mock it , please help.

'File not found' in unit tests problem



I have a unit test that reads from an .xml file and it works fine on my local machine.

However, in TFS when I create a new build it gives the following exception:

Failed    GetArticleByIdTestOptimal        Test method Test.ArticleSystemTest.GetArticleByIdTestOptimal threw exception:  System.Xml.XmlException: ImportFromFile filePath=[.\Articles1to5.xml]. --->  System.IO.FileNotFoundException: Could not find file 'c:\buildarea\TestResults\tfservice 2010-10-19 11_52_19_Any CPU_Release\Out\Articles1to5.xml'..  

Is there some reason why a unit test could pass locally but not in TFS? I've verified that the file is on the build server.

Public properties of collection derived classes are not deserialized in REST wcf service


I have Restful wcf service that returns the following class, but the Total and Count fields become 0 when it reaches the client side. But they have the correct values on the server side.

 public class Groups : List<Group>
private int total;
private int start;

/// <summary>
/// Total number of Groups in the result set irrespective of the paging
/// </summary>

How can I speed up unit tests which use reflection in Visual Studio 2010?


Hi there,

I was thinking about using reflection for unit tests where 2 objects will be compared for equality and GetProperty() and GetFields() methods will be used extensively. However, I know that the performance impact will be very significant. In fact, couple of my coworkers used reflection for a deep copy of some sourceobject to targetobject. The code is absolutely elegant, beautiful and does exactly what it's supposed to do. The problem is they had to scrap it because it was really slow. So, is all lost when it comes to using reflection in unit tests or is there a way to implement it without a ridiculous performance hit? Thanks a lot in advance.

Fail to access Sql Management Studio after installing visual studio 2010



After installing visual studio 2010 , a tried to open my Sql management studio and i can't access it (not with user authentication nor with Microsoft authentication). How can i solve this problem?

Thank you.

The error is :

This version of Microsoft SQL Server Management Studio Express can only be used to connect to SQL Server 2000 and SQL Server 2005 Servers.

Installing and Uninstalling Services

Installing and Uninstalling Services.Unlike most projects you create in Visual Studio .NET, Windows Service projects cannot be run directly from the development environment by pressing F5. This is because the service in the project must be installed before the project can run.

You can quickly install your service application by using a command line utility called InstallUtil.exe.

Unit Testing SharePoint - Past, Present, and Sporm

As I described in SharePoint: The Wild West of Software Development there is a serious problem when you develop for SharePoint: ensuring quality through unit testing is really, really hard. And that's where a new open source tool just released today called sporm (SharePoint Object Relational Mapper) comes in. While sporm provides many benefits besides simplified unit testing I wanted to focus on this topic first, because sporm's approach, which models the entity framework in the way it supports POCO's, is a unique feature not available with other SharePoint tools like LINQ to SharePoint.

Learning C# and OOP, Classes

This is the second lesson in a miniseries designed to teach you how to write object-oriented programs using C#. This miniseries will describe and discuss the necessary and significant aspects of object-oriented programming (OOP) using C#.

Performance Tests: Precise Run Time Measurements with System.Diagnostics.Stopwatch

Everybody who does performance optimization stumbles sooner or later over the Stopwatch class in the System.Diagnostics namespace. And everybody has noticed that the measurements of the same function on the same computer can differ 25% -30% in run time. This article shows how single threaded test programs must be designed to get an accuracy of 0.1% - 0.2% out of the Stopwatch class. With this accuracy, algorithms can be tested and compared.

Installing and configuring SharePoint 2010

The following steps show how to install SharePoint 2010 on VMware workstation 7.0. Host computer used during the preparation of this walk-through was a Vista (32-bit) machine and guest machine used was VMware workstation 7.0 with Windows Server 2008 Service Pack 2 (64-bit).
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend