/// <summary> /// Test the random number generation /// </summary> [Test] public void Test01_Random() { try { int rannum; string strrndnum; int lopcnt; int lopcnt1; bool usebase10; usebase10 = false; for (lopcnt1 = 0; lopcnt1 < 10; lopcnt1++) { for (lopcnt = 1; lopcnt < 7; lopcnt++) { rnd.SetMaxLength(lopcnt); rannum = rnd.GetRandomNumber(); strrndnum = NumberDisplay.CreateNumberString((uint)rannum, lopcnt, usebase10); if (strrndnum.Length != lopcnt) { throw new Exception("Strings not the correct length"); } } } } catch (Exception e) { Assert.AreEqual(66, 1, "UnExpected Failure. " + e.Message); } }
private void btnOK_Click(object sender, System.EventArgs e) { int rannum; int length; bool useBase10; // determine the base that we want to work in. if (rdobtn10.Checked) { useBase10 = true; } else { useBase10 = false; } if (txtRanlen.Text.Length == 0) { MessageBox.Show("Please Enter a valid Number", "Layout"); txtRanlen.Focus(); return; } try { length = Convert.ToInt32(txtRanlen.Text); rnd.SetMaxLength(length); } catch { MessageBox.Show("Please Enter a valid Number", "Layout"); txtRanlen.Focus(); return; } // get the random number rannum = rnd.GetRandomNumber(); if (rdobtn10.Checked) { txtRanNumber.Text = rannum.ToString("D"); } else { txtRanNumber.Text = rannum.ToString("X"); } txtRanNumStr.Text = NumberDisplay.CreateNumberString((uint)rannum, length, useBase10); }