Private
Public Access
Renamed SettingsAndHelperFunctions to HelperFunctions
This commit is contained in:
1 parent
b290848034
commit
e6722273a5
7 files changed
+18
-18
No files matched your search
+10
-10
@@ -31,7 +31,7 @@ namespace Advanced_Software_Engineering_Tests {
|
|||||||
|
|
||||||
obfuscatedInput = RandomSpaces() + obfuscatedInput + RandomSpaces();
|
obfuscatedInput = RandomSpaces() + obfuscatedInput + RandomSpaces();
|
||||||
|
|
||||||
Assert.AreEqual(correctOutput, SettingsAndHelperFunctions.Strip(obfuscatedInput));
|
Assert.AreEqual(correctOutput, HelperFunctions.Strip(obfuscatedInput));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ namespace Advanced_Software_Engineering_Tests {
|
|||||||
string input = " a simple sentence surrounded by spaces ";
|
string input = " a simple sentence surrounded by spaces ";
|
||||||
string expected = "a simple sentence surrounded by spaces";
|
string expected = "a simple sentence surrounded by spaces";
|
||||||
|
|
||||||
Assert.AreEqual(expected, SettingsAndHelperFunctions.Strip(input));
|
Assert.AreEqual(expected, HelperFunctions.Strip(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -54,7 +54,7 @@ namespace Advanced_Software_Engineering_Tests {
|
|||||||
string input = " a simple sentence surrounded by spaces ";
|
string input = " a simple sentence surrounded by spaces ";
|
||||||
string expected = "a simple sentence surrounded by spaces";
|
string expected = "a simple sentence surrounded by spaces";
|
||||||
|
|
||||||
Assert.AreEqual(expected, SettingsAndHelperFunctions.Strip(input));
|
Assert.AreEqual(expected, HelperFunctions.Strip(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -66,7 +66,7 @@ namespace Advanced_Software_Engineering_Tests {
|
|||||||
string[] expected = (new List<string> { "a", "test", "t", "asdf" }).ToArray();
|
string[] expected = (new List<string> { "a", "test", "t", "asdf" }).ToArray();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (string s in SettingsAndHelperFunctions.StripStringArray(input)) {
|
foreach (string s in HelperFunctions.StripStringArray(input)) {
|
||||||
Assert.AreEqual(expected[i++], s);
|
Assert.AreEqual(expected[i++], s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,7 +80,7 @@ namespace Advanced_Software_Engineering_Tests {
|
|||||||
string[] expected = (new List<string> { "a", "simple", "sentence", "surrounded", "by", "spaces" }).ToArray();
|
string[] expected = (new List<string> { "a", "simple", "sentence", "surrounded", "by", "spaces" }).ToArray();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (string s in SettingsAndHelperFunctions.StripStringArray(input)) {
|
foreach (string s in HelperFunctions.StripStringArray(input)) {
|
||||||
Assert.AreEqual(expected[i++], s);
|
Assert.AreEqual(expected[i++], s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ namespace Advanced_Software_Engineering_Tests {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CommandAndParameterParser_Manual1() {
|
public void CommandAndParameterParser_Manual1() {
|
||||||
Dictionary<string, string[]> commands = SettingsAndHelperFunctions.CommandAndParameterParser("moveto 200, 200");
|
Dictionary<string, string[]> commands = HelperFunctions.CommandAndParameterParser("moveto 200, 200");
|
||||||
Assert.AreEqual("moveto", commands["command"][0]);
|
Assert.AreEqual("moveto", commands["command"][0]);
|
||||||
Assert.AreEqual("200", commands["parameters"][0]);
|
Assert.AreEqual("200", commands["parameters"][0]);
|
||||||
Assert.AreEqual("200", commands["parameters"][1]);
|
Assert.AreEqual("200", commands["parameters"][1]);
|
||||||
@@ -101,7 +101,7 @@ namespace Advanced_Software_Engineering_Tests {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CommandAndParameterParser_Manual2() {
|
public void CommandAndParameterParser_Manual2() {
|
||||||
Dictionary<string, string[]> commands = SettingsAndHelperFunctions.CommandAndParameterParser("clear");
|
Dictionary<string, string[]> commands = HelperFunctions.CommandAndParameterParser("clear");
|
||||||
Assert.AreEqual("clear", commands["command"][0]);
|
Assert.AreEqual("clear", commands["command"][0]);
|
||||||
Assert.IsFalse(commands.Keys.Contains("parameters"));
|
Assert.IsFalse(commands.Keys.Contains("parameters"));
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ namespace Advanced_Software_Engineering_Tests {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CommandAndParameterParser_Manual3() {
|
public void CommandAndParameterParser_Manual3() {
|
||||||
Dictionary<string, string[]> commands = SettingsAndHelperFunctions.CommandAndParameterParser("");
|
Dictionary<string, string[]> commands = HelperFunctions.CommandAndParameterParser("");
|
||||||
Assert.IsFalse(commands.Keys.Contains("command"));
|
Assert.IsFalse(commands.Keys.Contains("command"));
|
||||||
Assert.IsFalse(commands.Keys.Contains("parameters"));
|
Assert.IsFalse(commands.Keys.Contains("parameters"));
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ namespace Advanced_Software_Engineering_Tests {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void CommandAndParameterParser_Manual4() {
|
public void CommandAndParameterParser_Manual4() {
|
||||||
Dictionary<string, string[]> commands = SettingsAndHelperFunctions.CommandAndParameterParser(" genericCommand 2, 3,4 5");
|
Dictionary<string, string[]> commands = HelperFunctions.CommandAndParameterParser(" genericCommand 2, 3,4 5");
|
||||||
|
|
||||||
Assert.AreEqual("genericCommand", commands["command"][0]);
|
Assert.AreEqual("genericCommand", commands["command"][0]);
|
||||||
Assert.AreEqual("2", commands["parameters"][0]);
|
Assert.AreEqual("2", commands["parameters"][0]);
|
||||||
@@ -153,7 +153,7 @@ namespace Advanced_Software_Engineering_Tests {
|
|||||||
input += RandomSpaces() + parameter + RandomSpaces() + "," + RandomSpaces();
|
input += RandomSpaces() + parameter + RandomSpaces() + "," + RandomSpaces();
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<string, string[]> commands = SettingsAndHelperFunctions.CommandAndParameterParser(input);
|
Dictionary<string, string[]> commands = HelperFunctions.CommandAndParameterParser(input);
|
||||||
|
|
||||||
Assert.AreEqual(command, commands["command"][0]);
|
Assert.AreEqual(command, commands["command"][0]);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -142,7 +142,7 @@
|
|||||||
<Compile Include="Windows\TextEditor.Designer.cs">
|
<Compile Include="Windows\TextEditor.Designer.cs">
|
||||||
<DependentUpon>TextEditor.cs</DependentUpon>
|
<DependentUpon>TextEditor.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="SettingsAndHelperFunctions.cs" />
|
<Compile Include="HelperFunctions.cs" />
|
||||||
<Compile Include="Windows\Menu.cs">
|
<Compile Include="Windows\Menu.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// This class simply provides settings and some functions that are used across many components.
|
/// This class simply provides settings and some functions that are used across many components.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SettingsAndHelperFunctions {
|
public class HelperFunctions {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This function removes spaces from the start and the end of the text. This should be unit tested.
|
/// This function removes spaces from the start and the end of the text. This should be unit tested.
|
||||||
+1
-1
@@ -60,7 +60,7 @@ namespace Advanced_Software_Engineering.Verbs.Value {
|
|||||||
// bools have ==
|
// bools have ==
|
||||||
if (!(type == "bool")) {
|
if (!(type == "bool")) {
|
||||||
//Seperate the assignment from the variables
|
//Seperate the assignment from the variables
|
||||||
List<string> assignmentList = SettingsAndHelperFunctions.StripStringArray(assignment.Split("="[0]));
|
List<string> assignmentList = HelperFunctions.StripStringArray(assignment.Split("="[0]));
|
||||||
name = assignmentList[0];
|
name = assignmentList[0];
|
||||||
value = ValueFactory.CreateValue(assignmentList[1], type);
|
value = ValueFactory.CreateValue(assignmentList[1], type);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+1
-1
@@ -61,7 +61,7 @@ namespace Advanced_Software_Engineering.Verbs.Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static IValue CreateValue(Drawer drawer, string value) {
|
public static IValue CreateValue(Drawer drawer, string value) {
|
||||||
value = SettingsAndHelperFunctions.Strip(value);
|
value = HelperFunctions.Strip(value);
|
||||||
if (drawer.CheckVariableExists(value)) return new VariableValue(drawer, value);
|
if (drawer.CheckVariableExists(value)) return new VariableValue(drawer, value);
|
||||||
else return ValueHelper.ConvertToIValue(value);
|
else return ValueHelper.ConvertToIValue(value);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -14,7 +14,7 @@ namespace Advanced_Software_Engineering.Verbs.Value {
|
|||||||
/// <param name="text">String to be converted to int</param>
|
/// <param name="text">String to be converted to int</param>
|
||||||
/// <returns>Integer representation of string</returns>
|
/// <returns>Integer representation of string</returns>
|
||||||
public static int ConvertToInt(string text) {
|
public static int ConvertToInt(string text) {
|
||||||
text = SettingsAndHelperFunctions.Strip(text);
|
text = HelperFunctions.Strip(text);
|
||||||
return int.Parse(text);
|
return int.Parse(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ namespace Advanced_Software_Engineering.Verbs.Value {
|
|||||||
/// <param name="text">String to be converted to double</param>
|
/// <param name="text">String to be converted to double</param>
|
||||||
/// <returns>Double representation of string</returns>
|
/// <returns>Double representation of string</returns>
|
||||||
public static double ConvertToDouble(string text) {
|
public static double ConvertToDouble(string text) {
|
||||||
text = SettingsAndHelperFunctions.Strip(text);
|
text = HelperFunctions.Strip(text);
|
||||||
return double.Parse(text);
|
return double.Parse(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ namespace Advanced_Software_Engineering.Verbs.Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static IValue ConvertToIValue(string text) {
|
public static IValue ConvertToIValue(string text) {
|
||||||
text = SettingsAndHelperFunctions.Strip(text);
|
text = HelperFunctions.Strip(text);
|
||||||
//No assignmnet
|
//No assignmnet
|
||||||
if (!text.Contains("=")) {
|
if (!text.Contains("=")) {
|
||||||
if (!text.Contains("#")) {
|
if (!text.Contains("#")) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
/// <param name="fullCommand">The command as a string</param>
|
/// <param name="fullCommand">The command as a string</param>
|
||||||
/// <returns>A IVerb that maches the command</returns>
|
/// <returns>A IVerb that maches the command</returns>
|
||||||
public static IVerb MakeVerb(Drawer drawer, string fullCommand) {
|
public static IVerb MakeVerb(Drawer drawer, string fullCommand) {
|
||||||
CommandAndParameterParserResult result = SettingsAndHelperFunctions.CommandAndParameterParser(fullCommand);
|
CommandAndParameterParserResult result = HelperFunctions.CommandAndParameterParser(fullCommand);
|
||||||
|
|
||||||
string command = result.getCommand();
|
string command = result.getCommand();
|
||||||
string[] commandParameters = result.getParameters();
|
string[] commandParameters = result.getParameters();
|
||||||
|
|||||||
Reference in new issue
Block a user