5

Looking for some advice on how to proceed here.

I am trying to do some integration testing on wcf services that call other wcf services. I want to make sure that they are configured correctly between one another. We are currently using spring.net and Nhibernate. What I am not sure about is how to check that the database is getting updated without actually saving anything to the database.

I have both msmq and wshttp services that I am trying to test here. I am familiar with transactions, as we use them in spring, but I have no idea how to setup my tests to rollback the transaction in a service that is not being tested directly by the integration test.

Right now the only option I have come up with is using a test database and test data, but it seems like there has to be a better solution than this.

Aaron M
  • 2,523
  • 1
  • 23
  • 38
  • 3
    Why would you prefer to **test** your software on a **production** database, instead of a **test** database? – CodeCaster Nov 17 '11 at 00:01
  • Maybe you misread me? The only option I have came up with so far is to create a test database and test data. – Aaron M Nov 17 '11 at 02:38
  • 1
    Could you set up all your services to use the same database and share the same `SessionFactory`? – Marijn Nov 17 '11 at 13:19

2 Answers2

0

Perhaps you can mock the services that update the database (or the DAL layer) using something like Moq, avoid the call to the database and checking with the verify method of the mock that the call to the database will be performed. In our project we are using this library with wcf with very good results.

Diego
  • 1,531
  • 1
  • 15
  • 27
  • This is a good idea if you want to test if the services are wired correctly, but this won't actually confirm that the proper sql is sent to the database. And I think this is what OP aims to do. – Marijn Nov 17 '11 at 16:02
  • Perhaps mocking the data access layer instead the wcf services will do the trick. I don't know how this is implemented, but if such layer exists it is easy to see if the proper sql will be executed without executing it. – Diego Nov 17 '11 at 18:01
  • Yes, I do this when testing the interfaces. But there is no way to perform any mocks on the service that is indirectly being called. – Aaron M Nov 17 '11 at 18:29
  • Using an in-memory database could help (assuming you are not tied to Microsoft Sql Server). – Diego Nov 17 '11 at 19:28
0

I decided to go with an implementation that is application specific. Basically creating a test database, and having our application hit the test database based on some values that are passed into our service.

Aaron M
  • 2,523
  • 1
  • 23
  • 38