using Advanced_Software_Engineering.Verbs.Value; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; namespace Advanced_Software_Engineering_Tests { /// /// This class tests methods. It uses a combination of manual and random tests. /// [TestClass] internal class ValueHelperTester { private readonly Random rand = new Random(); /// /// Random test. /// [TestMethod] public void ConvertToInt_Random1() { for (int i = 0; i < 100000; i++) { int expected = rand.Next(int.MinValue, int.MaxValue); string input = expected.ToString(); Assert.AreEqual(expected, ValueHelper.ConvertToInt(input)); } } /// /// Random test. /// [TestMethod] public void ConvertToDouble_Random1() { for (int i = 0; i < 100000; i++) { double expected = rand.NextDouble(); string input = expected.ToString(); Assert.AreEqual(expected, ValueHelper.ConvertToDouble(input)); } } /// /// Random test. /// [TestMethod] public void ConvertToDouble_Random2() { for (int i = 0; i < 100000; i++) { double expected = rand.Next(100, 100) * rand.NextDouble(); string input = expected.ToString(); Assert.AreEqual(expected, ValueHelper.ConvertToDouble(input)); } } /// /// Random test. /// [TestMethod] public void ConvertToDouble_Random3() { for (int i = 0; i < 100000; i++) { int expected = rand.Next(100, 100); string input = ((double)expected).ToString(); Assert.AreEqual((double)expected, ValueHelper.ConvertToDouble(input)); } } } }