Esempio n. 1
0
        public void TestOperators()
        {
            DVRPTRVersion a = new DVRPTRVersion(1, 6, 9, 'a', "Test");
            DVRPTRVersion b = new DVRPTRVersion(1, 6, 9, 'a', "Test");

            Assert.IsTrue(a == b, "a should equal b");
            Assert.IsTrue(a <= b, "a should equal b");
            Assert.IsTrue(a >= b, "a should equal b");
            Assert.IsFalse(a != b, "a should not be different b");

            a = new DVRPTRVersion(1, 6, 9, 'a', "Test");
            b = new DVRPTRVersion(1, 6, 9, 'b', "Test");
            Assert.IsTrue(a < b, "a should be lower than b");
            Assert.IsTrue(a != b, "a should be different b");

            a = new DVRPTRVersion(1, 6, 9, 'c', "Test");
            b = new DVRPTRVersion(1, 6, 9, 'a', "Test");
            Assert.IsTrue(a > b, "a should be greater than b");
            Assert.IsTrue(a != b, "a should be different b");

            a = new DVRPTRVersion(1, 6, 9, 'c', "Test");
            b = null;
            Assert.IsTrue(a > b, "a should be greater than b");
            Assert.IsTrue(a != b, "a should be different b");

            a = null;
            b = new DVRPTRVersion(1, 6, 9, 'a', "Test");
            Assert.IsTrue(a < b, "a should be lower than b");
            Assert.IsTrue(a != b, "a should be different b");

            a = null;
            b = null;
            Assert.IsTrue(a == b, "a should be greater than b");
            Assert.IsFalse(a != b, "a should NOT be different b");
        }
Esempio n. 2
0
        public void TestToString()
        {
            DVRPTRVersion a = new DVRPTRVersion(1, 6, 9, 'a', "Test");

            Assert.AreEqual("1.69a Test", a.ToString());

            DVRPTRVersion b = new DVRPTRVersion(1, 6, 9, '\0', "Test");

            Assert.AreEqual("1.69 Test", b.ToString());
        }
Esempio n. 3
0
        public void TestGetHashCode()
        {
            DVRPTRVersion a = new DVRPTRVersion(1, 6, 9, 'a', "Test");
            DVRPTRVersion b = new DVRPTRVersion(1, 6, 9, 'a', "Test");

            Assert.AreEqual(a.GetHashCode(), b.GetHashCode(), "a should equal b");

            a = new DVRPTRVersion(1, 6, 9, 'a', "Test");
            b = new DVRPTRVersion(1, 6, 8, 'p', "Test");
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode(), "a should NOT equal b");
        }
Esempio n. 4
0
        public void TestEquals()
        {
            DVRPTRVersion a = new DVRPTRVersion(1, 6, 9, 'a', "Test");
            DVRPTRVersion b = new DVRPTRVersion(1, 6, 9, 'a', "Test");

            Assert.IsTrue(a.Equals(b), "a should equal b");

            a = new DVRPTRVersion(1, 6, 9, 'a', "Test");
            b = new DVRPTRVersion(1, 6, 8, 'p', "Test");
            Assert.IsFalse(a.Equals(b), "a should NOT equal b");

            a = new DVRPTRVersion(1, 6, 9, 'a', "Test");
            b = null;
            Assert.IsFalse(a.Equals(b), "a should NOT equal null");
        }
Esempio n. 5
0
        public void TestGetVersion()
        {
            using (SerialPort serial = new SerialPort("/dev/ttyACM0"))
            {
                serial.Open();
                using (DVRPTR dvrptr = new DVRPTR(new PCP2DVRPTRio(serial.BaseStream, false)))
                {
                    dvrptr.TimeOut = TimeSpan.FromMilliseconds(-1);//this will give us infinite timeout so we can debug
                    dvrptr.Open();
                    DVRPTRVersion version = dvrptr.GetVersion();

                    Assert.IsNotNull(version, "version should not be null");
                    Console.WriteLine(version);
                }
            }
        }
Esempio n. 6
0
        public void TestCompareTo()
        {
            DVRPTRVersion a = new DVRPTRVersion(1, 6, 9, 'a', "Test");
            DVRPTRVersion b = new DVRPTRVersion(1, 6, 9, 'a', "Test");

            Assert.AreEqual(0, a.CompareTo(b), "a should equal b");

            a = new DVRPTRVersion(1, 6, 9, 'a', "Test");
            b = new DVRPTRVersion(1, 6, 9, '\0', "Test");
            Assert.AreEqual(1, a.CompareTo(b), "a should be greater than b");

            a = new DVRPTRVersion(1, 6, 9, 'a', "Test");
            b = new DVRPTRVersion(1, 6, 9, 'b', "Test");
            Assert.AreEqual(-1, a.CompareTo(b), "a should be smaller than b");

            a = new DVRPTRVersion(1, 6, 9, 'a', "Test");
            b = null;
            Assert.AreEqual(1, a.CompareTo(b), "a should be smaller than null");
        }