public void SendIdentificationMessageDotNet()
        {
            // Write data -------------------------------------
            var request = new IdentificationMessage
            {
                ApplicationInstance = "123",
                ApplicationName = "MyApp",
                InterfaceName = "MyInterface",
                InterfaceVersion = 123,
                ApplicationVersion = new VersionDotNet { Version = new Version(1, 2, 3, 4), AdditionaInfo = "more written" }
            };

            _serializer.WriteMessage(_stream, request.WriteToBms1Stream);
            AssertBytesWritten(65);


            // Read and verify data ----------------------------------------
            _stream.Position = 0;
            Assert.AreEqual(2, _serializer.ReadMessageStart(_stream).BlockTypeId);
            var reply = _serializer.ReadMessage(IdentificationMessage.ReadFromBms1Stream);
            Assert.IsNotNull(reply);
            (request.ApplicationVersion as VersionDotNet).AdditionaInfo = "None"; // the AdditionaInfo is not read from stream
            AssertEqual(request, reply);
            Assert.AreEqual(65, _stream.Position);
        }
        public void SendIdentificationMessagePLC()
        {
            // Write data -------------------------------------
            var request = new IdentificationMessage
            {
                ApplicationInstance = "1234",
                ApplicationName = "MyApp2",
                InterfaceName = "MyInterface2",
                InterfaceVersion = 1234,
                ApplicationVersion = new VersionPLC { Version = "1.2.3.4", CpuType = CpuType.ArmCortexA5, AdditionaInfo = "more info" }
            };

            _serializer.WriteMessage(_stream, request.WriteToBms1Stream);
            AssertBytesWritten(56);


            // Read and verify data ----------------------------------------
            _stream.Position = 0;
            Assert.AreEqual(2, _serializer.ReadMessageStart(_stream).BlockTypeId);
            var reply = _serializer.ReadMessage(IdentificationMessage.ReadFromBms1Stream);
            Assert.IsNotNull(reply);
            (request.ApplicationVersion as VersionPLC).AdditionaInfo = "None"; // the AdditionaInfo is not written to stream
            AssertEqual(request, reply);
            Assert.AreEqual(56, _stream.Position);
        }
        public void AssertEqual(IdentificationMessage m1, IdentificationMessage m2)
        {
            Assert.AreEqual(m1.ApplicationInstance, m2.ApplicationInstance);
            Assert.AreEqual(m1.ApplicationName, m2.ApplicationName);
            Assert.AreEqual(m1.InterfaceName, m2.InterfaceName);
            Assert.AreEqual(m1.InterfaceVersion, m2.InterfaceVersion);

            var d1 = m1.ApplicationVersion as VersionDotNet;
            if (d1 != null)
            {
                var d2 = m2.ApplicationVersion as VersionDotNet;
                Assert.AreEqual(d1.Version, d2.Version);
            }
            else
            {
                var p1 = m1.ApplicationVersion as VersionPLC;
                var p2 = m2.ApplicationVersion as VersionPLC;
                Assert.AreEqual(p1.Version, p2.Version);
                Assert.AreEqual(p1.CpuType, p2.CpuType);
                Assert.AreEqual(p1.AdditionaInfo, p2.AdditionaInfo);
            }
        }