unit-testing

Are there any mocking libraries that support the .NET Compact Framwork.

I was just wondering if anyone has found a mocking library that can be used with the .NET compact framwork. I have tried Moq but it doesn't seem to work, I did a quick Google search but couldn't find anything useful. Thanks. ...

Should I be using a moq just to test if a method is called?

I have some test code that looks like this: [Test] public void RunTableInfoCommandShouldCallTableINfoWithName() { string expectedcommand = "TableInfo(TestTable,1)"; Table.RunTableInfoCommand(mockmapinfo.Object, "TestTable", TableInfoEnum.TAB_INFO_NAME); //This is just an en...

What's the right way, for testability, to add functionality to a ComboBox?

The desired functionality of the 'enhanced' combo box is a quick find method. Each item in the combobox has a ToString() method, such that they can be displayed in the drop down list. On clicking an item in the drop down list, the combobox's observers are notified of the selection. Also, every time the typed text in the combobox changes...

Unit tests to verify time complexity

Hi, Does anyone use unit tests to verify the time/space complexity of code? Thanks Hugo ...

How do you unit test regular expressions?

I'm new to TDD, and I find RegExp quite a particular case. Is there any special way to unit test them, or may I just threat them as regular functions? ...

Why does Microsoft.VisualStudio.TestTools.UnitTesting.Assert.Equals() exist?

Description for Assert.Equals() from the MSDN Documentation: Do not use this method. That's it, the full explanation. Uh.. ok, but then ... why is it there? Is it a deprecated method from an earlier version of the framework? Something that's supposed to be used only by other Microsoft Assemblies? It just makes me want to use it all ...

Context agnostic JavaScript Testing Framework

I'm looking for a JavaScript Testing Framework that I can easily use in whatever context, be it browser, console, XUL, etc. Is there such a framework, or a way to easily retrofit an existing framework so its context agnostic? Edit: The testing framework should not be tied to any other framework such as jQuery or Prototype.js and should...

Unit test HttpContext.Current.Cache or other server-side methods in C#?

When creating a unit test for a class that uses the HttpContext.Current.Cache class, I get an error when using NUnit. The functionality is basic - check if an item is in the cache, and if not, create it and put it in: if (HttpContext.Current.Cache["Some_Key"] == null) { myObject = new Object(); HttpContext.Current.Cache.Insert(...

How to test for sometimes fails?

I'm trying to write a unit test for a module that will give me a random list of numbers given certain criteria. The particular test I'm writing is a reshuffle of the original sequence. I'm testing that The sequences are the same length The sequences have the same values The sequences are not in the same order The problem with this i...

Moq: how to assert that methods on my mock object are NOT run?

I have mocks working where I test that methods on my mocked object are called with the correct parameters, and return the right result. Now I want to check another condition. In this case, NO methods should be run on the mocked object. How can I express this in a unit test? ...

Using a dependency injection system how do you unit test your code.

As far as I can see there are two ways, both with their drawbacks. Get the object you are unit testing from the dependency injection system. This is low maintenance as you don’t have to manage anything when you change the framework around. But you are essentially testing the whole system from the point of view of your object, if a comp...

Include Data in my Unit Tests

I have some files I want to use in my unit tests but I want to make those files relative to location of the dll which contains the unit tests, is this possible? In other words I have included a Resources folder which contain some files for my unit tests to use in testing, I marked the files "Build Action" = "Content" and "Copy to Outpu...

How to test an application?

I have been building IMO a really cool RIA. But its now close to completion and I need to test it to see if there are any bugs or counter-intuitive parts or anything like that. But how? Anytime I ask someone to try to break it, they look at it for like 3 minutes and say "it's solid". How do you guys test things? I have never used a UnitT...

Is there a way to Execute NUnit Tests in a Specific Order?

When I am testing my DAL I need to create some database entities before others because of dependencies, is there a way via method attributes or something I can make NUnit execute my tests in the order I specify ? ...

.NET - Unit Testing Your Code and State in Your Database

Assumptions: We use .NET coding against SQL Server 2005 I was just wondering how most people incorporate state into the Unit Tests that affect their database? I know when and where to use mocking, but when you want to move past that and actually do some database tests... what strategies do you use to setup and teardown your database? Do...

DbC (Design by Contract) and Unit Tests

I am using contracts with C# 4.0 and before I was using lots of unit tests (not with TDD). I am wondering if DbC eliminates the need to write external unit tests? Personally I find contracts better to make robust frameworks, as the contracts are closely coupled with the code itself, and offers other benefits. What do you guys think? ...

What do you use to unit test C code?

I am a professional web developer and therefore I'm used to using very high-level scripting languages and testing tools. I've recently been working, personally, more with C and writing many C programs for unix-based systems to do various tasks. However, I still haven't gotten into a good groove for unit testing this code and I was wonde...

Making sure a view exists

I'm currently looking into unit testing for a new application I have to create. I've got the basic testing going nicely (testing the ActionResult classes is pretty nice). One thing I do want to make sure though, is that a viewpage exists in my solution. I'm not 100% sure my test is correct, so if anyone had suggestions, please don't hesi...

How do you test methods that take enums.

I already have a test setup up for this function but I would like to know if it's the best way to go about it. I have a method like this: public static string RunTableInfoCommand(IMapinfoWrapper wrapper, TableInfoEnum infoToReturn) { //pass the int value of infoToReturn to underlying COM objec...

Should I be testing a methods implementation using mocks.

I'm having a bit of trouble doing some unit-testing using moq. If I have a function like this: public string GetName(IMapinfoWrapper wrapper) { return wrapper.Evaluate("My com command"); ///"My comm command" is the same all the time. } Then I have a test that checks the return value of the GetName function: [Test] public void ...