public void GetBinary_MinTruncates_Inclusive() { TestRandom rand = new TestRandom(); rand.ByteArrayQueue.Enqueue(new byte[] { 0, 1, 2 }); rand.IntQueue.Enqueue(2); CollectionAssert.AreEqual(new byte[] { 0, 1, 2 }, rand.GetBinary(3, 4)); }
public void GetBinary_MaxTruncates_Exclusive() { TestRandom rand = new TestRandom(); rand.ByteArrayQueue.Enqueue(new byte[] { 1, 2, 3, 4 }); rand.IntQueue.Enqueue(5); CollectionAssert.AreEqual(new byte[] { 1, 2, 3, 4 }, rand.GetBinary(3, 5)); }
public void GetBinaryTests(int min, int max, int length, byte[] data) { TestRandom rand = new TestRandom(); rand.ByteArrayQueue.Enqueue(data); rand.IntQueue.Enqueue(length); CollectionAssert.AreEqual(data, rand.GetBinary(min, max)); }
public void NextBytesReturnsTopOfBytesArrayQueue() { byte[] target = new byte[] { 0x1, 0x2, 0x3, 0x4 }; TestRandom rand = new TestRandom(); rand.ByteArrayQueue.Enqueue(target); byte[] result = new byte[4]; rand.NextBytes(result); CollectionAssert.AreEqual(target, result, "The two arrays should be the same."); }
public void GetSingle_MaxIsTruncated_Exclusive() { TestRandom rand = new TestRandom(); rand.ByteArrayQueue.Enqueue(System.BitConverter.GetBytes(10.0f)); Assert.AreEqual(9.0f, rand.GetSingle(5f, 10f)); }
public void GetInt64_MinIsTruncated_Inclusive() { TestRandom rand = new TestRandom(); rand.ByteArrayQueue.Enqueue(System.BitConverter.GetBytes(5L)); Assert.AreEqual(6L, rand.GetInt64(6, 10)); }
public void GetInt32_MinIsTruncated_Inclusive() { TestRandom rand = new TestRandom(); rand.IntQueue.Enqueue(5); Assert.AreEqual(6, rand.GetInt32(6, 10)); }
public void GetInt32(int target) { TestRandom rand = new TestRandom(); rand.IntQueue.Enqueue(target); Assert.AreEqual(target, rand.GetInt32()); }
public void NextPopsTheTopOfTheIntQueue() { TestRandom rand = new TestRandom(); rand.IntQueue.Enqueue(0); if(rand.IntQueue.Count != 1) Assert.Fail("Unable to determine the size of IntQueue."); rand.Next(); Assert.AreEqual(0, rand.IntQueue.Count, "The number of items left in IntQueue should be zero."); }
public void NextMinMaxTruncatesValueInIntQueueMin() { TestRandom rand = new TestRandom(); rand.IntQueue.Enqueue(-1); int minValue = 0; int result = rand.Next(minValue, 100); Assert.AreEqual(minValue, result, "The result should have been equal to minValue because the min value represents an inclusive lower bound."); }
public void NextMinMaxTruncatesValueInIntQueueMax() { TestRandom rand = new TestRandom(); rand.IntQueue.Enqueue(101); int maxValue = 100; int result = rand.Next(0, maxValue); Assert.AreEqual(maxValue - 1, result, "The result should have been (maxvalue - 1) because the max value represents an exclusive upper bound."); }
public void NextMinMaxReturnsNextItemInIntQueue() { TestRandom rand = new TestRandom(); rand.IntQueue.Enqueue(100); int result = rand.Next(0, 101); Assert.AreEqual(100, result); }
public void NextMinMaxPopsIntQueue() { TestRandom rand = new TestRandom(); rand.IntQueue.Enqueue(100); if(rand.IntQueue.Count != 1) Assert.Fail("Unable to determine the size of IntQueue."); rand.Next(0, 101); Assert.AreEqual(0, rand.IntQueue.Count, "The number of items in IntQueue should be zero."); }
public void NextDoubleReturnsTopOfDoubleQueue() { TestRandom rand = new TestRandom(); rand.DoubleQueue.Enqueue(1.1); Assert.AreEqual(1.1, rand.NextDouble(), "The result of NextDouble should have been the top of the DoubleQueue."); }
public void GetDecimal_MinIsTruncated_Inclusive() { TestRandom rand = new TestRandom(); foreach(var item in GetUsableDecimalBits(5m)) rand.IntQueue.Enqueue(item); Assert.AreEqual(6m, rand.GetDecimal(6m, 10m)); }
public void GetGuid(byte[] targetBytes) { System.Guid target = new System.Guid(targetBytes); TestRandom rand = new TestRandom(); rand.ByteArrayQueue.Enqueue(targetBytes); Assert.AreEqual(target, rand.GetGuid()); }
public void NextReturnsTopOfIntQueue() { TestRandom rand = new TestRandom(); rand.IntQueue.Enqueue(101); Assert.AreEqual(101, rand.Next(), "The result of Next should have been the top of the IntQueue"); }
public void GetInt32_MaxIsTruncated_Exclusive() { TestRandom rand = new TestRandom(); rand.IntQueue.Enqueue(10); Assert.AreEqual(9, rand.GetInt32(5, 10)); }
public void GetBoolean_True() { TestRandom rand = new TestRandom(); rand.IntQueue.Enqueue(1); Assert.IsTrue(rand.GetBoolean()); }
public void GetInt64_MaxIsTruncated_Exclusive() { TestRandom rand = new TestRandom(); rand.ByteArrayQueue.Enqueue(System.BitConverter.GetBytes(10L)); Assert.AreEqual(9L, rand.GetInt64(5, 10)); }
public void GetDateTime(System.DateTime target) { TestRandom rand = new TestRandom(); rand.ByteArrayQueue.Enqueue(System.BitConverter.GetBytes(target.Ticks)); Assert.AreEqual(target, rand.GetDateTime(System.DateTime.MinValue, System.DateTime.MaxValue)); }
public void GetSingle(System.Single target) { TestRandom rand = new TestRandom(); rand.ByteArrayQueue.Enqueue(System.BitConverter.GetBytes(target)); Assert.AreEqual(target, rand.GetSingle()); }
public void GetDateTime_MaxIsTruncated_Exclusive() { System.DateTime max = new System.DateTime(1000, 1, 1, 0, 0, 0, 1); System.DateTime target = new System.DateTime(max.Ticks - 1); TestRandom rand = new TestRandom(); rand.ByteArrayQueue.Enqueue(System.BitConverter.GetBytes(max.Ticks)); Assert.AreEqual(target, rand.GetDateTime(System.DateTime.MinValue, max)); }
public void GetSingle_MinIsTruncated_Inclusive() { TestRandom rand = new TestRandom(); rand.ByteArrayQueue.Enqueue(System.BitConverter.GetBytes(5.0f)); Assert.AreEqual(6.0f, rand.GetSingle(6f, 10f)); }
public void GetDateTime_MinIsTruncated_Inclusive() { System.DateTime min = new System.DateTime(1000, 1, 1, 0, 0, 0, 1); System.DateTime target = new System.DateTime(min.Year, min.Month, min.Day, min.Hour, min.Minute, min.Second, min.Millisecond - 1); TestRandom rand = new TestRandom(); rand.ByteArrayQueue.Enqueue(System.BitConverter.GetBytes(target.Ticks)); Assert.AreEqual(min, rand.GetDateTime(min, System.DateTime.MaxValue)); }
public void GetDecimal(System.Decimal target) { TestRandom rand = new TestRandom(); foreach(var item in GetUsableDecimalBits(target)) rand.IntQueue.Enqueue(item); Assert.AreEqual(target, rand.GetDecimal()); }
public void GetDecimalScaleMustBeBetween0And28Inclusive(int low, int mid, int high, int signed, int scale, int badScale) { TestRandom rand = new TestRandom(); rand.IntQueue.Enqueue(low); rand.IntQueue.Enqueue(mid); rand.IntQueue.Enqueue(high); rand.IntQueue.Enqueue(signed); rand.IntQueue.Enqueue(badScale); Assert.AreEqual(new System.Decimal(low, mid, high, (signed % 2) == 1, (byte)scale), rand.GetDecimal(), @" The two decimal values should be equal. "); }
public void GetBoolean_False() { TestRandom rand = new TestRandom(); rand.IntQueue.Enqueue(0); Assert.IsFalse(rand.GetBoolean()); }
public void NextBytesPopsTheTopOfTheBytesArrayQueue() { byte[] target = new byte[] { 0x1, 0x2, 0x3, 0x4 }; TestRandom rand = new TestRandom(); rand.ByteArrayQueue.Enqueue(target); if(rand.ByteArrayQueue.Count != 1) Assert.Fail("Unable to determine the size of ByteArrayQueue."); byte[] result = new byte[4]; rand.NextBytes(result); Assert.AreEqual(0, rand.ByteArrayQueue.Count, "The number of items left in ByteArrayQueue should be zero."); }