Wrote simple Strip test

This commit is contained in:
Lukasz Baldyga committed 2020-10-21 17:27:04 +01:00
1 parent 7e3aff9781
commit 90dc05f9f9
3 files changed
+53 -10

No files matched your search

@@ -14,4 +14,8 @@
<PackageReference Include="coverlet.collector" Version="1.2.0" /> <PackageReference Include="coverlet.collector" Version="1.2.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Advanced Software Engineering\Advanced Software Engineering.csproj" />
</ItemGroup>
</Project> </Project>
@@ -0,0 +1,49 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Advanced_Software_Engineering;
using System;
namespace Advanced_Software_Engineering_Tests {
[TestClass]
public class SettingsAndHelperFunctionsTester {
string alphabet = "abcdefghijklmnopqrstuvwxzy";
char space = " "[0];
[TestMethod]
public void TestStrip_Random1() {
Random rand = new Random();
for (int test = 0; test < 200; test++) {
int until = rand.Next(50);
string correctOutput = "";
for (int i = 0; i < until; i++) {
correctOutput += alphabet[rand.Next(alphabet.Length)];
}
string obfuscatedInput = correctOutput;
until = rand.Next(50);
for (int i = 0; i < until; i++) {
if (rand.Next(1) == 0) obfuscatedInput += space;
}
until = rand.Next(50);
for (int i = 0; i < until; i++) {
if (rand.Next(1) == 0) obfuscatedInput = space + obfuscatedInput;
}
Assert.AreEqual(correctOutput, SettingsAndHelperFunctions.Strip(obfuscatedInput));
}
}
[TestMethod]
public void TestStrip_Manual1() {
string input = " a simple sentence surrounded by spaces ";
string expected = "a simple sentence surrounded by spaces";
Assert.AreEqual(expected, SettingsAndHelperFunctions.Strip(input));
}
}
}
@@ -1,10 +0,0 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Advanced_Software_Engineering_Tests {
[TestClass]
public class UnitTest1 {
[TestMethod]
public void TestMethod1() {
}
}
}