My unit tests are doing something very strange when I call a method of a generic base type. I have tried both NUnit and MSTest with the same result. This is how the code is organized:
public class MyStub {}
public class EnumerableGenerator
{
public bool GotMyStubs;
public IEnumerable<MyStub> GetMyStubs()
{
GotM...
Hi,
I'm trying to get Figure 3 Fake Database from IRepository using the example here
http://msdn.microsoft.com/en-us/magazine/dd263069.aspx
public class InMemoryRepository : IRepository
{
private readonly Cache<Type, object> _types;
private MockUnitOfWork _lastUnitOfWork;
public InMemoryRepository()
{
_types = n...
I am looking for ways of making the following more concise.
public class MyTests
{
IPresenter presenter;
[SetUp]
public void SetUp()
{
presenter = MockRepository.GenerateStub<IPresenter>();
}
...
}
In particular specifying the type again when creating the mock seems redundant. For example I can write...
Given two dictionaries
var dictA = new Dictionary<string, classA>();
var dictB = new Dictionary<string, classA>();
How to check whether these two dictionaries are the same? The catch here is that I can't use the default classA.Equals for comparing the value pairs. Instead, the test will pass when and only when given that all the objec...
I'd like to run some NUnit unit tests against a class in a .Net class library assembly which is designed to be hosted by an external process (outside of my control) and loaded at runtime.
The class I want to test derives from a class defined within the host exe that requires it to be instantiated within the host process. Any attempt to...
I'm reading Pro ASP.NET MVC Framework book. In an example on 106 - 111 the author walks through creating an NUnit test for a HTMLHelper class.
I noticed that when I ran my HTMLHelper code in NUnit the links appeared like this:
<a href="Page1">1</a>
<a class="selected" href="Page2">2</a>
<a href="Page3">3</a>
But when I see them in t...
Hello,
I'm diving into unit testing and I would like to know if it is possible to test some special functionality of a dialog or a form with NUnit. I have tried NUnitForms, but it lacks good documentation and seems that nobody is mantaining that project. Is it true?
If you have any experience testing Windows Forms, please point me in ...
I'm using Cruise Control.NET and NAnt to automatically run NUnit tests on our code base. Some tests cause Windows forms to be shown. When these tests are run manually from VS or NUnit GUI, they work fine. When run via the Cruise Control service, I get the following exception:
System.InvalidOperationException : Showing a modal dialog ...
I need to use some WPF components in an NUnit unit test. I run the test through ReSharper, and it fails with the following error when using the WPF object:
System.InvalidOperationException:
The calling thread must be STA, because many UI components require this.
I've read about this problem, and it sounds like the thread ne...
I have a few projects:
A database interface project that defines Thingo (main solution)
A logic project that defines ThingoChooser (plugin solution)
A GUI project that refers to the logic project (plugin solution
A test project that refers to the logic project (plugin solution)
I'm debugging the plugin, so I run the main solution wit...
I'm looking at NUnit XML output right now, and wonder if it's possible to generate the output for failures only.
I mean, if a test passes ok, no XML output gets generated for it at all.
(UPDATE: XSLT is not an option here. I don't want XML output for passed tests at all: if I don't need the details about the passed tests, I don't wan...
I'm wondering what the best way to do this is... I'm interested in introducing PostSharp into one of my projects, but I'm not sure how to unit test classes marked with an attribute properly.
For example:
public class hello {
[MyAspectThatDoesSomethingToTheDatabaseWhenThisMethodGetsCalled]
public int omg(string lol) {
/...
I've been working on an application that uses xVal's server side validation with data annotations. We recently ran into errors where the validation messages have been unpredictable for fields that have multiple validations that could fail if the field is empty (e.g., an email address is required, but also fails a validity check).
Assum...
I am writing a C# unit test to test C++/CLI functionality that involves threads.
The C++/CLI code implements a DirectShow filter, the Windows API for rendering movies. This works thus that I create DirectShow objects, I tell it to run an AVI through my C++/CLI filters, waits until rendering is done, and then exits. My filter has a call...
Is there a way to request elevated privileges from the os, for "just a part" of a c# program?
I'm writing a bunch of integrationtests using NUnit. One of the things I'm testing is if the application under test correctly connects to port 843. The test opens a listening socket at port 843, and then throws all sorts of responses to the app...
Their website has been down for a couple months now (link text), and their last release is September of last year. (according to SourceForge)
Did they croak?
I know that one of the guys went on to found xUnit (link text).. The xUnit site seems to be well maintained.
...
I have an object that gets passed into a method as a parameter. This object has a event on it which should get subscribed to when I call this method with the object as the argument.
Does NUnit allow me to check this?
Edit: Added a code sample:
[Test]
public void AddingToCollectionShouldHookPropertyChangedEventUp()
{
...
Hi,
I'm using the NUnit 2.5.3 TestCaseSource attribute and creating a factory to generate my tests. Something like this:
[Test, TestCaseSource(typeof(TestCaseFactories), "VariableString")]
public void Does_Pass_Standard_Description_Tests(string text)
{
Item obj = new Item();
obj.Description = text;
}
My source is this:
publi...
I am trying to run a simple test on a controller in MVC. This controller validates the input using xVal and DataAnnotations. When I run the test (using NUnit via Resharper, NUnit standalone or TestDriven.Net) it crashes the runner with no decent error message. In the event logs it just has a fairly generic .NET Runtime 2.0 Error Repor...
I am interested in improving my testing methodologies but am not sure if I prefer NUnit or VS 2008 test. I also have a book that uses NUnit in it's examples. Do the two frameworks coexist well with each other?
...