private void PerformMutationOp() { int outcome = DiscreteDistribution.Sample(_rng, _opDistribution); switch (outcome) { case 0: // Write. { PerformMutationOp_Write(); break; } case 1: // Write byte. { byte b = (byte)_rng.Next(); _strmA.WriteByte(b); _strmB.WriteByte(b); Debug.WriteLine("WriteByte"); break; } case 2: // Change read/write head position. { PerformMutationOp_Position(); break; } case 3: // SetLength { PerformMutationOp_SetLength(); break; } case 4: // Seek { PerformMutationOp_Seek(); break; } case 5: // Trim { _strmB.Trim(); Debug.WriteLine("Trim"); break; } case 6: // Read byte. { int a = _strmA.ReadByte(); int b = _strmB.ReadByte(); if (a != b) { throw new Exception("ReadByte mismatch"); } Debug.WriteLine("ReadByte"); break; } case 7: // Read { int len = _rng.Next(20000); byte[] abuf = new byte[len]; byte[] bbuf = new byte[len]; int alen = _strmA.Read(abuf, 0, len); int blen = _strmB.Read(bbuf, 0, len); if (alen != blen) { throw new Exception("Read mismatch"); } if (!Utils.AreEqual(abuf, bbuf)) { throw new Exception("Read mismatch"); } Debug.WriteLine("Read"); break; } } }