From ab94e9850809db9b9833e07528cd0cfb1d358ea1 Mon Sep 17 00:00:00 2001 From: Lukasz Baldyga Date: Mon, 7 Dec 2020 17:38:16 +0000 Subject: [PATCH] Fixed Tests --- .../Advanced Software Engineering Tests.xml | 167 +++++++++--------- .../CommandTester.cs | 22 +-- ...ionsTester.cs => HelperFunctionsTester.cs} | 60 ++++--- 3 files changed, 113 insertions(+), 136 deletions(-) rename Advanced Software Engineering/Advanced Software Engineering Tests/{SettingsAndHelperFunctionsTester.cs => HelperFunctionsTester.cs} (64%) diff --git a/Advanced Software Engineering/Advanced Software Engineering Tests/Advanced Software Engineering Tests.xml b/Advanced Software Engineering/Advanced Software Engineering Tests/Advanced Software Engineering Tests.xml index 7b0f5f1..f441701 100644 --- a/Advanced Software Engineering/Advanced Software Engineering Tests/Advanced Software Engineering Tests.xml +++ b/Advanced Software Engineering/Advanced Software Engineering Tests/Advanced Software Engineering Tests.xml @@ -29,107 +29,102 @@ - tests the "move" command. See . + tests the "move" command. See . - tests the "moveto" command. See . + tests the "moveto" command. See . - tests the "drawto" command. See . + tests the "drawto" command. See . - tests the "line" command. See . + tests the "line" command. See . - tests the "lineto" command. See . + tests the "lineto" command. See . - tests the "regularpolygon" command. See . + tests the "regularpolygon" command. See . - tests the "rp" command. See . + tests the "rp" command. See . - tests the "regularpolygon" command. See . + tests the "regularpolygon" command. See . - tests the "rp" command. See . + tests the "rp" command. See . - tests the "square" command. See . + tests the "square" command. See . - tests the "square" command. See . - - - - - tests the "quadrilateral" command using . See . + tests the "square" command. See . - Tests the "circle" command. See . + Tests the "circle" command. See . - tests the "triangle" command. See . + tests the "triangle" command. See . - tests the "triangle" command. See . + tests the "triangle" command. See . - test the "dot" command. See . + test the "dot" command. See . - tests the "clear" command. See . + tests the "clear" command. See . - Tests the "reset" command. See + Tests the "reset" command. See - Tests the "resetpen" command. See . + Tests the "resetpen" command. See . - Tests the command "pen". See + Tests the command "pen". See - Tests the command "fill". See . + Tests the command "fill". See . @@ -147,6 +142,61 @@ Tests the "int" declaration and assignment. It hasn't been implemented yet. + + + This class tests methods. It uses a combination of manual and random tests. + + + + + Random strip spaces test + + + + + Manual test + + + + + Manual test + + + + + Manual test. + + + + + Manual test. + + + + + Manual test. + + + + + Manual test. + + + + + Manual test. + + + + + Manual test. + + + + + Random test. + + A strongly-typed resource class, for looking up localized strings, etc. @@ -163,85 +213,30 @@ resource lookups using this strongly typed resource class. - - - This class tests methods. It uses a combination of manual and random tests. - - - - - Random strip spaces test - - - - - Manual test - - - - - Manual test - - - - - Manual test. - - - - - Manual test. - - - - - Manual test. - - - - - Manual test. - - - - - Manual test. - - - - - Manual test. - - - - - Random test. - - - This class tests methods. It uses a combination of manual and random tests. + This class tests methods. It uses a combination of manual and random tests. - Random test. + Random test. - Random test. + Random test. - Random test. + Random test. - Random test. + Random test. - \ No newline at end of file + diff --git a/Advanced Software Engineering/Advanced Software Engineering Tests/CommandTester.cs b/Advanced Software Engineering/Advanced Software Engineering Tests/CommandTester.cs index 7d7cf02..95e105b 100644 --- a/Advanced Software Engineering/Advanced Software Engineering Tests/CommandTester.cs +++ b/Advanced Software Engineering/Advanced Software Engineering Tests/CommandTester.cs @@ -1,5 +1,6 @@ using Advanced_Software_Engineering; using Advanced_Software_Engineering.Verbs.DrawingVerbs; +using Advanced_Software_Engineering.Verbs.Value.ValueObjects; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; @@ -267,27 +268,6 @@ namespace Advanced_Software_Engineering_Tests { Assert.AreEqual(correctDesc, verbDesc); } - /// - /// tests the "quadrilateral" command using . See . - /// - [TestMethod] - public void QuadrilateralTester_Manual1() { - string input = "quadrilateral 1, 2, 3, 4, 5, 6, 7, 8"; - Point[] points = { - new Point(1, 2), - new Point(3, 4), - new Point(5, 6), - new Point(7, 8) - }; - - IVerb IVerb = VerbFactory.MakeVerb(null, input); - - string verbDesc = IVerb.GetDescription(); - string correctDesc = new DrawLines(null, points).GetDescription(); - - Assert.AreEqual(verbDesc, correctDesc); - } - /// /// Tests the "circle" command. See . /// diff --git a/Advanced Software Engineering/Advanced Software Engineering Tests/SettingsAndHelperFunctionsTester.cs b/Advanced Software Engineering/Advanced Software Engineering Tests/HelperFunctionsTester.cs similarity index 64% rename from Advanced Software Engineering/Advanced Software Engineering Tests/SettingsAndHelperFunctionsTester.cs rename to Advanced Software Engineering/Advanced Software Engineering Tests/HelperFunctionsTester.cs index 2947558..16cf9f3 100644 --- a/Advanced Software Engineering/Advanced Software Engineering Tests/SettingsAndHelperFunctionsTester.cs +++ b/Advanced Software Engineering/Advanced Software Engineering Tests/HelperFunctionsTester.cs @@ -7,10 +7,10 @@ using System.Linq; namespace Advanced_Software_Engineering_Tests { /// - /// This class tests methods. It uses a combination of manual and random tests. + /// This class tests methods. It uses a combination of manual and random tests. /// [TestClass] - public class SettingsAndHelperFunctionsTester { + public class HelperFunctionsTester { private readonly string alphabet = "abcdefghijklmnopqrstuvwxzy"; private readonly Random rand = new Random(); @@ -36,7 +36,7 @@ namespace Advanced_Software_Engineering_Tests { } /// - /// Manual test + /// Manual test /// [TestMethod] public void Strip_Manual1() { @@ -47,7 +47,7 @@ namespace Advanced_Software_Engineering_Tests { } /// - /// Manual test + /// Manual test /// [TestMethod] public void Strip_Manual2() { @@ -58,7 +58,7 @@ namespace Advanced_Software_Engineering_Tests { } /// - /// Manual test. + /// Manual test. /// [TestMethod] public void StripStringArray_Manual1() { @@ -72,7 +72,7 @@ namespace Advanced_Software_Engineering_Tests { } /// - /// Manual test. + /// Manual test. /// [TestMethod] public void StripStringArray_Manual2() { @@ -86,47 +86,49 @@ namespace Advanced_Software_Engineering_Tests { } /// - /// Manual test. + /// Manual test. /// [TestMethod] public void CommandAndParameterParser_Manual1() { - Dictionary commands = HelperFunctions.CommandAndParameterParser("moveto 200, 200"); - Assert.AreEqual("moveto", commands["command"][0]); - Assert.AreEqual("200", commands["parameters"][0]); - Assert.AreEqual("200", commands["parameters"][1]); + CommandAndParameterParserResult commands = HelperFunctions.CommandAndParameterParser("moveto 200, 200"); + Assert.AreEqual("moveto", commands.GetCommand()); + Assert.AreEqual("200", commands.GetParameters()[0]); + Assert.AreEqual("200", commands.GetParameters()[1]); } /// - /// Manual test. + /// Manual test. /// [TestMethod] public void CommandAndParameterParser_Manual2() { - Dictionary commands = HelperFunctions.CommandAndParameterParser("clear"); - Assert.AreEqual("clear", commands["command"][0]); - Assert.IsFalse(commands.Keys.Contains("parameters")); + CommandAndParameterParserResult commands = HelperFunctions.CommandAndParameterParser("clear"); + Assert.AreEqual("clear", commands.GetCommand()); + Assert.IsTrue(commands.GetParameters() == null); } /// - /// Manual test. + /// Manual test. /// [TestMethod] public void CommandAndParameterParser_Manual3() { - Dictionary commands = HelperFunctions.CommandAndParameterParser(""); - Assert.IsFalse(commands.Keys.Contains("command")); - Assert.IsFalse(commands.Keys.Contains("parameters")); + CommandAndParameterParserResult commands = HelperFunctions.CommandAndParameterParser(""); + Assert.IsTrue(commands == null); } /// - /// Manual test. + /// Manual test. /// [TestMethod] public void CommandAndParameterParser_Manual4() { - Dictionary commands = HelperFunctions.CommandAndParameterParser(" genericCommand 2, 3,4 5"); + CommandAndParameterParserResult commands = HelperFunctions.CommandAndParameterParser(" genericCommand 2, 3,4 5"); - Assert.AreEqual("genericCommand", commands["command"][0]); - Assert.AreEqual("2", commands["parameters"][0]); - Assert.AreEqual("3", commands["parameters"][1]); - Assert.AreEqual("4 5", commands["parameters"][2]); + Assert.AreEqual("genericCommand", commands.GetCommand()); + + string[] parameters = commands.GetParameters(); + + Assert.AreEqual("2", parameters[0]); + Assert.AreEqual("3", parameters[1]); + Assert.AreEqual("4 5", parameters[2]); } private string RandomSpaces() { @@ -136,7 +138,7 @@ namespace Advanced_Software_Engineering_Tests { } /// - /// Random test. + /// Random test. /// [TestMethod] public void CommandAndParameterParser_Random1() { @@ -153,13 +155,13 @@ namespace Advanced_Software_Engineering_Tests { input += RandomSpaces() + parameter + RandomSpaces() + "," + RandomSpaces(); } - Dictionary commands = HelperFunctions.CommandAndParameterParser(input); + CommandAndParameterParserResult commands = HelperFunctions.CommandAndParameterParser(input); - Assert.AreEqual(command, commands["command"][0]); + Assert.AreEqual(command, commands.GetCommand()); int i = 0; foreach (string expected in parameters) { - Assert.AreEqual(expected, commands["parameters"][i++]); + Assert.AreEqual(expected, commands.GetParameters()[i++]); } } }