Exemple #1
0
        public void AssemblyMetadata_WhenCreatedAndIndexesAre4Bytes_ShouldHaveCorrectValues()
        {
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(4);
            Offset        offset       = 0;

            byte[] contents =
            {
                0x04, 0x80, 0x00, 0x00,
                0x01, 0x00,
                0x00, 0x00,
                0x00, 0x00,
                0x00, 0x00,
                0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00,
                0x9A, 0x1D, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00
            };

            AssemblyMetadataTableRow row = new AssemblyMetadataTableRow(contents, offset, indexDetails);

            Assert.AreEqual(AssemblyHashAlgorithms.SHA1, row.HashAlgId);
            Assert.AreEqual("1.0.0.0", row.GetVersion().ToString());
            Assert.AreEqual(AssemblyFlags.SideBySideCompatible, row.Flags);
            Assert.AreEqual(0, row.PublicKey);
            Assert.AreEqual(0x1D9A, row.Name.Value);
            Assert.AreEqual(0x0000, row.Culture.Value);
        }
        public void AssemblyRef_WhenConstructed_ValuesAreCorrect()
        {
            byte[] content =
            {
                0x04, 0x00,
                0x01, 0x00,
                0x00, 0x00,
                0x00, 0x00,
                0x00, 0x00, 0x00, 0x00,
                0x63, 0x03,
                0xD9, 0x03,
                0x00, 0x00,
                0x00, 0x00
            };
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(2);

            AssemblyRefMetadataTableRow row = new AssemblyRefMetadataTableRow(content, 0, indexDetails);

            Assert.AreEqual("4.1.0.0", row.GetVersion().ToString());
            Assert.AreEqual(AssemblyFlags.SideBySideCompatible, row.Flags);
            Assert.AreEqual(867, row.PublicKeyOrToken);
            Assert.AreEqual(985, row.Name.Value);
            Assert.AreEqual(0, row.Culture.Value);
            Assert.AreEqual(0, row.HashValue);
        }
        public void Module_WhenCreated_OffsetIsMovedOn()
        {
            byte[]        contents     = new byte[10];
            Offset        offset       = 0;
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(2);

            ModuleMetadataTableRow row = new ModuleMetadataTableRow(contents, offset, indexDetails);

            Assert.AreEqual(10, offset.Current);
        }
Exemple #4
0
        public void EventMap_WhenCreated_OffsetIsMovedOn()
        {
            byte[]        contents     = new byte[20];
            Offset        offset       = 0;
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(2);

            EventMapMetadataTableRow row = new EventMapMetadataTableRow(contents, offset, indexDetails);

            Assert.AreEqual(4, offset.Current);
        }
        public void NestedClass_WhenCreated_OffsetIsMovedOn()
        {
            byte[]        contents     = new byte[4];
            Offset        offset       = 0;
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(2);

            NestedClassMetadataTableRow row = new NestedClassMetadataTableRow(contents, offset, indexDetails);

            Assert.AreEqual(4, offset.Current);
        }
        public void TypeSpec_WhenCreated_OffsetIsMovedOn()
        {
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(2);

            byte[] contents = new byte[2];
            Offset offset   = 0;

            TypeSpecMetadataTableRow row = new TypeSpecMetadataTableRow(contents, offset, indexDetails);

            Assert.AreEqual(2, offset.Current);
        }
Exemple #7
0
        public void AssemblyMetadata_WhenConstructedWithIndexSizes_ShouldMoveOffset(byte sizeStringIndex, byte sizeBlobIndex, int expected)
        {
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(2, sizeStringIndex, sizeBlobIndex, 2);
            Offset        offset       = 0;

            byte[] contents = new byte[30];

            AssemblyMetadataTableRow row = new AssemblyMetadataTableRow(contents, offset, indexDetails);

            Assert.AreEqual(expected, offset.Current);
        }
Exemple #8
0
        public void FieldMarshal_WhenCreated_OffsetIsMovedOn()
        {
            byte[] contents = new byte[10];
            Offset offset   = 0;
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            FieldMarshalMetadataTableRow row = new FieldMarshalMetadataTableRow(contents, offset, resolver, indexDetails);

            Assert.AreEqual(4, offset.Current);
        }
        public void MemberRef_WhenCreated_OffsetIsMovedOn()
        {
            byte[] contents = new byte[10];
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);
            Offset offset = 0;

            MemberRefMetadataTableRow row = new MemberRefMetadataTableRow(contents, offset, resolver, indexDetails);

            Assert.AreEqual(6, offset.Current);
        }
        public void GenericConstraint_WhenCreated_OffsetIsMovedOn()
        {
            byte[] contents = new byte[10];
            Offset offset   = 0;
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            GenericParamConstraintMetadataTableRow row = new GenericParamConstraintMetadataTableRow(contents, offset, resolver, indexDetails);

            Assert.AreEqual(4, offset.Current);
        }
