nunit

Unit Test to Run .sql script to SQL Create Database

Can anyone point me in the direction of how I could get a NUnit test to run a .sql file to Create / Setup a database. I know about the the TestFixtureSetUp and TestFixtureTearDown attributes / methods in NUnit. So I KNOW how to call methods before and after all or each unit tests. I'm just unsure of how to load and execute the conten...

Dump iBatis sql in Nunit?

I saw nHibernate video during the weekend. In the tutorial, the programmer was using MBunit to test his code. One neat thing i liked about nhibernate was, if you tell nhibernate to 'showSql', it displays sql in Mbunit dialog box after the unit test. I was wondering if there is something similar for ibatis using nUnit? ...

How to test if raising an event results in a method being called conditional on value of parameters

I'm trying to write a unit test that will raise an event on a mock object which my test class is bound to. What I'm keen to test though is that when my test class gets its eventhandler called, it should only call a method on certain values of the eventhandler's parameters. My test seems to pass even if I comment the code that calls Pro...

Unit Testing rich Views for ASP.NET MVC

If I have a rich AJAX-driven GUI in ASP.NET MVC, how would I unit test that effectively using a framework like NUnit? ...

Use MSpec with MBUnit?

Hi, Does anyone know if it's possible to use MSpec with MBUnit instead of NUnit? Gallio seems to ignore all my tests when using MSpec? ...

Why Moq is throwing "expected Invocation on the mock at least once". Where as it is being set once,even though it is being set to null?

Following is the code. create a class lib add the ref to NUnit framework 2.5.3.9345 and Moq.dll 4.0.0.0 and paste the following code. Try running it on my machine it throws TestCase 'MoqTest.TryClassTest.IsMessageNotNull' failed: Moq.MockException : Expected invocation on the mock at least once, but was never performed: v =...

Stepping through ASP.NET MVC in Action (2009) - and stuck on nunit issue

I seem to have missed something - in this step through it talks through downloading nunit and changing the original MSTest reference to NUnit. Which seems fine until it talks about running the test with UnitRun from JetBrains. I would have thought I could run nUnit to be able to run the test - but I load my project in the nUnit gui and...

Problem using System.Xml in unit test in MonoDevelop (MonoTouch)

When I have a unit test that requires the System.Xml or System.Xml.Linq namespaces, I get the following error when I run the test: System.IO.FileNotFoundException : Could not load file or assembly 'System.Xml.Linq, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Things I've v...

Method parameters have incorrect values when using RowTest in VB.Net

Hello, I have the following test method (VB.NET) <RowTest()> _ <Row(1, 2, 3)> _ Public Sub AddMultipleNumbers(ByVal number1 As Integer, ByVal number2 As Integer, ByVal result As Integer) Dim dvbc As VbClass = New VbClass() Dim actual As Integer = dvbc.Add(number1, number2) Assert.That(actual, [Is].SameAs(result)) End Sub...

Is mspec better with or without nunit?

I've seen mspec used with nunit on some blogs and discussions. In fact, most of the examples on the web that I've seen demonstrate mspec with some kind of nunit dependancy or integration. My team is attempting to use mspec without nunit on a new ASP.NET MVC2 project. We're not at the spec-writing stage yet, so I can't tell what is better...

Books or Articles on Using NUnit to Test Entire Features

Are there any books or articles that show you how to use NUnit to test entire features of a program? Is there a name for this type of testing? This is different from the typical use of NUnit for unit testing where you test individual classes. This is similar to acceptance testing except that it is written by the developer to discern tha...

Registering NUnit DynamicMock Instances in a UnityContainer

I'm somewhat new to Unity and dependency injection. I'm trying to write a unit test that goes something like this: [Test] public void Test() { UnityContainer container = new UnityContainer(); DynamicMock myMock = new DynamicMock(typeof(IMyInterface)); container.RegisterInstance(typeof(IMyInterface), myMock.MockInstance); //...

Good tools which generate NUnit unit tests for .NET assemblies in Visual Studio 2008

Hey guys, I'm pretty new to Unit Testing so bear with me. I realize that best best practice is not to auto generate unit tests, however I'd like to use Code Generation to set-up the basic skeleton of the tests. Now, I know Visual Studio 2008 already has the built in "create tests", however, it just creates a flat list of all the classe...

NUnit fail with System.ArgumentException: The net-4.0 framework is not available

Exception: ProcessModel: Default DomainUsage: Single Execution Runtime: net-4.0 Unhandled Exception: System.ArgumentException: The net-4.0 framework is not available Parameter name: framework at NUnit.Util.TestAgency.GetAgent(RuntimeFramework framework, Int32 waitTime, Boolean enableDebug) at NUnit.Util.ProcessRunner.Load(TestPa...

Why in the world is this Moq + NUnit test failing?

I have this dataAccess mock object and I'm trying to verify that one of its methods is being invoked, and that the argument passed into this method fulfills certain constraints. As best I can tell, this method is indeed being invoked, and with the constraints fulfilled. This line of the test throws a MockException: data.Verify(d => d....

NUnit-console 2.5.4 not capable of running multiple assemblies?

I am having problems running tests with the command line NUnit test runner. I am using version 2.5.4 with .NET 4 on an x64 machine. Using the following line results in a failure "Could not load file or assembly 'bar' or one of its dependencies. The system cannot find the file specified." nunit-console-x86 foo.dll bar.dll /framework=4....

bool as object vs string as object testing equality

I am relatively new to C# and I noticed something interesting today that I guess I have never noticed or perhaps I am missing something. Here is an NUnit test to give an example: object boolean1 = false; object booloan2 = false; Assert.That(boolean1 == booloan2); This unit test fails, but this one passes: object string1 = "string"; o...

NUnit.Framework.Assert.IsInstanceOfType() is obsolete

I'm currently reading the book Professional Enterprise .NET and I've noticed this warning in some of the example programs: 'NUnit.Framework.Assert.IsInstanceOfType(System.Type, object)' is obsolete Now I may have already answered my own question but, to fix this warning is it simply a case of replacing Assert.IsInstanceOfType() with A...

Why does trying to unit test with two .NET 4.0 assemblies under NUnit 2.5.4 fail?

I have an MSBuild script that uses NUnit to run tests in two assemblies. These were on .NET Framework 3.5 and it worked perfectly for a long time. The command line was: (actual paths & names simplified) nunit-console tests1\bin\debug\tests1.dll tests2\bin\debug\tests2.dll I've upgraded to VS2010 and have now made the two test assembl...

Can I configure NUnit so that Debug.Fail doesn't show a message box when I run my tests?

I have this property: public SubjectStatus Status { get { return status; } set { if (Enum.IsDefined(typeof(SubjectStatus), value)) { status = value; } else { Debug.Fail("Error setting Subject.Status", "There is no ...