Beispiel #1
0
        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);
        }
Beispiel #2
0
        public void writeGeneric()
        {
            string    path = tmpFile("write.generic");
            SkillFile sf   = SkillFile.open(path);

            reflectiveInit(sf);
            sf.close();
            File.Delete(path);
        }
Beispiel #3
0
        public void APITest_core_hintsAll_acc_basic()
        {
            string    path = tmpFile("basic");
            SkillFile sf   = SkillFile.open(path, Mode.Create, Mode.Write);

            // create objects
            hintsAll.Abuser        a    = (hintsAll.Abuser)sf.Abusers().make();
            hintsAll.NowASingleton nas  = (hintsAll.NowASingleton)sf.NowASingletons().make();
            hintsAll.UID           uid  = (hintsAll.UID)sf.UIDs().make();
            hintsAll.BadType       bt   = (hintsAll.BadType)sf.BadTypes().make();
            hintsAll.User          u    = (hintsAll.User)sf.Users().make();
            hintsAll.ExternMixin   em   = (hintsAll.ExternMixin)sf.ExternMixins().make();
            hintsAll.Expression    expr = (hintsAll.Expression)sf.Expressions().make();
            // set fields
            a.abuseDescription = (string)"I am a absue description";


            uid.identifier = (long)7L;

            bt.reflectivelyInVisible = (string)"I am reflectively visible";
            bt.ignoredData           = (string)"Ignore me";

            u.name = (string)"herb";
            u.reflectivelyVisible = (string)"I am not visible";
            u.age = (long)43L;

            em.unknownStuff = ([email protected])null;

            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.BadTypes().staticSize());
                Assert.AreEqual(1, sf.NowASingletons().staticSize());
                Assert.AreEqual(1, sf.Abusers().staticSize());
                Assert.AreEqual(1, sf.ExternMixins().staticSize());
                Assert.AreEqual(1, sf.Users().staticSize());
                Assert.AreEqual(1, sf.UIDs().staticSize());
                Assert.AreEqual(1, sf.Expressions().staticSize());
                // create objects from file
                hintsAll.Abuser        a_2    = (hintsAll.Abuser)sf2.Abusers().getByID(a.SkillID);
                hintsAll.NowASingleton nas_2  = (hintsAll.NowASingleton)sf2.NowASingletons().getByID(nas.SkillID);
                hintsAll.UID           uid_2  = (hintsAll.UID)sf2.UIDs().getByID(uid.SkillID);
                hintsAll.BadType       bt_2   = (hintsAll.BadType)sf2.BadTypes().getByID(bt.SkillID);
                hintsAll.User          u_2    = (hintsAll.User)sf2.Users().getByID(u.SkillID);
                hintsAll.ExternMixin   em_2   = (hintsAll.ExternMixin)sf2.ExternMixins().getByID(em.SkillID);
                hintsAll.Expression    expr_2 = (hintsAll.Expression)sf2.Expressions().getByID(expr.SkillID);
                // assert fields
                Assert.IsTrue(a_2.abuseDescription != null && a_2.abuseDescription.Equals("I am a absue description"));


                Assert.IsTrue(uid_2.identifier == 7L);

                Assert.IsTrue(bt_2.reflectivelyInVisible != null && bt_2.reflectivelyInVisible.Equals("I am reflectively visible"));
                Assert.IsTrue(bt_2.ignoredData != null && bt_2.ignoredData.Equals("Ignore me"));

                Assert.IsTrue(u_2.name != null && u_2.name.Equals("herb"));
                Assert.IsTrue(u_2.reflectivelyVisible != null && u_2.reflectivelyVisible.Equals("I am not visible"));
                Assert.IsTrue(u_2.age == 43L);

                Assert.IsTrue(em_2.unknownStuff == null);
            }
            File.Delete(path);
        }
Beispiel #4
0
 public SkillFile read(string s)
 {
     return(SkillFile.open(basePath + s, Mode.Read, Mode.ReadOnly));
 }