Exemple #11
0
        public void AssemblyRefOS_WhenCreated_OffsetIsMovedOn(byte sizeOfIndex, int expected)
        {
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(sizeOfIndex);
            Offset        offset       = 0;

            byte[] content = new byte[20];

            AssemblyRefOSMetadataTableRow row = new AssemblyRefOSMetadataTableRow(content, offset, indexDetails);

            Assert.AreEqual(expected, offset.Current);
        }
        public void AssemblyRef_WhenConstructedWithIndexSizes_OffsetIsMovedOn(byte blobIndex, byte stringIndex, int expected)
        {
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(2, stringIndex, blobIndex, 2);
            Offset        offset       = 0;

            byte[] content = new byte[30];

            AssemblyRefMetadataTableRow row = new AssemblyRefMetadataTableRow(content, offset, indexDetails);

            Assert.AreEqual(expected, offset.Current);
        }
Exemple #13
0
        public void ClassLayout_WhenCreated_OffsetIsMovedOn(byte indexSize, int expected)
        {
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(indexSize);
            Offset        offset       = 0;

            byte[] content = new byte[20];

            ClassLayoutMetadataTableRow row = new ClassLayoutMetadataTableRow(content, offset, indexDetails);

            Assert.AreEqual(expected, offset.Current);
        }
Exemple #14
0
        public void AssemblyRefProcessor_WhenCreated_ShouldMoveOffsetOn(byte sizeOfIndex, int expected)
        {
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(sizeOfIndex);

            byte[] content = new byte[30];
            Offset offset  = 0;

            AssemblyRefProcessorMetadataTableRow row = new AssemblyRefProcessorMetadataTableRow(content, offset, indexDetails);

            Assert.AreEqual(expected, offset.Current);
        }
Exemple #15
0
        public void FieldLayout_WhenCreated_OffsetIsMovedOn()
        {
            Offset offset = 0;

            byte[]        contents     = new byte[10];
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(2);

            FieldLayoutMetadataTableRow row = new FieldLayoutMetadataTableRow(contents, offset, indexDetails);

            Assert.AreEqual(6, offset.Current);
        }
Exemple #16
0
        public void DeclSecurity_WhenCreated_OffsetIsMovedOn(byte blobIndexSize, byte codedIndexSize, int expected)
        {
            byte[] content = new byte[20];
            Offset offset  = 0;
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(codedIndexSize);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2, 2, blobIndexSize, codedIndexSize);

            DeclSecurityMetadataTableRow row = new DeclSecurityMetadataTableRow(content, offset, resolver, indexDetails);

            Assert.AreEqual(expected, offset.Current);
        }
        public void Property_WhenCreated_OffsetIsMovedOn()
        {
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(2);

            byte[] contents = new byte[6];
            Offset offset   = 0;

            PropertyMetadataTableRow row = new PropertyMetadataTableRow(contents, offset, indexDetails);

            Assert.AreEqual(6, offset.Current);
        }
Exemple #18
0
        public void ModuleRef_WhenCreated_FieldsAreReadCorrectly()
        {
            byte[] contents = new byte[] {
                0x01, 0x00
            };
            Offset        offset       = 0;
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(2);

            ModuleRefMetadataTableRow row = new ModuleRefMetadataTableRow(contents, offset, indexDetails);

            Assert.AreEqual(1, row.Name.Value);
        }
        public void Constant_WhenCreated_OffsetIsMovedOn()
        {
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);
            Offset offset = 0;

            byte[] content = new byte[30];

            ConstantMetadataTableRow row = new ConstantMetadataTableRow(content, offset, resolver, indexDetails);

            Assert.AreEqual(6, offset.Current);
        }
        public void ExportedType_WhenCreated_OffsetIsMovedOn()
        {
            Offset offset = 0;

            byte[] contents = new byte[20];
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            ExportedTypeMetadataTableRow row = new ExportedTypeMetadataTableRow(contents, offset, resolver, indexDetails);

            Assert.AreEqual(14, offset.Current);
        }
