public void Constructor_RangeEndParameterLessThanRangeStart() { ArgumentException e = Assert.Throws <ArgumentException>(delegate { testUnflaggedNumberGenerator = new UnflaggedNumberGenerator(2, 1); }); Assert.That(e.Message, NUnit.Framework.Does.StartWith("Parameter 'rangeEnd' must be greater than or equal to parameter 'rangeStart'.")); Assert.AreEqual("rangeEnd", e.ParamName); }
public void GetHighestUnflaggedNumber() { testUnflaggedNumberGenerator = new UnflaggedNumberGenerator(1, 8); testUnflaggedNumberGenerator.FlagNumber(8); testUnflaggedNumberGenerator.FlagNumber(4); testUnflaggedNumberGenerator.FlagNumber(2); Tuple <Boolean, Int64> result = testUnflaggedNumberGenerator.GetHighestUnflaggedNumber(); Assert.AreEqual(true, result.Item1); Assert.AreEqual(7, result.Item2); }
public void GetHighestUnflaggedNumber_NoUnFlaggedNumbersExist() { testUnflaggedNumberGenerator = new UnflaggedNumberGenerator(1, 3); testUnflaggedNumberGenerator.FlagNumber(1); testUnflaggedNumberGenerator.FlagNumber(2); testUnflaggedNumberGenerator.FlagNumber(3); Tuple <Boolean, Int64> result = testUnflaggedNumberGenerator.GetHighestUnflaggedNumber(); Assert.AreEqual(false, result.Item1); Assert.AreEqual(0, result.Item2); }
public void FlagNumber_NumberParameterGreaterThanAllowedRange() { testUnflaggedNumberGenerator = new UnflaggedNumberGenerator(1, 5); ArgumentOutOfRangeException e = Assert.Throws <ArgumentOutOfRangeException>(delegate { testUnflaggedNumberGenerator.FlagNumber(6); }); Assert.That(e.Message, NUnit.Framework.Does.StartWith("Parameter 'number' with value 6 is greater than maximum of the range specified in the constructor (5).")); Assert.AreEqual("number", e.ParamName); }
public void Constructor_Int64MaxValueRange() { testUnflaggedNumberGenerator = new UnflaggedNumberGenerator(1, 9223372036854775807); Assert.AreEqual(1, testUnflaggedNumberGenerator.RangeStart); Assert.AreEqual(9223372036854775807, testUnflaggedNumberGenerator.RangeEnd); testUnflaggedNumberGenerator = new UnflaggedNumberGenerator(0, 9223372036854775806); testUnflaggedNumberGenerator = new UnflaggedNumberGenerator(-1, 9223372036854775805); testUnflaggedNumberGenerator = new UnflaggedNumberGenerator(-4611686018427387903, 4611686018427387903); testUnflaggedNumberGenerator = new UnflaggedNumberGenerator(-9223372036854775806, 0); testUnflaggedNumberGenerator = new UnflaggedNumberGenerator(-9223372036854775807, -1); testUnflaggedNumberGenerator = new UnflaggedNumberGenerator(-9223372036854775808, -2); }
public void FlagNumberIsFlagged() { testUnflaggedNumberGenerator = new UnflaggedNumberGenerator(1, 5); Assert.IsFalse(testUnflaggedNumberGenerator.IsFlagged(1)); Assert.IsFalse(testUnflaggedNumberGenerator.IsFlagged(2)); Assert.IsFalse(testUnflaggedNumberGenerator.IsFlagged(3)); Assert.IsFalse(testUnflaggedNumberGenerator.IsFlagged(4)); Assert.IsFalse(testUnflaggedNumberGenerator.IsFlagged(5)); testUnflaggedNumberGenerator.FlagNumber(1); Assert.IsTrue(testUnflaggedNumberGenerator.IsFlagged(1)); Assert.IsFalse(testUnflaggedNumberGenerator.IsFlagged(2)); Assert.IsFalse(testUnflaggedNumberGenerator.IsFlagged(3)); Assert.IsFalse(testUnflaggedNumberGenerator.IsFlagged(4)); Assert.IsFalse(testUnflaggedNumberGenerator.IsFlagged(5)); testUnflaggedNumberGenerator.FlagNumber(5); Assert.IsTrue(testUnflaggedNumberGenerator.IsFlagged(1)); Assert.IsFalse(testUnflaggedNumberGenerator.IsFlagged(2)); Assert.IsFalse(testUnflaggedNumberGenerator.IsFlagged(3)); Assert.IsFalse(testUnflaggedNumberGenerator.IsFlagged(4)); Assert.IsTrue(testUnflaggedNumberGenerator.IsFlagged(5)); testUnflaggedNumberGenerator.FlagNumber(3); Assert.IsTrue(testUnflaggedNumberGenerator.IsFlagged(1)); Assert.IsFalse(testUnflaggedNumberGenerator.IsFlagged(2)); Assert.IsTrue(testUnflaggedNumberGenerator.IsFlagged(3)); Assert.IsFalse(testUnflaggedNumberGenerator.IsFlagged(4)); Assert.IsTrue(testUnflaggedNumberGenerator.IsFlagged(5)); testUnflaggedNumberGenerator.FlagNumber(2); Assert.IsTrue(testUnflaggedNumberGenerator.IsFlagged(1)); Assert.IsTrue(testUnflaggedNumberGenerator.IsFlagged(2)); Assert.IsTrue(testUnflaggedNumberGenerator.IsFlagged(3)); Assert.IsFalse(testUnflaggedNumberGenerator.IsFlagged(4)); Assert.IsTrue(testUnflaggedNumberGenerator.IsFlagged(5)); }
public void GetHighestUnflaggedNumbers() { testUnflaggedNumberGenerator = new UnflaggedNumberGenerator(1, 8); testUnflaggedNumberGenerator.FlagNumber(2); testUnflaggedNumberGenerator.FlagNumber(5); testUnflaggedNumberGenerator.FlagNumber(6); var result = new List <Int64>(testUnflaggedNumberGenerator.GetHighestUnflaggedNumbers(1)); Assert.AreEqual(1, result.Count); Assert.AreEqual(8, result[0]); result = new List <Int64>(testUnflaggedNumberGenerator.GetHighestUnflaggedNumbers(3)); Assert.AreEqual(3, result.Count); Assert.AreEqual(8, result[0]); Assert.AreEqual(7, result[1]); Assert.AreEqual(4, result[2]); result = new List <Int64>(testUnflaggedNumberGenerator.GetHighestUnflaggedNumbers(5)); Assert.AreEqual(5, result.Count); Assert.AreEqual(8, result[0]); Assert.AreEqual(7, result[1]); Assert.AreEqual(4, result[2]); Assert.AreEqual(3, result[3]); Assert.AreEqual(1, result[4]); result = new List <Int64>(testUnflaggedNumberGenerator.GetHighestUnflaggedNumbers(6)); Assert.AreEqual(5, result.Count); Assert.AreEqual(8, result[0]); Assert.AreEqual(7, result[1]); Assert.AreEqual(4, result[2]); Assert.AreEqual(3, result[3]); Assert.AreEqual(1, result[4]); }
public void Constructor_RangeGreaterThanInt64MaxValue() { ArgumentException e = Assert.Throws <ArgumentException>(delegate { testUnflaggedNumberGenerator = new UnflaggedNumberGenerator(0, 9223372036854775807); }); Assert.That(e.Message, NUnit.Framework.Does.StartWith("The total inclusive range cannot exceed Int64.MaxValue.")); Assert.AreEqual("rangeEnd", e.ParamName); e = Assert.Throws <ArgumentException>(delegate { testUnflaggedNumberGenerator = new UnflaggedNumberGenerator(-1, 9223372036854775806); }); Assert.That(e.Message, NUnit.Framework.Does.StartWith("The total inclusive range cannot exceed Int64.MaxValue.")); Assert.AreEqual("rangeEnd", e.ParamName); e = Assert.Throws <ArgumentException>(delegate { testUnflaggedNumberGenerator = new UnflaggedNumberGenerator(-2, 9223372036854775805); }); Assert.That(e.Message, NUnit.Framework.Does.StartWith("The total inclusive range cannot exceed Int64.MaxValue.")); Assert.AreEqual("rangeEnd", e.ParamName); e = Assert.Throws <ArgumentException>(delegate { testUnflaggedNumberGenerator = new UnflaggedNumberGenerator(-4611686018427387903, 4611686018427387904); }); Assert.That(e.Message, NUnit.Framework.Does.StartWith("The total inclusive range cannot exceed Int64.MaxValue.")); Assert.AreEqual("rangeEnd", e.ParamName); e = Assert.Throws <ArgumentException>(delegate { testUnflaggedNumberGenerator = new UnflaggedNumberGenerator(-9223372036854775808, -1); }); Assert.That(e.Message, NUnit.Framework.Does.StartWith("The total inclusive range cannot exceed Int64.MaxValue.")); Assert.AreEqual("rangeEnd", e.ParamName); e = Assert.Throws <ArgumentException>(delegate { testUnflaggedNumberGenerator = new UnflaggedNumberGenerator(-9223372036854775807, 0); }); Assert.That(e.Message, NUnit.Framework.Does.StartWith("The total inclusive range cannot exceed Int64.MaxValue.")); Assert.AreEqual("rangeEnd", e.ParamName); e = Assert.Throws <ArgumentException>(delegate { testUnflaggedNumberGenerator = new UnflaggedNumberGenerator(-9223372036854775806, 1); }); Assert.That(e.Message, NUnit.Framework.Does.StartWith("The total inclusive range cannot exceed Int64.MaxValue.")); Assert.AreEqual("rangeEnd", e.ParamName); }