chrisb
11 years agoRegular Contributor
Save method overwrites an object saved to stores
I am using the save method to save one property of an object to the project stores.
dir = "C:\\testing\\WIP\\Stores\\Objects\\"+dirName;
Objects.Save(fieldContent, hashIndex,"Text","","True",dir);
I then call Objects.Save a second time but pass a different directory name, I would expect the object to then be saved twice, once to the first directory and once to the new directory.
It seems that TC tries to be clever and recgonizes that the object is the same in both cases and overwrites the existing object with the latest version of the same object and updates the directory name (path).
Is there a way I can save the same object in two locations in the Stores? Ie. in 2 different directories. I need to do this to save test data from a common control that is tested using different data in two different tests.
dir = "C:\\testing\\WIP\\Stores\\Objects\\"+dirName;
Objects.Save(fieldContent, hashIndex,"Text","","True",dir);
I then call Objects.Save a second time but pass a different directory name, I would expect the object to then be saved twice, once to the first directory and once to the new directory.
It seems that TC tries to be clever and recgonizes that the object is the same in both cases and overwrites the existing object with the latest version of the same object and updates the directory name (path).
Is there a way I can save the same object in two locations in the Stores? Ie. in 2 different directories. I need to do this to save test data from a common control that is tested using different data in two different tests.
- Hi Chris
An interesting problem and one for which I may be completely wrong, but have you tried looking in the two different file locations using Explorer to see if there are 2 physically different files?
This in itself will not directly answer your query, but I think that the problem might lie in how the Objects.Save feature works. Is it that this is a collection of objects in the store, each of which must be unique and the fact that you have specified different directory paths is irrelevant because these are just values of a key, being the object's name, which is the same in both cases, For example, if the key is 'A' and one of its values is 'C:/myDir/myFile' and I create another key 'A' with a value 'C:/yourDir/yourFile', there will still only be one object in the collection with key A (the object's name), but its values, in this case the directory location have changed. If you want to have two objects in the collection you will need to have unique names for each.
I would be interested to hear if my understanding of this is correct?
Regards
Stephen.