Forum Discussion

marin's avatar
marin
Frequent Contributor
14 years ago

How to pass a reference to a stored table

Hello all,



my tests include a scenario where multiple outcomes of certain program logic branches need to be checked against corresponding table stored in Tables store.

I was wondering if it is possible to pass table name to a function and then check against that particular table, e.g. sth. like following:





function foo()

{

    doSomethingToModifyMyTable1;

    checkAgainstExistingTable(Tables.myTable1);

}



function foo2()

{

    doSomethingToModifyMyTable2;

    checkAgainstExistingTable(Tables.myTable2);

}





function checkAgainstExistingTable(myTableRef)

{

  doSomethingElseToModifyTableReferencedBy_myTableRef;

  myTableRef.Check();

}




Many thanks,



Marin

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    The code you described looks like it's not passing the name of the table through but the actual table object.  However, that's not a problem so long as you understand that.



    Essentially, I don't see anything on the surface that would be a problem with that code.  Have you tried it?  If so, have you run into particular problems that are preventing it from working?  Again, I don't see any fundamental problems with the test design...
  • marin's avatar
    marin
    Frequent Contributor
    Hello Robert,



    thanks for the reply - yes, I am actually passing the object, thanks for pointing it out.

    The code actually works, I have now verified it. Originally there was a problem caused elsewhere in the code which made me think that this approach can not work.

    Thanks again for your attention.





    Marin