private void btnInjectTypeError_Click(object sender, EventArgs e) { int errorNumber = 13; int numberOfBit = HammingHelper.GetTotalSize(HammingHelper.HammingDataSplitNumber); if (numErrorCorrectible.Validate()) { for (int i = (int)numErrorCorrectible.Value; i > 0; --i) { cable.InsertRandomErrors(1, errorNumber * numberOfBit, (errorNumber + 1) * numberOfBit); ++errorNumber; } } if (numErrorDetectable.Validate()) { for (int i = (int)numErrorDetectable.Value; i > 0; --i) { cable.InsertRandomErrors(2, errorNumber * numberOfBit, (errorNumber + 1) * numberOfBit); ++errorNumber; } } if (numIrrecoverable.Validate()) { for (int i = (int)numIrrecoverable.Value; i > 0; --i) { cable.InsertRandomErrors(3, errorNumber * numberOfBit, (errorNumber + 1) * numberOfBit); ++errorNumber; } } }
public void When_random_errors_are_injected_Then_frame_is_altered() { const int nbErrors = 3; t.InsertRandomErrors(nbErrors, 0, 5); Assert.IsTrue(t.TransmitterReady(Constants.StationId.Station1)); t.SendData(data, Constants.StationId.Station1); Thread.Sleep(Constants.DefaultDelay * 200); var dataStation2 = t.GetData(Constants.StationId.Station2); Assert.IsTrue(data != dataStation2); BitArray xor = data.Xor(dataStation2); var nbBitSet = (from bool m in xor where m select m).Count(); Assert.IsTrue(nbBitSet == nbErrors); }