예제 #1
0
 public void OTFixedReadFixedTest2()
 {
     byte[] b = new byte[5] { 0, 1, 0x50, 0, 1 };
     MemoryStream ms = new MemoryStream(b);
     OTFixed expected = new OTFixed(1, 0x5000);
     OTFixed actual = new OTFixed();
     try
     {
         actual = OTFixed.ReadFixed(ms);
     }
     catch (Exception)
     {
         // unexpected exception
     }
     Assert.IsTrue(expected == actual, "Error: unexpected value read");
 }
예제 #2
0
        public void OTFixedReadFixedTest1()
        {
            bool caughtExpectedException = false; // will set to true if expected exception is caught

            byte[] b = new byte[1] { 0 };
            MemoryStream ms = new MemoryStream(b);
            try
            {
                OTFixed f = OTFixed.ReadFixed(ms);
            }
            catch (OTDataIncompleteReadException)
            {
                caughtExpectedException = true; // caught expected argument: test passes
            }
            catch (Exception)
            {
                // unexpected exception
            }
            Assert.IsTrue(caughtExpectedException, "Error: expected exception not caught");

            b = new byte[3] { 0, 1, 0 };
            ms = new MemoryStream(b);
            try
            {
                OTFixed f = OTFixed.ReadFixed(ms);
            }
            catch (OTDataTypeReadException)
            {
                caughtExpectedException = true; // caught expected argument: test passes
            }
            catch (Exception)
            {
                // unexpected exception
            }
            Assert.IsTrue(caughtExpectedException, "Error: expected exception not caught");
        }