Private
Public Access
Converting to Linux new lines before final publish.
This commit is contained in:
1 parent
ab94e98508
commit
ea2360f2a6
667 files changed
+68755
-8530
No files matched your search
+65
-65
@@ -1,66 +1,66 @@
|
||||
using Advanced_Software_Engineering.Verbs.Value;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
|
||||
namespace Advanced_Software_Engineering_Tests {
|
||||
|
||||
/// <summary>
|
||||
/// This class tests <see cref="ValueHelper"/> methods. It uses a combination of manual and random tests.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
internal class ValueHelperTester {
|
||||
private readonly Random rand = new Random();
|
||||
|
||||
/// <summary>
|
||||
/// Random <see cref="ValueHelper.ConvertToInt(string)"/> test.
|
||||
/// </summary>
|
||||
[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));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Random <see cref="ValueHelper.ConvertToDouble(string)"/> test.
|
||||
/// </summary>
|
||||
[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));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Random <see cref="ValueHelper.ConvertToDouble(string)"/> test.
|
||||
/// </summary>
|
||||
[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));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Random <see cref="ValueHelper.ConvertToDouble(string)"/> test.
|
||||
/// </summary>
|
||||
[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));
|
||||
}
|
||||
}
|
||||
}
|
||||
using Advanced_Software_Engineering.Verbs.Value;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
|
||||
namespace Advanced_Software_Engineering_Tests {
|
||||
|
||||
/// <summary>
|
||||
/// This class tests <see cref="ValueHelper"/> methods. It uses a combination of manual and random tests.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
internal class ValueHelperTester {
|
||||
private readonly Random rand = new Random();
|
||||
|
||||
/// <summary>
|
||||
/// Random <see cref="ValueHelper.ConvertToInt(string)"/> test.
|
||||
/// </summary>
|
||||
[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));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Random <see cref="ValueHelper.ConvertToDouble(string)"/> test.
|
||||
/// </summary>
|
||||
[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));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Random <see cref="ValueHelper.ConvertToDouble(string)"/> test.
|
||||
/// </summary>
|
||||
[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));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Random <see cref="ValueHelper.ConvertToDouble(string)"/> test.
|
||||
/// </summary>
|
||||
[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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user