Example #1
0
        public void ESFRecord_DeserializeFromByteArray_HasCorrectData()
        {
            var numberEncoderService = new NumberEncoderService();
            var sourceRecord         = CreateRecordWithSomeGoodTestData();
            var sourceRecordBytes    = GetExpectedBytesWithoutNames(sourceRecord, numberEncoderService);

            var record = new ESFRecord {
                ID = sourceRecord.ID, Name = sourceRecord.Name, Shout = sourceRecord.Shout
            };

            record.DeserializeFromByteArray(sourceRecordBytes, numberEncoderService);

            var properties = record.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);

            Assert.IsTrue(properties.Length > 0);

            foreach (var property in properties)
            {
                var expectedValue = property.GetValue(sourceRecord);
                var actualValue   = property.GetValue(record);

                Assert.AreEqual(expectedValue, actualValue, "Property: {0}", property.Name);
            }
        }
Example #2
0
        public void ESFRecord_DeserializeFromByteArray_InvalidArrayLength_ThrowsException()
        {
            var record = new ESFRecord();

            Assert.Throws <ArgumentOutOfRangeException>(() => record.DeserializeFromByteArray(new byte[] { 1, 2, 3 }, new NumberEncoderService()));
        }