unit-testing

Unit Testing Expression Trees

I recently need to build a Expression tree so I wrote a Test method like so... /// <summary> /// /// </summary> [TestMethod()] [DeploymentItem("WATrust.Shared.Infrastructure.dll")] public void BuildForeignKeysContainsPredicate_shoud_build_contains_predicate() { RemoteEntityRefLoader_Accessor<ReferencedEntity> target = CreateRe...

How to mock or stub a .netTiers generated DataRepository object

I am using Rhino mocks for unit test mocking of objects. Our DAL uses codesmith to generate code from .netTiers templates, which creates these DataRepository classes that contain all the methods for CRUD type transaction to the datasource. In unit testing, I am trying to mock this data repository object which has no interface class to us...

Does Unit Testing make Debug.Assert() unnecessary?

Its been a while I have ready Mcconnell's "Code Complete". Now I read it again in Hunt & Thomas' "The Pragmatic Programmer": Use assertions! Note: Not Unit Testing assertions, I mean Debug.Assert(). Following the SO questions When should I use Debug.Assert()? and When to use assertion over exceptions in domain classes assertions are use...

Operation involving foreign key Insertion causes problems during Unit Testing Stage

I have the following schema: create table statuslookup { statusid int primary key, statusname string unique, description string } create table job { jobid int primary key, jobname string unique, status_id foreign key reference statuslookup(statusid) } The table statuslookup will, of course, be prepopulated during the sche...

How to unit test a WCF Client built with WCF Rest Starter Kit

I created some POX services using the REST Starter kit. At first, it was a little complicated to create the unit tests for the service layer, but in the end, it was well designed and I succeed in mocking the context and set expectations. But, I'm starting in with the client side now, and I'm having some problems figuring out how to mock...

Refactoring strategy for the class which generates specific text file

Hi guys, I am a TDD noob and I don't know how to solve the following problem. I have pretty large class which generates text file in a specific format, for import into the external system. I am going to refactor this class and I want to write unit tests before. How should these tests look like? Actually the main goal - do not break th...

Integrate Silverlight Unit Testing with Visual Studio 2008 Test Results Panel?

I would like to run my Silverlight Unit Tests from Visual Studio instead of opening a new instance of my Silverlight Test App in the browser. Apparently it is possible (http://www.jeff.wilcox.name/2008/09/rc0-new-test-features/ - search for "Visual Studio Team Test log provider output")....but I don't understand how you enable this, doe...

VS08 TFS unit tests vs Gallio/MbUnit

I am looking into adding unit tests at work. I used MbUnit in the past, and have some sample UT's in Gallio framework. We are using VS08 which comes with its own testing suite. What are pros and cons of using VS08 TFS UT vs Gallio? What is the general recommendation on which framework to use? Thanks! ...

Suggestions for BDD Scenarios for an generic API?

I'm putting together BDD inspired unit tests for the API part of my application. (Yeah, I know, BDD is supposed to be about the domain and talking to the suits, but I'd rather try out BDD on something less visible first) Ordinary use. The developer uses the API methods with ordinary parameter values. Extreme use. The developer invokes...

OrderedTest- Not keeping valuse from previous Test. - visualstudio208 - Unit Testing.

Hi, I am trying to Unit Test the application using VSTS 2008 unit Testing. My Problem is: I want to invoke two test case in an order. I am using the ordered Test case feature of VSTS 2008 for this. Problem i facing is I increment the value of one variable(X) in TestA and on the basis of that value i am chekcing something in TestB. But wh...

NMocks2 Argument Syntax in Rhino Mocks?

In NMocks2 you can mock up the result of a method you don't know the arguments to before hand using Stub.On(aMock) .Method( ... ) .WithAnyArguments() .Will(Return.Value( ... ); from NMocks2 Cheatsheet. My question is, is there a similar mechanism for Rhino mocks when you don't care about the arguments? I want to make a ...

Unit testing for D-Bus and HAL?

How does one test a method that does some interactions with the local D-Bus (accessing a HAL object)? Results of tests will differ depending on the system that the test is run on, so I don't know how to provide the method reliable input. I'm working in Python, by the way. ...

When is it OK to change "completed" unit tests?

I've taken my first baby steps into Unit Testing and, due to a better understanding of the domain, have made a change to a domain model that has broken a unit test. So this brought up the question: When is it permissible to change previously working unit tests? I figure I'm missing an important aspect of unit testing in having to ask t...

Generating tests from run-time analysis

We have a large body of legacy code, several portions of which are scheduled for refactoring or replacement. We wish to optimise parts that currently impact on the user-experience, facilitate reuse in a new product being planned, and hopefully improve maintainability too. We have quite good/comprehensive functional tests for an existing...

How to unit test Silverlight 3 Out-Of-Browser application?

How to unit test Silverlight 3 Out-Of-Browser application? ...

Can You Specify the Order of Test Execution in VS 2005 Test Engine?

I am using the provided Unit Test Engine in Visual Studio 2005 and am wondering if there is a way for me to specify the order of tests. I have numerous test classes and numerous test methods inside of each. I would like to control the order in which the test classes are executed and the order of the test methods in each. ...

What is the best way to automate integration testing MSMQ with Visual Studio Test suite / NUnit?

I would like to create a series of automated unit tests for an MSMQ application I am writing. As I see it, the challenge is how to accommodate the event handlers from the test method. That is, I send a message from the test method and need to return a result back to that test method that the message has been received and handled. I ha...

Multiple asserts in single test?

Let's say I want to write a function that validates an email address with a regex. I write a little test to check my function and write the actual function. Make it pass. However, I can come up with a bunch of different ways to test the same function ([email protected]; [email protected]; test.test.com, etc). Do I put all the incantations t...

Unit testing JSPs in embedded mode

I am in process of building up a small framework that does unit testing for JSPs. These JSPs have some custom tags, otherwise they are not any special. Although there are numerous Java unit testing solutions available, I prefer not to use the method where a separate full-blown JSP container is launched, application deployed and results ...

Is my Unit Test Sufficient?

I am looking at the Unit Tests I wrote for an email service (unsing SMTP) and I am wondering if one test inparticular is suffient. Here is a snippet of my email service: [PluginFamily("EmailService")] public interface IEmailService { Boolean SendEmail( string toAddress, string fromAddress, string bccAddress, string ccAddress, stri...