nunit

TDD with filesystem dependencies

Hello. I have an integration test LoadFile_DataLoaded_Succefully(). And I want to refactor it to the unit test for breaking dependency with filesytem. P.S. I am new in TDD: Here are my production class : public class LocalizationData { private bool IsValidFileName(string fileName) { if (fileName.ToLower().EndsWith("...

MbUnit vs Nunit

I read that MbUnit is Nunit on steroids, but I don't see why. From what I have read on here, I here that Nunit is more popular over MbUnit. One of the main reasons is because it has a fluent interface. Is this the only reason? Why should I prefer MbUnit over Nunit, or vice-versa? Thanks! ...

Returning specific UserHostAddress using TestControllerBuilder

I am using MvcContrib and the TestControllerBuilder to write tests for my controller. I am writing the tests for my Error Handling Controller that looks like this: public JsonResult HttpError() { Exception ex = null; try { ex = (Exception)HttpContext.Application[Request.UserHostAddress.ToStr...

how to represent a list of U.S. States

Trying to do TDD against FluentValidation and Looking for the proper way to represent a list of US States. For example, I have an "Address" object. I would like to write a test (and a FluentValidation rule) that declares the address invalid if it's not in a list of US States. This is a finite list, only to include the 50 US States, ...

How to test a NUnit helper?

I'm build a library inspired by RSpec on top of NUnit 2.5+ in order to improve my tests readability. The source code is available at http://github.com/educobuci/SpecUnit. This library allows me to write tests like this: [Test] public void It_should_returns_0_for_all_gutter_game() { var game = new Bowling(); for (int i = 0; i < ...

NUnit tests are executed slower by MSBuild than by NAnt

I am in the process of porting a NAnt build script to MSBuild 4.0 and I am seeing a rather interesting behaviour. MSBuild is slightly faster when executing filesystem and compilation tasks, but takes twice as long to run NUnit tests. Here's some background info: I am using nant-0.91-alpha2 and MSBuild 4.0 I am using NUnit v2.5.7 NAn...

Writing Logs/results or generating reports using Selenuim C# API

Hi All, I am testing the web application using Selenium RC. All things works fine and I have written many test cases and executing these test cases using Nunit. Now the hurdle that i am facing is how to keep track of failures or how to generate the Reports ? Please advice which could be best way to capture this. Thanks in Advance...

nunit debugs in 64-bit, application is in 32-bit

I'm one of those people who love the Edit and Continue in VS. Because of that I develop apps in 32-bit. But when I run a unit test in debug mode and I try to edit a line, I get the usual "Changes to 64-bit applications are not allowed." message. All my components are marked x86, nunit is installed as a 32-bit application. My system is 64...

MbUnit's row attribute in NUnit?

While reading an Asp.Net MVC code sample that used MbUnit as it's testing framework, I saw that it was possible to run a single test against multiple input possibilities by using a Row attribute, like so: [Test] [Row("test@test_test.com")] [Row("sdfdf dsfsdf")] [Row("[email protected]")] public void Invalid_Emails_Should_Return_False(string in...

Unity Nunit & Rhino Mocks

Hi, could anyone give me a good example of using rhino mocks, nunit, and unity together. I am reading the help on each but there doesnt seem to be any good sample projects of how you would use them together and the way to set up projects /test projects using them. I.e. do you create new ioc containers in your test project which point t...

Preventing catch of NUnit AssertionException?

I'm working on a project at the moment where I need to inter-operate with code that swallows exceptions. In particular, I'm writing NUnit unit tests. There are some places where I want to embed assertions within code that gets passed as a delegate, as part of mocking a particular behavior. The problem I'm having is that the AssertionE...

How to give a presentation on unit testing with nunit?

If you had to give an overview on unit testing with some practical examples to other colleagues and you yourself weren't up to speed on unit testing, how would you approach that? Examples would be shown in nunit, but I guess it could be any unit testing framework. ...

Visual Studio 2010 Unit Test not showing in Dropdown menu

I installed NUnit to show up in the Test Framework dropdown menu in Visual Studio 2010. The setup went good and NUnit now shows up in the Test Framework dropdown menu for my ASP.NET MVC2 projects. My problem is the Visual Studio Test has disappeared from the Test Framework dropdown menu. I ran a repair on Visual Studio but that did not r...

Null Object Reference

Using Nunit to test C# code with the following code block: foreach (XmlNode node in nodeList) { thisReport.Id = node.Attributes.GetNamedItem("id").Value; thisReport.Name = node.Attributes.GetNamedItem("name").Value; thisReport.Desc = node.Attributes.GetNamedItem("desc").Value; if (node.SelectNodes("subreport").Count > 0...

How should I test an MVC web app in a container with nunit?

We have an MVC web which is running in Autofac. All the config is stored in an autofac config section in the web.config and when run the Global asax sets up the container and sorts out all the modules by providing them with their config settings - the one I'm interested in at the moment is the NHibernate module - so this gets the connec...

testdriven.net log4net console output

How do I get log4net console output to show up when using TestDriven.net to run nunit tests? I'm using the ColoredConsoleAppender, and there is no log output. ...

nUnit - ignore GAC copy of a DLL

I am using a nUnit to, well, unit test an assembly. The assembly is in my project output dir (\bin\debug) and is loaded into nUnit (Assemblies > Add Assembly) from this location. However an older version is also in the GAC and nUnit is picking this one up instead. I can of course remove the old version and re-install to the GAC upon b...

Nunit suite is not getting called while run

Hi, I am trying to create a framework which calls many test to run.So thought of implementing Suite attribute provided by Nunit framework.This is my code. Main.cs: using System; using System.Diagnostics; using System.Text; using NUnit.Framework; using Selenium; using System.IO; using NUnit.Core; namespace SeleniumTests { [TestFixtu...

Displaying results of an NUnit run, CruiseControl.Net 1.5.7256.1

We recently upgraded CruiseControl.Net 1.4.2 to 1.5.7256.1. To our dismay the nice nunit results page that had previously been there had disappeared. All we get now is a build log with the verbose output from command line of our build. After some research we discovered you can log into "Dashboard Administrator" from the main ccnet dashb...

How do I unit test protected properties meant to be set only by NHibernate?

I'm using NHibernate to persist this entity: public class Store { public int Id { get; protected set; } public int Name { get; set; } } Note how the Id property has a protected setter. This is to prevent users from changing the Id while still allowing NHibernate to assign it an Id when it saves it to the database. In one of m...