We are writing a unit testing framework using MSTest so that we can test the AIF framework integration project we have.
We couldn't figure out a way to use mocks so our solution to this was to take a snapshot of the database at the start of the unit tests, then restore and dispose of it at the end using assembly initialise and cleanup.
Our test structure then makes a log on call to AX to create the data we need then log off and dispose. We then arrange the data we need and push it through the AIF service.
By the time we get to restoring the snapshot it falls over and says that it is not able to restore the database while other users are using the database. (even though we are cleaning up the service after its use). We can solve this by running another SQL query before it which loops through all the sessions and kills them (apart from the current one). This allows the DB to restore correctly but because we are not gracefully closing the sessions the AX Service thinks there is a problem and turns itself off which as you can imagine isn't very useful!
So we have a catch 22 situation here.
I haven't included any code in here because I don't think it would help any but if you think it will then let me know.
Please help me I am literally at the end of my tether!