I have a class which for now should always have a certain member populated before it is valid. To enforce this, the class has no default constructor and instead has a constructor which accepts a value for that required member. The setup is similar to this below:
public class MyClass
{
public string Owner { get; protected set; }
pub...
I'm having a problem when a project is committed to SVN, which in turn is automatically picked up by our newly set-up CruiseControl.NET server, the UnitTests are failing.
The unit tests are written in the default Visual Studio Unit test framework - which is the problem. I spot that nUnit appears to be recommended as a good alternative. ...
Is there a framework to write unit test for Data Access layer? There are several issues in this.
1. How to populate your database?
2. How do we make sure that one test is not modifying values in db that can fail another test?
Is there a good framework available which can take care of above issues?
Update: I came across nDBUnit which ...
Hi,
I have an issue with NUnit - wondering if anyone has any ideas.
We're using NUnit 2.5.3.9345 and C# 3.5.
Take the following code:
public class UnitTestBase
{
[TestFixtureSetUp]
public void SetUpTestFixture()
{
//Do something in base
}
}
[TestFixture]
public class SomeTestClass : UnitTestBase
{
[TestFi...
I am working a project with many NUnit tests, that were already written long time ago. What is the best way to run Pex on these tests and extend them? I try to run Pex on the methods that are being tested, but Pex wants to create new projects and new tests, and doesn't pick up the old ones.
...
I'm trying to set up blade unit tests in an MVC Turbine-derived site. The problem is that I can't seem to mock the IServiceLocator interface without hitting the following exception:
System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at System.Reflection.E...
If I start my unit tests from TestDriven.NET under VS2008, they run pretty much immediately.
If I start my unit tests using nunit-console.exe, the NUnit console hangs for five minutes before actually running my tests. If I attach a debugger, it seems to be spending its time in System.IO.MemoryStream.Read, called from System.Runtime.Ser...
In testing singleton classes we need the single instance to "go away" after each test. Is there a way to configure nunit to recreate the test app domain after each test, or at least after each fixture?
...
I'm using NUnit to write unit tests for a libary a colleague of mine has written. His library contains a lot of Debug.Asserts which triggers on invalid input. When I'm writing the unit tests and give invalid input to his library, his Debug.Assert throws up a message box complaining about the bad input.
I feel that it's a good thing that...
In both my NUnit SetUp and TearDown methods, I need to retrieve the MethodInfo of the test that is about to be run or has been run. Is this possible? I'm using NUnit 2.5.
Motivation: I would like to be able to retrieve, via Reflection, attributes attached to the test method.
...
I have a method named RenderContent which returns object[]
In my unit test, I need to assert that this array does not contain any objects of type VerifyRequest
At the moment, I'm using the following Assert statement. Is there anything more concise?
Assert.That(
domain.RenderContent().OfType<VerifyRequest>().Count(),
Is.EqualT...
Is there any way to pass generic types using a TestCase to a test in NUnit?
This is what I would like to do but the syntax is not correct...
[Test]
[TestCase<IMyInterface, MyConcreteClass>]
public void MyMethod_GenericCall_MakesGenericCall<TInterface, TConcreteClass>()
{
// Arrange
// Act
var response = MyClassUnderTest.My...
NUnit supports a feature where you can specify a set of data inputs for a unit test to be run multiple times.
[RowTest]
[Row(1001,1,2,3)]
[Row(1,1001,2,3)]
[Row(1,2,1001,3)]
public void SumTests(int x, int y, int z, int expected)
{
...
}
What's the best way to accomplish this same type of thing using MSTest? I can't find a similar...
I realise that there are many older questions addressing the general question of NUnit v MSTest for versions of Visual Studio up to 2008 (such as this one).
Microsoft have a history of getting things right in their 3rd version. For MSTest, that is VS2010.
Have they done so with MSTest? Would you use it in a new project in preference to...
I am new to unit testing and I wanted to give NUnit a try.
In an ASP.NET Web Project, I can create a new project in my web project solution for unit testing and add a reference to my original project and in NUnit I can load the dll file for my unit testing project to run the tests.
However, i am developing an ASP.NET Website and becaus...
There are a ton of questions here on SO regarding NUnit vs. MSTest, and I have read quite a few of them. I think my question here is slightly different enough to post separately.
When I started to use C#, I never even considered looking at MSTest because I was so used to not having it available when I was using C++ previously. I basic...
I'm still figuring out a few of the finer points around unit testing my ASP.Net MVC2 application using NUnit.
On the whole, testing my ActionResults, models, respositories and the like is straight-forward, but I've not had to test Ajax methods before and I'd like some guidance on how I should best go about it.
Thanks in advance.
...
Why in NUnit when i write :
Assert.AreEqual(ConfigurationManager.ConnectionStrings["FertigungRead"].ConnectionString , "Data Source=server511;Initial Catalog=FERTIGUNG;Persist Security Info=True");
it does not run the test and raises an error : Object reference not set to an instance of an object.
But ConfigurationManager is static c...
Hi,
Does NUnit have an Assert method that returns a bool? They all return void. I am using version 2.5.3
Thanks
...
(Sorry for the unclear title, please edit it if you can come up with a better one)
I wish to run the same tests over two different data stores, I can create the data stores in the Setup() method.
So should I have a super class that contains all the tests and an abstract SetUp() method, then have a subclass for each data store?
Or is t...