public void generateTwoBytesFromThreeTest_InvalidIndex() { byte[] byteArray = { 0, 0xCA, 0x53, 4 }; int startIndex = 2; byte[] actual; actual = CNCRTools.generateTwoBytesFromThree(byteArray, startIndex); }
public void generateUInt16FromThreeBytesTest_ShortArray() { byte[] parityBytes = { 0, 170 }; int startIndex = 0; ushort actual; actual = CNCRTools.generateUInt16FromThreeBytes(parityBytes, startIndex); }
public void generateParityBitTest_Valid0() { byte serialByte = 232; byte serialByteExpected = 232; CNCRTools.generateParityBit(ref serialByte); Assert.AreEqual(serialByteExpected, serialByte); }
public void validateParityBitTest_Valid() { byte serialByte = 255; bool expected = true; bool actual; actual = CNCRTools.validateParityBit(serialByte); Assert.AreEqual(expected, actual); }
public void validateParityBytesTest_InvalidFinalByte() { byte[] serialBytes = { 3, 90, 0 }; bool expected = false; bool actual; actual = CNCRTools.validateParityBytes(serialBytes); Assert.AreEqual(expected, actual); }
public void getMsgLenFromTypeTest() { CNCRMSG_TYPE msgType = CNCRMSG_TYPE.MOVE; int expected = 11; int actual; actual = CNCRTools.getMsgLenFromType(msgType); Assert.AreEqual(expected, actual); }
public void validateParityBytesTest_Valid() { byte[] serialBytes = { 3, 90, 89 }; bool expected = true; bool actual; actual = CNCRTools.validateParityBytes(serialBytes); Assert.AreEqual(expected, actual); }
public void ToStringTest() { byte[] bytes = { 0xFF, 0x01 }; string expected = "FF01"; string actual; actual = CNCRTools.BytesToHex(bytes); Assert.AreEqual(expected, actual); }
public void generateUInt16FromThreeBytesTest_Valid() { byte[] parityBytes = { 0, 170, 170, 0 }; int startIndex = 1; ushort expected = 43690; ushort actual; actual = CNCRTools.generateUInt16FromThreeBytes(parityBytes, startIndex); Assert.AreEqual <ushort>(expected, actual); }
public void generateInt16FromThreeBytesTest_BadIndex() { byte[] parityBytes = { 0, 0x60, 0xA8, 4, 0 }; int startIndex = 3; short expected = 25000; short actual; actual = CNCRTools.generateInt16FromThreeBytes(parityBytes, startIndex); Assert.AreEqual(expected, actual); }
public void generateParityBitsTest1() { byte[] serialBytes = { 232, 0, 2, 254, 6 }; byte[] serialBytesExpected = { 232, 0, 3, 255, 6 }; CNCRTools.generateParityBits(ref serialBytes); for (int i = 0; i < serialBytesExpected.Length; i++) { Assert.AreEqual <byte>(serialBytesExpected[i], serialBytes[i]); } }
public void generateParityTest() { byte[] serialBytes = { 0x32, 0xFE, 0xBE, 0x06, 0 }; byte[] serialBytesExpected = { 0x33, 0xFF, 0xBE, 0x06, 0x74 }; CNCRTools.generateParity(ref serialBytes); for (int i = 0; i < serialBytesExpected.Length; i++) { Assert.AreEqual <byte>(serialBytesExpected[i], serialBytes[i]); } }
public void generateUInt16FromThreeBytesTest_ValidComplex() { //TODO: Validate this test. byte[] parityBytes = { 0, 0xCA, 0x53, 4 }; int startIndex = 1; ushort expected = 52050; ushort actual; actual = CNCRTools.generateUInt16FromThreeBytes(parityBytes, startIndex); Assert.AreEqual <ushort>(expected, actual); }
public void generateThreeBytesFromTwoTest() { byte[] bytes = { 0x52, 0xCB }; // 52050, result of Bitconvert.getBytes() byte[] expected = { 0xCA, 0x52, 4 }; byte[] actual; actual = CNCRTools.generateThreeBytesFromTwo(bytes); for (int i = 0; i < expected.Length; i++) { Assert.AreEqual <byte>(expected[i], actual[i]); } }
public void generateThreeBytesFromInt16Test() { short value = 25000; byte[] expected = { 0x60, 0xA8, 4 }; byte[] actual; actual = CNCRTools.generateThreeBytesFromInt16(value); for (int i = 0; i < expected.Length; i++) { Assert.AreEqual <byte>(expected[i], actual[i]); } }
public void getMsgFromBytesTest() { byte[] msgBytes = { 0x5C, 0x00, 0x2D, 0x05, 0x74 }; CNCRMessage expected = new CNCRMsgSetSpeed(msgBytes); CNCRMessage actual; actual = CNCRTools.getMsgFromBytes(msgBytes); Assert.AreEqual <CNCRMSG_TYPE>(expected.getMessageType(), actual.getMessageType()); Assert.AreEqual(((CNCRMsgSetSpeed)expected).isX(), ((CNCRMsgSetSpeed)actual).isX()); Assert.AreEqual(((CNCRMsgSetSpeed)expected).isY(), ((CNCRMsgSetSpeed)actual).isY()); Assert.AreEqual(((CNCRMsgSetSpeed)expected).isZ(), ((CNCRMsgSetSpeed)actual).isZ()); Assert.AreEqual(((CNCRMsgSetSpeed)expected).getSpeed(), ((CNCRMsgSetSpeed)actual).getSpeed()); }
public void generateTwoBytesFromThreeTest_Valid() { byte[] byteArray = { 0, 170, 170, 0 }; int startIndex = 1; byte[] expected = { 170, 170 }; byte[] actual; actual = CNCRTools.generateTwoBytesFromThree(byteArray, startIndex); for (int i = 0; i < expected.Length; i++) { Assert.AreEqual <byte>(expected[i], actual[i]); } }
public void generateTwoBytesFromThreeTest_InvalidComplex() { byte[] byteArray = { 0, 0xCA, 0x53, 4 }; int startIndex = 1; byte[] expected = { 0xCB, 0x52 }; byte[] actual; actual = CNCRTools.generateTwoBytesFromThree(byteArray, startIndex); for (int i = 0; i < expected.Length; i++) { Assert.AreNotEqual <byte>(expected[i], actual[i]); } }
public void GetBytesTest() { string hexString = "FF 01"; int discarded = 0; int discardedExpected = 1; byte[] expected = { 0xFF, 0x01 }; byte[] actual; actual = CNCRTools.GetBytes(hexString, out discarded); Assert.AreEqual(discardedExpected, discarded); for (int i = 0; i < expected.Length; i++) { Assert.AreEqual <byte>(expected[i], actual[i]); } }