unit-testing

Testing stored procedures' logic

We have quite a bit of logic in TSQL stored procedures. Being a big fan of automated tests, I started writing automated tests for stored procedures. I test stored procedures by calling them from a C# project. I make all tests touching the database inherit from a base class the ensures the test is run in a TransactionScope that is neve...

How to test Subversion functions?

Hi, I am implementing an application that involves some svn functions. I'm gonna write some unit tests for the app, however, how would you suggest I write unit tests for svn commands such as checkout, update, status, etc? Thanks! ...

Setting useLegacyV2RuntimeActivationPolicy for test projects in VS 2010

In .NET 4, loading .NET 2 mixed-mode assemblies requires setting useLegacyV2RuntimeActivationPolicy="true" in the startup element of the app.config file for the application project. How can I set this (and is it necessary) for a test project? I am getting some very odd behavior in the testing host, but only for tests that use CLR 2 mix...

Testing un-compilable code in NUnit

I have a class which for now should always have a certain member populated before it is valid. To enforce this, the class has no default constructor and instead has a constructor which accepts a value for that required member. The setup is similar to this below: public class MyClass { public string Owner { get; protected set; } pub...

How do you unit test HTML.ActionLink

I would like to be able to unit test that an HTML.ActionLink or Url.Action will return the correct url based on my route. What is the best way to achieve this. ...

Does it make sense to unit test throwaway code that runs in production?

One of the primary benefits of unit testing is to provide confidence that when one needs to later alter the code one is not breaking it. However, what benefits does unit testing provide for code that is literally used as one-off throwaway code? This throwaway code is most certainly used in production, but is never actually altered once i...

Importance of unit testing my Views when using the MVVM pattern?

When using the MVVM pattern to structure your WPF application you should get all your business logic out of the View and code-behind files. Doing it properly the View itself will be a simple facade with Data Bindings and Command Bindings to the ViewModel classes - which is where the magic happens. One key benefit from structuring your a...

Rhino Mocks overwriting stubs possible?

I have this problem, which may be a bug in Rhino Mocks 3.5: stubObj = MockRepository.GenerateStub(IObject); stubObj.Stub(a=>a.Get()).Return (Guid.Empty); //1.stub stubObj.Stub(a=>a.Get()).Return (Guid.NewGuid()); //2.stub, should overwrite the first one? this: var value = stubObj.Get(); returns Guid.Empty, is this the correct beh...

How to avoid breaking build when committing Visual Studio Unit Tests in CruiseControl.Net

I'm having a problem when a project is committed to SVN, which in turn is automatically picked up by our newly set-up CruiseControl.NET server, the UnitTests are failing. The unit tests are written in the default Visual Studio Unit test framework - which is the problem. I spot that nUnit appears to be recommended as a good alternative. ...

cmake unit test issue

Hello all, I'm facing a problem where in I build a shared library and and a unit-test executable (which is in a sub directory) I want to execute this test as a POST_BUILD operation for the shared library. So I gave Add_Custom_Command (TARGET ShLibName POST_BUILD COMMAND unit_test_exe) CMake throws an error message during generation pr...

Mocking Extension Methods with Moq

I have a preexisting Interface... public interface ISomeInterface { void SomeMethod(); } and I've extended this intreface using a mixin... public static class SomeInterfaceExtensions { public static void AnotherMethod(this ISomeInterface someInterface) { // Implementation here } } I have a class thats callin...

Unit Test for a View Attribute using Moq

I am using Moq for unit testing and I would like to test for a view's attribute. In this case the Authorize attribute. Example View Code: [Authorize(Roles = "UserAdmin")] public virtual ActionResult AddUser() { // view logic here return View(); } So I would like to test the view attribute when I act on this view with a user t...

unit test an attached behavior wpf

I am still grokking attached behaviors in general, and am at a loss to see how to write a unit test for one. I pasted some code below from Sacha Barber's Cinch framework that allows a window to be closed via attached behavior. Can somewone show me an example unit test for it? Thanks! Berryl #region Close /// <summary>Dependen...

Unit Testing with Complex Directory Structure

I am trying to use test-driven development for an application that has to read a lot of data from disk. The problem is that the data is organized on the filesystem in a somewhat complex directory structure (not my fault). The methods I'm testing will need to see that a large number of files exist in several different directories in order...

Has anyone used Robotium or Calculon for testing Android apps?

Has anyone used Robotium or Calculon for testing Android apps? Are they useful? Any recommendations on which is better? ...

How to test UIViewControllers at build time?

I'm a big believer in testing, but not a very good practitioner. I've done pretty well at getting coverage on my model objects and programming them in a TDD style. I'm actually enjoying it so much I'd love to extend this to my controller layer, particularly my UIViewController subclasses. Unfortunately, many UIKit classes don't function...

mocking a singleton class

I recently read that making a class singleton makes it impossible to mock the objects of the class, which makes it difficult to test its clients. I could not immediately understand the underlying reason. Can someone please explain what makes it impossible to mock a singleton class? Also, are there any more problems associated with making...

Set up CUTE (Eclipse CDT Unit Testing Plugin) on OSX

I am trying to set up the CUTE unit testing plugin for Eclipse C/C++ Development Tools. The documentation says: If you did not install Boost in the standard location, you will need to specify it. Right click on the newly created CUTE project, and select Properties. In C/C++ Build, Settings, choose the Tool Settings tab. Specify the ...

How can I add a ClientAccessPolicy.xml file to the SharePoint 2010 root folder?

In a Visual Studio 2010 SharePoint (2010) project, we can add mapped SharePoint folders, including the {SharePointRoot} folder. When I deploy my project, I can see that the root files end up in the 14-hive, but they never appear in the web site root. What I really want to accomplish to unit test my Silverlight application which communic...

Problem in RoR testing

I reading/learning "agile develpment.." now i'm on Chapter 14 (testing)/ when i tried to run "@ruby -I test test/unit/product_test.rb" i have error that 1) Error: test_invalid_with_empty_attributes(ProductTest): ActiveRecord::StatementInvalid: PGError: ERROR: relation "carts" does not exist LINE 1: DELETE FROM "carts" ...