nunit

NUnit+Moq Throwing Exception

The code under test follows. view.QueryResultsGrid is a System.Windows.Forms.DataGridView object: public void SelectCheckedChanged(object sender, EventArgs e) { view.QueryResultsGrid.SelectionMode = DataGridViewSelectionMode.ColumnHeaderSelect; } Test being attempted: private Mock<IQueryForm> mockWind...

Questions about Selenium with nunit

Hi I want to write some tests for my website using Selenium but before I begin I have a couple questions. Note I have not looked at Selenium yet these are just pre questions How can I write my Selenium tests in nunit that would first say load up firefox do the set up of tests. Then next load up IE and do the tests again just in IE th...

Where is the [Rollback] Feature in Nunit?

Hi I want to use the role back feature yet when I write the tag it seems to not exists. I am using nunit 2.5.0 I just used the nunit.framework.dll Do I need to add some other .dll in? Also does anyone know how I actually get nunit to connect to a sql sever database in an asp.net application? I am not sure where to put my connectio...

Unit Test Help. How do I test for a message output to console?

I am a newbie to unit testing. How do I check the for console output? I have namespace XXShapes { public abstract class XXShape { public virtual void DrawXXShape() { Console.WriteLine("The XXShape was drawn."); } } public class XXCircle : XXShape { public override void DrawXXShape() ...

How to run explicit test cases of Nunit

Hi, My test suite project contains some explicit test cases, now i want to execute the test cases with the help of Nunit-console.exe. When i execute the test cases, the explicit test cases were excluded from the execution. So, i have tried to execute the test cases using the batch file in the following manner. nunit-console.exe test1.d...

App-settings for smtp-server not read correctly on cc.net build server?

Hi all, I have a unit test that attempts to send an email using the settings in my app.config in my unit test project. It works just fine on my developer machine, but the SmtpClient instance is not configured at all when running on my build server. Below is the code under test. Both client.Host and .Port is unconfigured on server. An...

nunit won't redirect console output

Hello I'm using nunit 2.5 and when I try the following nunit-console.exe "C:\Work\classLib\Data.Tests\bin\Debug\data.tests.dll" /out:output.txt it still displays it on the console. I can redirect ALL output by > output.txt of the whole command, but this doesn't work running in the context of NANT. Any ideas? EDIT: The NANT command ...

How do I start unit testing?

I know that unit testing is desirable, and I am interested in doing unit testing. The only problem is I have no idea how, or even where to start really. So my question is: How do I learn about and start unit testing? Specifically I frequently write Java code in NetBeans and C# code in Visual Studio and am interested in what tools to u...

NUnit & Probing Paths

Note: All assemblies here are not strong-named I'm using NUnit (tried 2.4.2 and 2.5.2) to run tests in assembly A. Assembly A references assembly B v2. Assembly A also references assembly C, which in turn references assembly B v1. When I run assembly A from a bin\Debug directory that only contains assembly B v2, the tests fail with a ...

What is the best method for storing test cases that your xunit tests load from ?

This is a "design/architecture" question and so you don't need to provide me technical details. I can find examples on the internet all day long that show how to run a xunit unit test, log test results, and how to show if it succeeds or fails but every example on the internet is hard coded and nobody shows examples of how you store your...

How to ensure that the view is safe of null exceptions

I have in the controller a custom DataView object that comprises 2 lists. I populate them and than pass the DataView object as model for my view. In view when displaying the data I am checking for null reference. I wonder how to write unit tests to ensure that the programmer did not forget to check for null reference in the view. I would...

Help me test a one-to-many realtionship with NHibernate and NUnit.

I have a class, Task, and it has a property TaskLibrary which is dll it will load and run some code from. So, any task has one library, but any library can have many tasks. My problem is that my test for making sure the task's Library property is not null is failing (so it could just be my test). My classes are effectively this: public ...

How to setup IPrincipal for a mockup?

Hi I want to mockup IPrincipal so I did this public Mock<IPrincipal> Principal { get; set; } in my setup of my nunit Principal = new Mock<IPrincipal>(); So this should be all that I need in my nunit unit test but how about in my actual controller file? Like how do I set it up? For example I have a membership.Provider So what I...

How to run Google Chrome with Selenium RC?

Hi I am trying to test my site with Selenium RC + Nunit + asp.net. I can get my tests to work in Firefox,Safari,opera,IE 8 but not google chrome. I put this in for the browser arugment selenium = new DefaultSelenium(Server, ServerPort, "*chrome", DomainURL); This always loads up Firefox tho...

How do I test an exception that is only thrown when the system path is wrong?

I have the following class in C# which creates an object from a propriatery .DLL that requires a license in a reachable directory at the initialization . public CplexServices{ private Cplex _cplex; public Cplex Cplex { get { return _cplex; } } public CplexServices() { try { _cplex = new Cplex(...

Access App.Config Settings from Class Library Called through Unit Test Project

I have the following setup: ASP.net 3.5 Web Site Project C# Class Library with business logic C# Class Library for unit testing The business logic library does all of the db access. It gets connection strings from the web.config file of the web site by accessing System.Configuration.ConfigurationManager.ConnectionStrings. When the li...

Private Accessor don't build when using MSBuild

My build server uses MSBuild to build my application. Our unit tests require access to some private members for testing, so we use the built in private accessors. Visual Studio has no problem with it, but when we push our code to the build server we get the error: MyTest.cs (96,13): errorCS0246: The type or namespace name 'My_Acc...

Multiple NUnit test assemblies, each requiring different config. How can I get NUnit to run them all at once?

I have 13 separate but related architecture assemblies, and 13 separate NUnit test assemblies, each one containing all the test fixtures for its matching architecture assembly. I am using NUnit 2.5.2 (latest version currently). I can run each test assembly separately in the NUnit GUI and all the tests pass. However, when I come to combi...

What is the equivalent of Java's default (package) access in C#?

What is the equivalent of Java's default (package) access in C#? Is there one? Is there anyway to restrict access to a particular namespace? The Problem: I'm trying to restrict access to certain methods to just my NUnit tests - in JUnit I would do this by making the methods package access and having the test in the same package but un...

Is there a way to specify ANYTHING as an argument to NUnit Mocks Expect call?

hi, I'm using NUnit mocks and would like to specify that I expect a call but without saying what the arguments will be for example: mock.ExpectAndReturn("Equals", true, ANY_ARGUMENT); Obviously filling in the correct syntax instead of ANY_ARGUMENT. Is there a way to do this? If I specify no arguments - NUnit fails the test because ...