Beispiel #1
0
        public void SdbDataHeadTest()
        {
            const FileFormatVersions FileFormat = FileFormatVersions.Office2010;
            var classIds                = new SdbClassIdToSchemaTypeIndex[5];
            var schemaTypes             = new SdbSchemaType[8];
            var particleConstraints     = new SdbParticleConstraint[2];
            var particleChildrenIndexes = new SdbParticleChildrenIndex[11];
            var attributes              = new SdbAttributeConstraint[4];

            var instance = new SdbDataHead(
                FileFormat,
                classIds,
                schemaTypes,
                particleConstraints,
                particleChildrenIndexes,
                attributes);

            Assert.Equal(FileFormat, instance.FileFormat);

            Assert.Equal(SdbSpan.Create(instance.ClassIds.Offset, classIds), instance.ClassIds);
            Assert.Equal(instance.ClassIds.End, instance.SchemaType.Offset);

            Assert.Equal(SdbSpan.Create(instance.SchemaType.Offset, schemaTypes), instance.SchemaType);
            Assert.Equal(instance.SchemaType.End, instance.Particles.Offset);

            Assert.Equal(SdbSpan.Create(instance.Particles.Offset, particleConstraints), instance.Particles);
            Assert.Equal(instance.Particles.End, instance.ParticleChildren.Offset);

            Assert.Equal(SdbSpan.Create(instance.ParticleChildren.Offset, particleChildrenIndexes), instance.ParticleChildren);
            Assert.Equal(instance.ParticleChildren.End, instance.Attributes.Offset);

            Assert.Equal(SdbSpan.Create(instance.Attributes.Offset, attributes), instance.Attributes);
            Assert.Equal(instance.Attributes.End, instance.End);

            var expected = new byte[]
            {
                0xB7, 0x55, 0xDD, 0x06, 0x4D, 0xEF, 0xEE, 0x46, 0xA6, 0x18, 0x04, 0x2A, 0xF4,
                0xC3, 0x90, 0x4E, 0x02, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x05, 0x00,
                0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
                0x00, 0x08, 0x00, 0x00, 0x00, 0xA4, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
                0x0D, 0x00, 0x00, 0x00, 0xBE, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x02,
                0x00, 0x00, 0x00, 0xD4, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00,
                0x00, 0x00,
            };

            var bytes = VerifyBytes(instance, expected);

            var deserialized = Assert.Single(Deserialize <SdbDataHead>(bytes));

            Assert.Equal(instance, deserialized);
        }
Beispiel #2
0
        public void SdbClassIdToSchemaTypeIndexTest()
        {
            const ushort ClassId         = 50;
            const ushort SchemaTypeIndex = 63;

            var instance = new SdbClassIdToSchemaTypeIndex(ClassId, SchemaTypeIndex);

            Assert.Equal(ClassId, instance.ClassId);
            Assert.Equal(SchemaTypeIndex, instance.SchemaTypeIndex);

            var bytes = VerifyBytes(instance, new byte[] { 0x32, 0x00, 0x3F, 0x00 });

            var deserialized = Assert.Single(Deserialize <SdbClassIdToSchemaTypeIndex>(bytes));

            Assert.Equal(ClassId, deserialized.ClassId);
            Assert.Equal(SchemaTypeIndex, deserialized.SchemaTypeIndex);

            Assert.Equal(instance, deserialized);
        }
        /// <summary>
        /// Get a SdbClassIdToSchemaTypeIndex data for the sepcified class ID.
        /// </summary>
        /// <param name="classId">The class ID.</param>
        /// <returns>A SdbClassIdToSchemaTypeIndex data.</returns>
        private SdbClassIdToSchemaTypeIndex GetClassIdData(SdbIndex classId)
        {
            int index = SdbClassIdToSchemaTypeIndex.ArrayIndexFromClassId(classId);

            return(this.SdbClassIdMap[index]);
        }