unit-testing

How do you unit-test a plug-in to an application?

When developing a plug-in to application, using the application API which doesn't run independently of the application, is unit-testing even a possibility? What are strategies to test a plug-in that is tightly integrated with an application? ...

Mocking a COM object

I have been working on a wrapper for a COM object that can only take and return strings. The interface for the COM object looks like this: interface IMapinfo { void Do(string cmd); string Eval(string cmd); } Now I have made classes that wrap up basic functions like so: public class Table { ...

Why do SelectedIndices and SelectedItems not work when ListView is instantiated in unit test?

I'm writing this question in the spirit of answering your own questions, since I found a solution to the problem, but if anyone has a better solution I would gladly listen to it. In the application I am currently working on I am subclassing the ListView control to add some functionality of which some interacts with the ListView Selected...

Can unit tests have a execution time criteria?

Is it good practice to have a unit test that specifies how long a certain function takes to return a value. I'm unit testing a curl function and want to specify that it needs to time out after 5 seconds. Is this in line with the way unit tests work? ...

How to mock ADO.Net Dataservice calls from Silverlight

Has anyone found a good method of mocking out ADO.Net Data Service calls from a Silverlight application? The power of Data Services seems to be the use of linq, client side, over entities. However when testing the objects that do the data access how can you mock out the service? One way is to create an entire mock Data Service, but th...

How to test error-conditions with code that interacts with remote web-servers?

I have a small project that basically a Python wrapper to a websites API. It's fairly well tested, but there are some conditions I cannot work out how to easily test: when the remote API is unreachable, or otherwise broken. More specifically, I would quite like a test for each of the following: When the site is unreachable (connectio...

Moq multi-interface question

This may or may not be a multi-interface problem, but I'm doing something like this: var mockInterface1 = new Mock<IInterface1>(); var mockInterface2 = mockInterface1.As<IInterface2>(); mockInterface1.Expect( foo => foo.Foo(It.IsAny<IInterface3>() ) ); ... otherObject.DoSomething( (IInterface1)mockInterface2.Object ); On the DoSomet...

Iterate through an anonymous variable in another scope then where it was created

I am writing an unit test for a mvc web application that checks if a returned list of anonymous variables(in a jsonresult) is correct. therefore i need to iterate through that list but i cannot seem to find a way to do so. so i have 2 methods 1) returns a json result . In that json result there is a property called data. that property ...

How to decide test cases for unit tests?

I'm just getting into unit testing, and have written some short tests to check if function called isPrime() works correctly. I've got a test that checks that the function works, and have some test data in the form of some numbers and the expected return value. How many should I test? How do I decide on which to test? What's the best-pr...

What's a good way to write Unit tests for code with protected objects C# (using NMock, and NUnit framework)

When writeing unit tests for a single class that contains other objects what's the best way to use mock objects to avoid tests dependant on other classes. Example 1: public class MyClass { protected MyObject _obj; public MyClass() { _obj = new MyObject(); } public object DoSomething() { //some work ...

Best test runner? (Unit Testing, .NET)

I'm using MBUnit Framework for unit testing and looking for a good test runner. MbUnit's runner is fast however lacking lots of stuff such as You can't set execution path It's collapsing all trees in every run which drives me crazy And almost all other test runner provides so many extra quite and lovely features I used Zanebug, but...

How to set execution path in MbUnit?

Is there anyway to set an execution path for the tested DLL so it can find resource folders when MbUnit copy files into a temporary folder. Before you tell me: No I don't want to implement Dependency Injection I've tried putting these extra files as as content and set behaviour to copy, still doesn't work ...

How to stop stepping into .NET source code using TestDriven.NET?

I just started using TestDriven.NET to debug on my tests, here is my setup TestDriven.NET 2.17 VS 2008 SP1 Windows XP The problem I run into is on exception it keeps stepping into the .NET Framework source code. I checked Tools > Options > Debugging and "Enable .NET Framework source stepping" is not checked and "Enable Just My Code...

Which opensource java or .net project has best unit test coverage?

I want to dive more into the unit testing concepts. An open source project which will illustrate the best practices in unit testing is required. ...

Silverlight Unit Testing

Hi, I'm using the Silverlight UnitTest framerwork does anyone have a good example have how to unit test an application with it? I'm using it quite successfully to unit test a silverlight class library. Any pointers and links would be greatly appreciated. Thanks, Nath ...

Object Dumper/Unit Testing

I'm currently writing an object dumper (allowing different dumping strategies). Of course, I would like to write unit tests to verify that what I will develop will match all the features that I expect. However, I cannot imagine how I will perform the testing on this solution. I have thought about creating a set of objects which save th...

Java: How to test methods that call System.exit()?

I've got a few methods that should call System.exit() on certain inputs. Unfortunately, testing these cases causes JUnit to terminate! Putting the method calls in a new Thread doesn't seem to help, since System.exit() terminates the JVM, not just the current thread. Are there any common patterns for dealing with this? For example, can I ...

How to correctly unit test my DAL?

I'm new to unit testing. But how do I unit test my DAL which is written with Entity Framework, so I can make sure my DAL code is working correctly but no database is actually touched? Could someone give as much detail as possible please. Thanks, Ray. Note: this post is relevant to my other post Mocking vs. Test DB? which is asked aft...

Mocking vs. Test DB?

Earlier I asked this question How to correctly unit test my DAL?, one thing left unanswered for me is if to really test my DAL is to have a Test DB, then what is the role of mocking vs. a testing DB? To add on this, another person suggested to "use transactions and rollback at the end of the unit test, so the db is clean", test db that ...

DataRollBack with XtUnit in Nunit

Today I ran XtUnit at a part of my unit testing framework to to rollback database changes created while running a test case. This is a skeleton of how I have used it. The Test case ran successfully but the database state changed as a result. using NUnit.Framework; using TeamAgile.ApplicationBlocks.Interception; using TeamAgile.Applica...