Exemple #21
0
        public void Event_WhenCreated_MovesOffsetOn()
        {
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            byte[] contents = new byte[20];
            Offset offset   = 0;

            EventMetadataTableRow row = new EventMetadataTableRow(contents, offset, resolver, indexDetails);

            Assert.AreEqual(6, offset.Current);
        }
        public void ManifestResource_WhenCreated_OffsetIsMovedOn()
        {
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            byte[] contents = new byte[12];
            Offset offset   = 0;

            ManifestResourceMetadataTableRow row = new ManifestResourceMetadataTableRow(contents, offset, resolver, indexDetails);

            Assert.AreEqual(12, offset.Current);
        }
Exemple #23
0
        public void FieldLayout_WhenCreated_ReadFieldsCorrectly()
        {
            byte[] contents = new byte[] {
                0x01, 0x00, 0x00, 0x00,
                0x01, 0x00
            };
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(2);

            FieldLayoutMetadataTableRow row = new FieldLayoutMetadataTableRow(contents, 0, indexDetails);

            Assert.AreEqual(1, row.Offset);
            Assert.AreEqual(1, row.Field.Value);
        }
Exemple #24
0
        public void EventMap_WhenCreated_FieldsAreReadCorrectly()
        {
            byte[] contents = new byte[] {
                0x01, 0x00,
                0x05, 0x00
            };
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(2);

            EventMapMetadataTableRow row = new EventMapMetadataTableRow(contents, 0, indexDetails);

            Assert.AreEqual(1, row.Parent.Value);
            Assert.AreEqual(5, row.EventList.Value);
        }
Exemple #25
0
        public void AssemblyRefProcessor_WhenCreated_AllFieldsShouldBeZero()
        {
            byte[] content = new byte[] {
                0, 10, 0, 10,
                0, 10
            };
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(2);

            AssemblyRefProcessorMetadataTableRow row = new AssemblyRefProcessorMetadataTableRow(content, 0, indexDetails);

            Assert.AreEqual(0, row.Processor);
            Assert.AreEqual(0, row.AssemblyRef.Value);
        }
        public void CustomAttribute_WhenCreated_OffsetIsMovedOn(byte blobIndexSize, int codedIndexSize, int expected)
        {
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(codedIndexSize);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2, 2, blobIndexSize, 2);
            byte   sizeOfBlobIndexes         = blobIndexSize;
            Offset offset = 0;

            byte[] contents = new byte[10];

            CustomAttributeMetadataTableRow row = new CustomAttributeMetadataTableRow(contents, offset, resolver, indexDetails);

            Assert.AreEqual(expected, offset.Current);
        }
        public void TypeSpec_WhenCreated_FieldsAreReadCorrectly()
        {
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(2);

            byte[] contents = new byte[] {
                0x01, 0x00
            };
            Offset offset = 0;

            TypeSpecMetadataTableRow row = new TypeSpecMetadataTableRow(contents, offset, indexDetails);

            Assert.AreEqual(1, row.Signiture.Value);
        }
Exemple #28
0
        public void PropertyMap_WhenCreated_FieldsAreReadCorrectly()
        {
            byte[] contents = new byte[] {
                0x01, 0x00,
                0x02, 0x00
            };
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(2);
            Offset        offset       = 0;

            PropertyMapMetadataTableRow row = new PropertyMapMetadataTableRow(contents, offset, indexDetails);

            Assert.AreEqual(1, row.Parent.Value);
            Assert.AreEqual(2, row.PropertyList.Value);
        }
        public void NestedClass_WhenCreated_FieldsAreReadCorrectly()
        {
            byte[] contents = new byte[] {
                0x01, 0x00,
                0x02, 0x00
            };
            Offset        offset       = 0;
            IIndexDetails indexDetails = IndexHelper.CreateIndexDetails(2);

            NestedClassMetadataTableRow row = new NestedClassMetadataTableRow(contents, offset, indexDetails);

            Assert.AreEqual(1, row.NestedClass.Value);
            Assert.AreEqual(2, row.EnclosingClass.Value);
        }
        public void InterfaceImpl_WhenCreated_FieldsAreReadCorrectly()
        {
            byte[] contents = new byte[] {
                0x01, 0x00,
                0x00, 0x00
            };
            ICodedIndexResolver resolver     = IndexHelper.CreateCodedIndexResolver(2);
            IIndexDetails       indexDetails = IndexHelper.CreateIndexDetails(2);

            InterfaceImplMetadataTableRow row = new InterfaceImplMetadataTableRow(contents, 0, resolver, indexDetails);

            Assert.AreEqual(1, row.Class.Value);
            Assert.IsNotNull(row.Interface);
        }