public void T21_RandomWriteRead() { BlockStream blocks = new BlockStream(); blocks.CreateMemoryStream(); SimpleRandom random = new SimpleRandom(102854); int TestIterations = random.RandomInteger(100, 10000); Console.Out.WriteLine("Performing " + TestIterations.ToString() + " test iterations."); for (int TestNumber = 1; TestNumber <= TestIterations; TestNumber++) { int action = random.RandomInteger(0, 100); if (action < 50) // Insert { Hashtable tags = this.NewTestTags(TestNumber); byte[] bytes = this.NewTestBytes(TestNumber); blocks.WriteBlock(Guid.NewGuid(), tags, bytes); } else { List <Guid> ids = blocks.GetBlockIDs(); int ndx = random.RandomInteger(1, ids.Count); Guid id = ids[ndx - 1]; if (action < 75) // Update { Hashtable tags = this.NewTestTags(TestNumber); byte[] bytes = this.NewTestBytes(TestNumber); blocks.WriteBlock(id, tags, bytes); } else if (action <= 100) // Delete { blocks.DestroyBlock(id); } } } this.AssertIsValid(blocks); blocks.Compact(); this.AssertIsValid(blocks); return; }