예제 #1
0
        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);
        }
예제 #2
0
파일: B.cs 프로젝트: skill-lang/csharpTests
 /// <summary>
 /// Used for internal construction, full allocation.
 /// </summary>
 public B(int skillID, subtypes.B b, subtypes.A a) : base(skillID)
 {
     this.b = b;
     this.a = a;
 }
예제 #3
0
 /// <summary>
 /// Used for internal construction, full allocation.
 /// </summary>
 public D(int skillID, subtypes.D d, subtypes.B b, subtypes.A a) : base(skillID)
 {
     this.d = d;
     this.b = b;
     this.a = a;
 }
예제 #4
0
 /// <summary>
 /// Used for internal construction, full allocation.
 /// </summary>
 public C(int skillID, subtypes.C c, subtypes.A a) : base(skillID)
 {
     this.c = c;
     this.a = a;
 }
예제 #5
0
파일: A.cs 프로젝트: skill-lang/csharpTests
 /// <summary>
 /// Used for internal construction, full allocation.
 /// </summary>
 public A(int skillID, subtypes.A a) : base(skillID)
 {
     this.a = a;
 }
예제 #6
0
 public abstract _R visit(subtypes.A self, _A arg);
예제 #7
0
 public CBuilder a(subtypes.A a)
 {
     instance.a = a;
     return(this);
 }