示例#1
0
 public void ReadValueWrongFormatTest()
 {
     TestDataEntity _data = new TestDataEntity()
     {
         Tags = GetData(), TimeStamp = DateTime.Now
     };
     ReadDataEntity _instance = new ReadDataEntity(_data, new Block());
     object         _value    = _instance.ReadValue(0, typeof(float));
 }
示例#2
0
 public void ReadValueShortFormatExceptionTest()
 {
     TestDataEntity _data = new TestDataEntity()
     {
         Tags = GetData(), TimeStamp = DateTime.Now
     };
     ReadDataEntity _instance = new ReadDataEntity(_data, new Block());
     object         _value    = _instance.ReadValue(2, typeof(short));
 }
示例#3
0
        public void ReadValueShortOverflowExceptionTest()
        {
            TestDataEntity _data = new TestDataEntity()
            {
                Tags = GetData(), TimeStamp = DateTime.Now
            };

            _data.Tags[7] = "33000";
            ReadDataEntity _instance = new ReadDataEntity(_data, new Block());
            object         _value    = _instance.ReadValue(3, typeof(short));
        }
示例#4
0
        public void InPoolTestMethod()
        {
            TestDataEntity _data = new TestDataEntity()
            {
                Tags = new string[8], TimeStamp = DateTime.Now
            };
            ReadDataEntity _instance = new ReadDataEntity(_data, new Block());

            Assert.IsFalse(_instance.InPool);
            _instance.InPool = true;
            Assert.IsFalse(_instance.InPool);
        }
示例#5
0
        public void ReadValueShortTest()
        {
            TestDataEntity _data = new TestDataEntity()
            {
                Tags = GetData(), TimeStamp = DateTime.Now
            };
            ReadDataEntity _instance = new ReadDataEntity(_data, new Block());
            object         _value    = _instance.ReadValue(3, typeof(short));

            Assert.IsTrue(_value is short);
            Assert.AreEqual <long>(1368, (short)_value);
        }
示例#6
0
        public void ConstructorTestMethod()
        {
            TestDataEntity _data = new TestDataEntity()
            {
                Tags = new string[8], TimeStamp = DateTime.Now
            };
            ReadDataEntity _instance = new ReadDataEntity(_data, new Block());

            _instance.ReturnEmptyEnvelope(); //do nothing
            Assert.AreEqual(4, _instance.length);
            Assert.AreEqual(0, _instance.dataType);
            Assert.IsFalse(_instance.InPool);
            Assert.AreEqual(4, _instance.startAddress);
        }
示例#7
0
        public void ReadValueFloatTest()
        {
            TestDataEntity _data = new TestDataEntity()
            {
                Tags = GetData(), TimeStamp = DateTime.Now
            };
            ReadDataEntity _instance = new ReadDataEntity(_data, new Block());
            object         _value    = _instance.ReadValue(2, typeof(float));

            Assert.IsTrue(_value is float);
            Assert.AreEqual <float>(26.9f, (float)_value);
            _value = _instance.ReadValue(3, typeof(float));
            Assert.IsTrue(_value is float);
            Assert.AreEqual <float>(1368f, (float)_value);
        }
示例#8
0
        public void IsInBlockTestMethod()
        {
            TestDataEntity _data = new TestDataEntity()
            {
                Tags = new string[8], TimeStamp = DateTime.Now
            };
            ReadDataEntity _instance = new ReadDataEntity(_data, new Block());

            Assert.IsTrue(_instance.IsInBlock(0, 4, 0));
            Assert.IsTrue(_instance.IsInBlock(0, 7, 0));
            Assert.IsFalse(_instance.IsInBlock(0, 0, 0));
            Assert.IsFalse(_instance.IsInBlock(0, 3, 0));
            Assert.IsFalse(_instance.IsInBlock(0, 8, 0));
            Assert.IsFalse(_instance.IsInBlock(0, 10, 0));
            Assert.IsFalse(_instance.IsInBlock(0, 0, 1));
            Assert.IsFalse(_instance.IsInBlock(1, 0, 0));
        }
示例#9
0
        public void ReadValueStringTest()
        {
            TestDataEntity _data = new TestDataEntity()
            {
                Tags = GetData(), TimeStamp = DateTime.Now
            };
            ReadDataEntity _instance = new ReadDataEntity(_data, new Block());
            object         _value    = _instance.ReadValue(0, typeof(string));

            Assert.IsTrue(_value is string);
            Assert.AreEqual <string>("09-12-16", (string)_value);
            _value = _instance.ReadValue(1, typeof(string));
            Assert.IsTrue(_value is string);
            Assert.AreEqual <string>("09:24:02", (string)_value);
            _value = _instance.ReadValue(2, typeof(string));
            Assert.IsTrue(_value is string);
            Assert.AreEqual <string>("26.9", (string)_value);
            _value = _instance.ReadValue(3, typeof(string));
            Assert.IsTrue(_value is string);
            Assert.AreEqual <string>("1368", (string)_value);
        }