Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If I understand the problem, you need to persist the results of a test for a later inspection or additional testing. It has often been reluctant to invest too much time in writing test code, but in this case I see no alternative immediately available.</p> <p>My advice is to decouple as much as possible the parts involved: the algorithm, the persistence layer (serialization/deserialization), its product and the verification code.</p> <p>It is possible also that later algorithms implementations can share the same interface, e.g.:</p> <pre><code>interface IMyAlgorithm { AbstractOutput DoSomething (InputData); } class ConcreteOutput : AbstractOutput { // Output for version XXX of your algorithm } class XXXAlgorithm { ConcreteOutput DoSomething (InputData inputData) // Version XXX of you alogorithm } } interface IPersistenceManager { Serialize(AbstractOutput output, string filename); AbstractOutput Deserialize(string filename) } class XXXPersistenceManager : IPersistenceManager { // Handle persistence for XXX hierarchy } class XXXTestFixture { void BuildObjectWithXXXAlgorithm() { IMyAlgorithm XXX = new XXXAlgorithm(); // run XXX here AbstractOutput objXXX = XXX.DoSomething(new InputData()); IPersistenceManager pmXXX = new XXXPersistenceManager(); pmXXX.Serialize(objXXX); } void VerifyThatXXXWorkAsExpected() { IPersistenceManager pmXXX = new XXXPersistenceManager(); AbstractOutput objXXX = pmXXX.Deserialize(path); // check object here } } </code></pre> <p>So when you need to create a new algorithm, say YYY, you create the corresponding hierarchy. Anyway I don't know details and this is just a draft of pseudocode, placed here only to put emphasis on loosely coupling application components.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload