public void WriteFailedOutOfRangeTest() { FRAM ram = new FRAM(10); byte[] data = { 0x12, 0x34, 0x56, 0x78 }; Assert.AreEqual(-2, ram.Write(data, 10, 4)); }
/*! * Writes data to the FRAM. * @param data Address where data to be written is stored. * @param address Location in the FRAM where data should be written. * @param size Number of bytes to write. * @return -2 if the specified address and size are out of range, * -1 if obtaining lock for FRAM access fails, * 0 on success. */ public int FRAM_write(byte[] data, uint address, uint size) { if (fram == null) { return(OBCConstants.ACCESS_ERROR); } return(fram.Write(data, (int)address, (int)size)); }
public void WriteSuccessTest() { FRAM ram = new FRAM(20); byte[] data = { 0x12, 0x34, 0x56, 0x78 }; Assert.AreNotEqual(0x12, ram.Memory[0]); Assert.AreEqual(0, ram.Write(data, 0, 4)); Assert.AreEqual(0x12, ram.Memory[0]); Assert.AreEqual(0x34, ram.Memory[1]); Assert.AreEqual(0x56, ram.Memory[2]); Assert.AreEqual(0x78, ram.Memory[3]); Assert.AreEqual(0, ram.Write(data, 10, 2)); Assert.AreEqual(0x12, ram.Memory[10]); Assert.AreEqual(0x34, ram.Memory[11]); Assert.AreNotEqual(0x56, ram.Memory[12]); Assert.AreNotEqual(0x78, ram.Memory[13]); }