public void TestInitialize()
 {
     s_defaultRecord = new MtdImageTableRecord(Constants.DEFAULT_TEST_RECORD_NAME,
                                               Constants.DEFAULT_TEST_RECORD_X_POSITION,
                                               Constants.DEFAULT_TEST_RECORD_Y_POSITION, Constants.DEFAULT_TEST_RECORD_X_EXTEND,
                                               Constants.DEFAULT_TEST_RECORD_Y_EXTEND,
                                               Constants.DEFAULT_TEST_RECORD_ALPHA);
 }
Exemplo n.º 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());
        }
Exemplo n.º 3
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 Ctor_Test__IsBinaryEquivalentToExpected()
 {
     byte[] actual = new MtdImageTableRecord(Constants.DEFAULT_TEST_RECORD_NAME,
                                             Constants.DEFAULT_TEST_RECORD_X_POSITION,
                                             Constants.DEFAULT_TEST_RECORD_Y_POSITION, Constants.DEFAULT_TEST_RECORD_X_EXTEND,
                                             Constants.DEFAULT_TEST_RECORD_Y_EXTEND,
                                             Constants.DEFAULT_TEST_RECORD_ALPHA).ToBytes();
     Assert.AreEqual(Constants.OBJECT_SIZE_IN_BYTE, actual.Length);
     TestUtility.AssertAreBinaryEquivalent(Constants.EXPECTED_MTD_IMAGE_TABLE_RECORD_AS_BYTES, actual);
 }
        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]);
            }
        }
        public void MtdImageTableRecordBuilderTest()
        {
            string s = Path.Combine(Directory.GetCurrentDirectory(), MTD_RECORD);

            byte[] array = File.ReadAllBytes(Path.Combine(Directory.GetCurrentDirectory(), MTD_RECORD));
            MtdImageTableRecordBuilder builder = new MtdImageTableRecordBuilder();
            MtdImageTableRecord        e       = builder.Build(array);

            Assert.IsNotNull(e);
            Assert.IsNotNull(e.GetBytes());
            Assert.AreEqual(MTD_IMAGE_TABLE_RECORD_SIZE, e.GetBytes().Length);
        }
 public void Ctor_Test__ThrowsInvalidIconNameException()
 {
     MtdImageTableRecord _ =
         new MtdImageTableRecord(TestUtility.GetRandomStringOfLength(128), 0, 0, 0, 0, false);
 }
 public void Ctor_Test__ThrowsArgumentException(string inputName)
 {
     MtdImageTableRecord _ = new MtdImageTableRecord(inputName, 0, 0, 0, 0, false);
 }