views:

173

answers:

2

Hi,

I am using Pivotal CRM and I do not find easy ways to code unit test for its ASRs for this software. Do you have any experience programming test for this software?

Edit: I have thought a simple but not perfect way of testing. But I am willing to give the Bounty to anybody who gives the minimun insight.

A: 

The only possible answer I find is to move the logic to other clases than would be called by the ASR. This way you can unit test the classes. ASR become more complicated and would only be tested as part of integration test.

borjab
+1  A: 

Great question. I would inject stubs or mocks on the implemented methods to set up the test. So if I implement the IRFormScript interface like below. I could use a stub that implements the IRForm interface to setup expectations on the form object that gets injected into my methods. Some of these arguments are just strings too, so those are easy. You would also have to stub out any other interfaces to Pivotal in order to test your functionality without actually hitting the real system.(IRSystem7, DataAccess, etc.) Hope this helps! Brandon Joyce

public class TDD : Pivotal.Interop.RDALib.IRFormScript
{        
    public object AddFormData(Pivotal.Interop.RDALib.IRForm pForm, object Recordsets, ref object ParameterList)
    {
        throw new NotImplementedException();
    }

    public void DeleteFormData(Pivotal.Interop.RDALib.IRForm pForm, object RecordId, ref object ParameterList)
    {
        throw new NotImplementedException();
    }

    public void Execute(Pivotal.Interop.RDALib.IRForm pForm, string MethodName, ref object ParameterList)
    {
        throw new NotImplementedException();
    }

    public object LoadFormData(Pivotal.Interop.RDALib.IRForm pForm, object RecordId, ref object ParameterList)
    {
        throw new NotImplementedException();
    }

    public object NewFormData(Pivotal.Interop.RDALib.IRForm pForm, ref object ParameterList)
    {
        throw new NotImplementedException();
    }

    public void NewSecondaryData(Pivotal.Interop.RDALib.IRForm pForm, object SecondaryName, ref object ParameterList, ref Pivotal.Interop.ADODBLib.Recordset Recordset)
    {
        throw new NotImplementedException();
    }

    public void SaveFormData(Pivotal.Interop.RDALib.IRForm pForm, object Recordsets, ref object ParameterList)
    {
        throw new NotImplementedException();
    }

    public void SetSystem(Pivotal.Interop.RDALib.RSystem pSystem)
    {
        throw new NotImplementedException();
    }     
}
Brandon Joyce
Hi Brandom, Thanks a lot. I am having problems accepting your answer (see http://stackoverflow.com/questions/637822/is-there-a-bug-keeps-me-from-accepting-an-answer-from-an-expired-bounty)Anyway I will need to try. But I feel that I missing somethig of the big picture and I am new to testing.
borjab
Mocking or stubbing out all this stuff may seem like some work, but it's pretty easy with a mocking framework like Rhino Mocks. It's really about being able to test this thing in isolation. It's worth the effort. Good Luck!
Brandon Joyce