/// <summary> /// Makes sure that the field will be returned properly when a /// non-escape byte, 0, is assigned to it. /// </summary> /// <param name="field">The field to test.</param> /// <param name="original">The transfer message to test.</param> public void ZeroTest(TxField field, Note original) { var target = (Note)original.Clone(); target[field] = 0; Assert.AreEqual(0, target.Bytes[(int)field]); }
/// <summary> /// Makes sure that the field will be stored as escaped or not /// escaped. The test is performed for all escape characters. /// </summary> /// <param name="field">The field to test.</param> /// <param name="original">The transfer message to test.</param> /// <param name="expectEscaped">Whether to expect it to be stored as /// escaped.</param> public void EscapeTest(TxField field, Note original, bool expectEscaped) { var target = (Note)original.Clone(); target[field] = Note._START; if (expectEscaped) { Assert.AreEqual(Note._START - 1, target.Bytes[(int)field]); } else { Assert.AreEqual(Note._START, target.Bytes[(int)field]); } target[field] = Note._END; if (expectEscaped) { Assert.AreEqual(Note._END - 1, target.Bytes[(int)field]); } else { Assert.AreEqual(Note._END, target.Bytes[(int)field]); } }
/// <summary> /// Helper method for <c>Escaping_Rx</c>. Used to help test every /// possible field. /// </summary> /// <param name="field">The field to test.</param> /// <param name="original">The transfer message to test.</param> /// <param name="expectEscaped">Whether escaping will be expected.</param> public void TestField(TxField field, Note original, bool expectEscaped) { ZeroTest(field, original); EscapeTest(field, original, expectEscaped); }