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 writeGeneric() { string path = tmpFile("write.generic"); SkillFile sf = SkillFile.open(path); reflectiveInit(sf); sf.close(); File.Delete(path); }
public void APITest_core_subtypes_acc_poly() { string path = tmpFile("poly"); SkillFile sf = SkillFile.open(path, Mode.Create, Mode.Write); // create objects subtypes.A a = (subtypes.A)sf.As().make(); subtypes.B b = (subtypes.B)sf.Bs().make(); subtypes.C c = (subtypes.C)sf.Cs().make(); subtypes.D d = (subtypes.D)sf.Ds().make(); // set fields a.a = (A)d; b.a = (A)d; b.b = (B)d; c.a = (A)d; c.c = (C)c; d.a = (A)d; d.b = (B)d; d.d = (D)d; 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.Ds().staticSize()); Assert.AreEqual(1, sf.As().staticSize()); Assert.AreEqual(1, sf.Cs().staticSize()); Assert.AreEqual(1, sf.Bs().staticSize()); // create objects from file subtypes.A a_2 = (subtypes.A)sf2.As().getByID(a.SkillID); subtypes.B b_2 = (subtypes.B)sf2.Bs().getByID(b.SkillID); subtypes.C c_2 = (subtypes.C)sf2.Cs().getByID(c.SkillID); subtypes.D d_2 = (subtypes.D)sf2.Ds().getByID(d.SkillID); // assert fields Assert.IsTrue(a_2.a == d_2); Assert.IsTrue(b_2.a == d_2); Assert.IsTrue(b_2.b == d_2); Assert.IsTrue(c_2.a == d_2); Assert.IsTrue(c_2.c == c_2); Assert.IsTrue(d_2.a == d_2); Assert.IsTrue(d_2.b == d_2); Assert.IsTrue(d_2.d == d_2); } File.Delete(path); }
public SkillFile read(string s) { return(SkillFile.open(basePath + s, Mode.Read, Mode.ReadOnly)); }