I am creating a unit test (XUnit) for a service in SnapDevelop. The service method takes a DataUnPacker object as a parameter. This gets passed to the API from PowerBuilder using the jsonpackage object. My question is how can I populate this in a C# unit test before calling the service? I have the following code so far -- see below. My idea was to insert some rows into a datastore, instantiate a new packer object, add the datastore to it and then pass it to the service (in bold). It doesn't like the datatype however and I can't compile. Is there a way to convert the packer object to an unpacker object? Is there a better way to handle this situation?
Thanks, Tom
var ds = new DataStore("d_department", context);
ds.Retrieve();
// Inserts an empty row before the first row of datastore.
ds.InsertRow(0);
ds.SetItem(0, "action", "A");
var packer = new DataPacker();
packer.AddDataStore("Departments", ds);
var result = service.GetDepartments(packer, out errmsg);
I think you could call IDataPacker.AddDataStore to add a DataStore:
https://docs.appeon.com/appeon_online_help/powerbuilder/api_reference/PowerBuilder.Data/DataStoreExtensions/Method/AddDataStore1.html
After converting it to IDataUnpacker, call IDataUnpacker.GetDataStore to get a DataStore:
https://docs.appeon.com/appeon_online_help/powerbuilder/api_reference/PowerBuilder.Data/DataStoreExtensions/Method/GetDataStore1.html