public void MtdImageTableRecordBuilderBuildMtdImageTableRecordAttributeNullTest()
        {
            MtdImageTableRecordBuilder   builder   = new MtdImageTableRecordBuilder();
            MtdImageTableRecordAttribute attribute = null;

            Assert.ThrowsException <AttributeNullException>(() => builder.Build(attribute));
        }
Пример #2
0
        public void MtdImageTableRecordCreateInvalidTest()
        {
            MtdImageTableRecordAttribute attribute = new MtdImageTableRecordAttribute {
                Name = GetRandomString(RANDOM.Next(65, 132))
            };
            MtdImageTableRecord record = new MtdImageTableRecord(attribute);

            Assert.ThrowsException <InvalidIconNameException>(() => record.GetBytes());
        }
Пример #3
0
 internal MtdImageTableRecord(MtdImageTableRecordAttribute attribute)
 {
     _name      = attribute.Name;
     _xPosition = attribute.XPosition;
     _yPosition = attribute.YPosition;
     _xExtend   = attribute.XExtend;
     _yExtend   = attribute.YExtend;
     _alpha     = attribute.Alpha;
 }
Пример #4
0
        public void MtdImageTableRecordCreateValidTest()
        {
            MtdImageTableRecordAttribute attribute = new MtdImageTableRecordAttribute {
                Name = GetRandomString(RANDOM.Next(1, 64))
            };
            MtdImageTableRecord record = new MtdImageTableRecord(attribute);

            Assert.IsNotNull(record);
            Assert.AreEqual(MTD_IMAGE_TABLE_RECORD_SIZE, record.GetBytes().Length);
        }
        public void MtdImageTableRecordBuilderBuildMtdImageTableRecordTest(string name, uint posX, uint posY, uint exX,
                                                                           uint exY, bool alpha)
        {
            List <byte> inputAsBytes = new List <byte>();

            byte[] n       = Encoding.ASCII.GetBytes(name);
            byte[] nPadded = new byte[64];
            for (int i = 0; i < nPadded.Length; i++)
            {
                nPadded[i] = 0;
            }

            for (int i = 0; i < n.Length && i < nPadded.Length; i++)
            {
                nPadded[i] = n[i];
            }

            inputAsBytes.AddRange(nPadded);
            inputAsBytes.AddRange(BitConverter.GetBytes(posX));
            inputAsBytes.AddRange(BitConverter.GetBytes(posY));
            inputAsBytes.AddRange(BitConverter.GetBytes(exX));
            inputAsBytes.AddRange(BitConverter.GetBytes(exY));
            inputAsBytes.AddRange(BitConverter.GetBytes(alpha));
            byte[] inAsByteArray = inputAsBytes.ToArray();

            MtdImageTableRecordBuilder   builder   = new MtdImageTableRecordBuilder();
            MtdImageTableRecordAttribute attribute = new MtdImageTableRecordAttribute
            {
                Name      = name,
                XPosition = posX,
                YPosition = posY,
                XExtend   = exX,
                YExtend   = exY,
                Alpha     = alpha
            };
            MtdImageTableRecord record          = builder.Build(attribute);
            MtdImageTableRecord recordFromBytes = builder.Build(inAsByteArray);

            byte[] bytesFromAttributes = record.GetBytes();
            byte[] bytesFromBytes      = recordFromBytes.GetBytes();
            Assert.IsNotNull(bytesFromAttributes);
            Assert.IsNotNull(bytesFromBytes);
            Assert.AreEqual(MTD_IMAGE_TABLE_RECORD_SIZE, bytesFromAttributes.Length);
            Assert.AreEqual(MTD_IMAGE_TABLE_RECORD_SIZE, bytesFromBytes.Length);
            for (int i = 0; i < bytesFromAttributes.Length; i++)
            {
                Assert.AreEqual(bytesFromAttributes[i], inAsByteArray[i]);
            }

            for (int i = 0; i < bytesFromBytes.Length; i++)
            {
                Assert.AreEqual(bytesFromBytes[i], inAsByteArray[i]);
            }
        }