public void test()
    {
        // 1 make a Pipe
        IExpire <Pipe <int> > expire = new ExpireNever <Pipe <int> >();
        IFlagable             flags  = new Flagable();
        Pipe <int>            p      = new PipeSum(expire, flags, 10);

        // 2 Pump the pipe
        assert(p.pump(5) == 15, "Pump produced the wrong value during pump operation!");

        // 3 Jsonify
        JsonObject jo = p.toJson();

        assert(jo["Type"] == "PipeSum");


        string directory = "TempDirectory";
        string fileName  = "TestFile";
        // NOTE: PersistantFilePath =  C:\Users\Arthur\AppData\LocalLow\DefaultCompany\StandAloneCon(plex)versation
        // 4 write to disk
        JsonOrigamist jsonOrigamist = new JsonOrigamist(directory, fileName);

        jsonOrigamist.add(jo);
        jsonOrigamist.writeToDisk();

        // 4.1 Simulate power down
        CentralRegistry.deregister(p.getNocabName());

        // 5 read from disk
        JsonArray  ja         = jsonOrigamist.readFromDisk();
        JsonObject joFromDisk = ja[0];

        assert(joFromDisk.ToString() == jo.ToString());

        // 6 Load the new pipe
        Pipe <int> pFromDisk = new PipeSum(joFromDisk);

        // 7 pump the new pipe
        assert(p.pump(5) == pFromDisk.pump(5));
    }
Example #2
0
 public bool deregister()
 {
     return(CentralRegistry.deregister(NocabName));
 }