public void writeGenericChecked() { string path = tmpFile("write.generic.checked"); SkillFile sf = SkillFile.open(path); reflectiveInit(sf); // write file sf.flush(); // create a name -> type map Dictionary <string, IAccess> types = new Dictionary <string, IAccess>(); foreach (IAccess t in sf.allTypes()) { types[t.Name] = t; } // read file and check skill IDs SkillFile sf2 = SkillFile.open(path, Mode.Read); foreach (IAccess t in sf2.allTypes()) { IEnumerator os = types[t.Name].GetEnumerator(); foreach (SkillObject o in t) { Assert.IsTrue(os.MoveNext(), "to few instances in read state"); Assert.AreEqual(o.SkillID, ((SkillObject)os.Current).SkillID); } Assert.IsFalse(os.MoveNext(), "to many instances in read state"); } File.Delete(path); }
public void APITest_interfaces_graphInterface_acc_succ__1() { string path = tmpFile("succ_1"); SkillFile sf = SkillFile.open(path, Mode.Create, Mode.Write); // create objects graphInterface.ColorHolder ch = (graphInterface.ColorHolder)sf.ColorHolders().make(); graphInterface.SubNode sn = (graphInterface.SubNode)sf.SubNodes().make(); graphInterface.Node n = (graphInterface.Node)sf.Nodes().make(); // set fields ch.anAbstractNode = (ColoredNode)n; ch.anAnnotation = (Colored)(Colored)null; sn.next = (Marker)(Marker)null; sn.color = (string)"red"; sn.f = (Marker)(Marker)null; sn.edges = (System.Collections.Generic.HashSet <ColoredNode>)set <ColoredNode>(n); sn.map = (System.Collections.Generic.Dictionary <Node, System.Collections.Generic.Dictionary <ColoredNode, Marker> >)put(map <Node, Dictionary <ColoredNode, Marker> >(), n, put(map <ColoredNode, Marker>(), n, (Marker)null)); sn.mark = (string)"Cirlce"; sn.n = (Node)n; n.next = (Marker)(Marker)null; n.color = (string)"blue"; n.edges = (System.Collections.Generic.HashSet <ColoredNode>)set <ColoredNode>(); n.map = (System.Collections.Generic.Dictionary <Node, System.Collections.Generic.Dictionary <ColoredNode, Marker> >)put(map <Node, Dictionary <ColoredNode, Marker> >(), n, put(map <ColoredNode, Marker>(), n, (Marker)null)); n.mark = (string)"Circle"; sf.close(); { // read back and assert correctness SkillFile sf2 = SkillFile.open(sf.currentPath(), Mode.Read, Mode.ReadOnly); // check count per Type Assert.AreEqual(1, sf.SubNodes().staticSize()); Assert.AreEqual(1, sf.Nodes().staticSize()); Assert.AreEqual(1, sf.ColorHolders().staticSize()); // create objects from file graphInterface.ColorHolder ch_2 = (graphInterface.ColorHolder)sf2.ColorHolders().getByID(ch.SkillID); graphInterface.SubNode sn_2 = (graphInterface.SubNode)sf2.SubNodes().getByID(sn.SkillID); graphInterface.Node n_2 = (graphInterface.Node)sf2.Nodes().getByID(n.SkillID); // assert fields Assert.IsTrue(ch_2.anAbstractNode == n_2); Assert.IsTrue(ch_2.anAnnotation == (Colored)null); Assert.IsTrue(sn_2.next == (Marker)null); Assert.IsTrue(sn_2.color != null && sn_2.color.Equals("red")); Assert.IsTrue(sn_2.f == (Marker)null); Assert.IsTrue(sn_2.edges != null && Enumerable.SequenceEqual(sn_2.edges, set <ColoredNode>(n_2))); Assert.IsTrue(sn_2.map != null && Enumerable.SequenceEqual(sn_2.map, put(map <Node, Dictionary <ColoredNode, Marker> >(), n_2, put(map <ColoredNode, Marker>(), n_2, (Marker)null)))); Assert.IsTrue(sn_2.mark != null && sn_2.mark.Equals("Cirlce")); Assert.IsTrue(sn_2.n == n_2); Assert.IsTrue(n_2.next == (Marker)null); Assert.IsTrue(n_2.color != null && n_2.color.Equals("blue")); Assert.IsTrue(n_2.edges != null && Enumerable.SequenceEqual(n_2.edges, set <ColoredNode>( ))); Assert.IsTrue(n_2.map != null && Enumerable.SequenceEqual(n_2.map, put(map <Node, Dictionary <ColoredNode, Marker> >(), n_2, put(map <ColoredNode, Marker>(), n_2, (Marker)null)))); Assert.IsTrue(n_2.mark != null && n_2.mark.Equals("Circle")); } File.Delete(path); }
public void writeGeneric() { string path = tmpFile("write.generic"); SkillFile sf = SkillFile.open(path); reflectiveInit(sf); sf.close(); File.Delete(path); }
public SkillFile read(string s) { return(SkillFile.open(basePath + s, Mode.Read, Mode.ReadOnly)); }