示例#1
0
        public void TestCreation()
        {
            Cell cell1 = new SampleCell1();
            Cell cell2 = new SampleCell2();
            Cell cell3 = new SampleCell3();
            Cell cell4 = new SampleCell4();

            // Static construction

            var tag = ((Cell)cell1).GetTypeTag();
            Assert.IsNull(tag.Base);
            Assert.AreEqual(cell1.GetType(), tag.RuntimeType);
            Assert.AreEqual(2, tag.NumProps);
            Assert.AreEqual(0, tag.Offset);

            tag = ((Cell)cell2).GetTypeTag();
            Assert.AreEqual(cell1.GetTypeTag(), tag.Base);
            Assert.AreEqual(cell2.GetType(), tag.RuntimeType);
            Assert.AreEqual(1, tag.NumProps);
            Assert.AreEqual(2, tag.Offset);

            tag = ((Cell)cell3).GetTypeTag();
            Assert.AreEqual(cell1.GetTypeTag(), tag.Base);
            Assert.AreEqual(cell3.GetType(), tag.RuntimeType);
            Assert.AreEqual(1, tag.NumProps);
            Assert.AreEqual(2, tag.Offset);

            tag = ((Cell)cell4).GetTypeTag();
            Assert.AreEqual(cell2.GetTypeTag(), tag.Base);
            Assert.AreEqual(cell4.GetType(), tag.RuntimeType);
            Assert.AreEqual(1, tag.NumProps);
            Assert.AreEqual(3, tag.Offset);

            // Fingerprint length
            Assert.AreEqual(2, cell1.GetFingerprint().Length);
            Assert.AreEqual(3, cell2.GetFingerprint().Length);
            Assert.AreEqual(3, cell3.GetFingerprint().Length);
            Assert.AreEqual(4, cell4.GetFingerprint().Length);
        }