public void testToString() { List<Percept> ps = new List<Percept>(); ps.Add(new DynamicPercept("key1", "value1")); Assert.Equals("[Percept[key1==value1]]", ps.ToString()); ps.Add(new DynamicPercept("key1", "value1", "key2", "value2")); Assert.Equals( "[Percept[key1==value1], Percept[key1==value1, key2==value2]]", ps.ToString()); }
public void LoadingWordsFromTest() { List<string> expected = new List<string> { "computer", "programmer", "software", "debugger", "compiler", "developer" }; SecretWordManager actual = new SecretWordManager(); actual.LoadAllSecretWords(@"../../Test Resources/SecretWordLibraryTest.txt"); Assert.AreEqual(expected.ToString(), actual.GetAllSecretWords().ToString()); }
public void LoadingWordsFromNonOrderedFileWithWordsTest() { List<string> expected = new List<string> { "computer", "debugger", "silence" }; SecretWordManager actual = new SecretWordManager(); actual.LoadAllSecretWords(@"../../Test Resources/nonOrderedWords.txt"); Assert.AreEqual(expected.ToString(), actual.GetAllSecretWords().ToString()); }
public void LoadingWordsFromEmptyFileTest() { List<string> expected = new List<string>(); SecretWordManager actual = new SecretWordManager(); actual.LoadAllSecretWords(@"../../Test Resources/emptyfile.txt"); Assert.AreEqual(expected.ToString(), actual.GetAllSecretWords().ToString()); }
public void TestListToString() { TestClass testclass = new TestClass() { ID = 5, Decimal = 3.3M, Float = 3.23423F, String = "blah, \"asdff\"" }; testclass.Class = new TestClass() { ID = 5, Decimal = 3.3M, Float = 3.23423F, String = "blah, \"asdff\"" }; List<TestClass> lst = new List<TestClass>(); for (int i = 0; i < 2; i++) { lst.Add(testclass); } string actual = lst.ToString(','); Assert.AreEqual("5,\"blah, \"\"asdff\"\"\",3.3,3.23423,\"5,\"blah, \"\"asdff\"\"\",3.3,3.23423\"\r\n5,\"blah, \"\"asdff\"\"\",3.3,3.23423,\"5,\"blah, \"\"asdff\"\"\",3.3,3.23423\"\r\n", actual); }
public void NavBar_Return_SameModel() { //Arrange var navbar = new NavbarController(); var navbars = new List<Navbar>(); navbars.Add(new Navbar { Id = 2, nameOption = "Charts", controller = "Home", action = "Charts", imageClass = "fa fa-fw fa-bar-chart-o", estatus = true }); navbars.Add(new Navbar { Id = 3, nameOption = "Tables", controller = "Home", action = "Tables", imageClass = "fa fa-fw fa-table", estatus = true }); string controller = "Home"; string act = "Index"; //Act var viewResult = navbar.Navbar(controller, act) as PartialViewResult; var viewModel = viewResult.Model; //Assert Assert.AreSame(viewResult.Model.ToString(), navbars.ToString()); }
public void StepTwoTest() { Board board = Board.createInstance(25); // TODO: Initialize to an appropriate value int gameSize = 5; // TODO: Initialize to an appropriate value ComputerMoveHandler Step2Target = new ComputerMoveHandler(board, gameSize); // TODO: Initialize to an appropriate value Step2Target.MakeMove(new Point(5, 5), Symbol.Cross); Step2Target.MakeMove(new Point(5, 6), Symbol.Cross); Step2Target.MakeMove(new Point(5, 7), Symbol.Cross); Step2Target.MakeMove(new Point(6, 7), Symbol.Oval); List<Point> pos = new List<Point>() {new Point(5,8),new Point(5,4)}; // TODO: Initialize to an appropriate value Symbol coin = Symbol.Cross; // TODO: Initialize to an appropriate value List<Point> expected = new List<Point>(){new Point(5,8)}; // TODO: Initialize to an appropriate value List<Point> actual; actual = Step2Target.StepTwo(pos, coin); Assert.AreEqual(expected.ToString(), actual.ToString()); Step2Target = null; board = null; }
public void StepThreeTest() { Board board = Board.createInstance(25); // TODO: Initialize to an appropriate value int gameSize = 5; // TODO: Initialize to an appropriate value ComputerMoveHandler Step3Target = new ComputerMoveHandler(board, gameSize); // TODO: Initialize to an appropriate value List<Point> pos = new List<Point>(){new Point(0,0),new Point(0,1)}; // TODO: Initialize to an appropriate value Symbol coin = Symbol.Cross; // TODO: Initialize to an appropriate value List<Point> expected = new List<Point>(){new Point(0,1)} ; // TODO: Initialize to an appropriate value List<Point> actual; actual = Step3Target.StepThree(pos, coin); Assert.AreEqual(expected.ToString(), actual.ToString()); Step3Target = null; board = null; }
public void StepOneTest() { Board board = Board.createInstance(25); // TODO: Initialize to an appropriate value int gameSize = 5; // TODO: Initialize to an appropriate value ComputerMoveHandler target = new ComputerMoveHandler(board, gameSize); // TODO: Initialize to an appropriate value target.MakeMove(new Point(5, 5), Symbol.Cross); target.MakeMove(new Point(5, 6), Symbol.Cross); target.MakeMove(new Point(5, 7), Symbol.Cross); Symbol coin = Symbol.Cross; // TODO: Initialize to an appropriate value List<Point> expected = new List<Point>(); // TODO: Initialize to an appropriate value expected.Add(new Point(5, 4)); expected.Add(new Point(5, 8)); List<Point> actual1; actual1 = target.StepOne(coin); List<Point> Actual = new List<Point>(); foreach (Point ptr in actual1) { Actual.Add(ptr); } Assert.AreEqual(expected.ToString(), Actual.ToString()); target = null; board = null; }
public void CreatePointTest() { // PrivateObject param0 = null; // TODO: Initialize to an appropriate value // Board_Accessor target = new Board_Accessor(param0); // TODO: Initialize to an appropriate value int size = 2; Board target = Board.createInstance(size); List<Point> expected = new List<Point>(); Point Epoint= new Point(0,0); for (int y = 0; y < 2; y++) { for (int x = 0; x < 2; x++) { expected.Add(new Point(x, y)); } } IEnumerable<Point> act; List<Point> actual = new List<Point>(); act = target.CreatePoint(); foreach (Point position in act) { actual.Add(new Point(position.X, position.Y)); } Assert.AreEqual(expected.ToString(), actual.ToString()); }
public void TestCourseStudentLeaving() { Student studentToRemove = new Student("Pesho", 34342); IList<Student> students = new List<Student>() { new Student("Pesho", 10002), new Student("Gosho", 20003), new Student("Mariq", 30004), new Student("Pettq", 10042), studentToRemove }; Course course = new Course(students); course.Leave(studentToRemove); bool studentHasLeft = true; for (int i = 0; i < course.Students.Count; i++) { if (course.Students[i].Name == studentToRemove.Name && course.Students[i].Number == studentToRemove.Number) { studentHasLeft = false; } } Assert.AreEqual(4, students.Count, "Expected to count 4 students after removing one from the course."); Assert.IsFalse(students.ToString().Contains(studentToRemove.Number.ToString()), "Expected to remove the student from the course but found his unique number."); Assert.IsTrue(studentHasLeft, "Expected to not find a student with the same name and number"); }
//--------------------------------------- //private IList<string> GetAppTable(IWebElement element) //{ // IWebElement rowElement; // IList<IWebElement> columnElements; // IList<IWebElement> rowElements; // List<string> htmlTable = new List<string>(); // rowElements = element.FindElements(By.TagName("tr")); // int rowNum = rowElements.Count; // if (rowNum > 0) // { // string value = ""; // for (int i = 0; i < rowNum; i++) // { // rowElement = rowElements[i]; // columnElements = rowElement.FindElements(By.TagName("td")); // if (columnElements == null) // { // columnElements = rowElement.FindElements(By.TagName("th")); // } // int colNum = columnElements.Count; // for (int j = 0; j < colNum; j++) // { // value = columnElements[j].Text; // if (value != null) // { // htmlTable.Add(value); // } // else // { // htmlTable.Add(""); // } // } // } // } // else // { // throw new Exception(); // } // return htmlTable; //} //--------------------------------------- private void CompareTableData(UITestControl element, string tableName, string expectedValue, bool stopOnFailure, Object customErrorMessage = null) { IList<string> htmlTable; IList<string> inputTable; string paradigm = element.TechnologyName; try { //htmlTable = GetAppTable(element); if (paradigm.Equals("Web", StringComparison.OrdinalIgnoreCase)) { HtmlTable actTable = (HtmlTable)element; htmlTable = actTable.GetContent(); } else { WinTable actTable = (WinTable)element; htmlTable = actTable.GetContent(); } inputTable = new List<string>(expectedValue.Split(',').ToList<string>()); List<string> tempInputTable = new List<string>(); foreach (string inputVal in inputTable) { string formattedValue = inputVal.Replace("\\\\", ","); tempInputTable.Add(formattedValue); } inputTable = tempInputTable; string inputTableStr = string.Join("|", inputTable); string actualTableStr = string.Join("|", htmlTable); if (actualTableStr.Contains(inputTableStr)) { reportResults("Check Table: Table Data", "Check Table: Table Data command passed. Table : " + tableName, LogLevel.Success); } else { string inputTableString = inputTable.ToString(); string htmlTableString = htmlTable.ToString(); reportResults( stopOnFailure, "Check Table: Table Data", "Check Table: Table Data command failed. Table : " + tableName + ", table data is not as expected. Expected : " + string.Join(",", inputTableString) + ", Actual : " + string.Join(",", htmlTableString), LogLevel.Error, "", customErrorMessage ); } } catch (AssertFailedException e) { throw e; } catch (Exception e) { reportResults( stopOnFailure, "Check Table: Table Data", "Check Table: Table Data command failed. Actual Error : " + e.Message, LogLevel.Error, e.StackTrace, customErrorMessage ); } }
private void CheckEdgeGraph(HalfEdgeStructure edgeGraph) { var checkoff = new List<HalfEdge>(edgeGraph.Edges); //faces should all have closed graphs foreach (var f in edgeGraph.Faces) CheckOffEdges(checkoff, f.OuterEdge); //now we just have 1 poly for the outer bounds facing in. CheckOffEdges(checkoff, checkoff[0]); Assert.AreEqual(0, checkoff.Count, "Dangling edges: " + checkoff.ToString()); }
public void IdentityPathTest() { SimpleIdentity id = new SimpleIdentity(); IdentityPath pathSimple = new IdentityPath(id); Assert.AreEqual(IdentityPath.ROOT, pathSimple.Parent); Assert.AreEqual(IdentityPath.ROOT, pathSimple.GetPathTo(-1)); Assert.AreEqual(id, pathSimple.Child); Assert.AreEqual(1, pathSimple.Length); Assert.AreEqual(0, pathSimple.Depth); AssertEx.ThrowsException<IndexOutOfRangeException>(() => pathSimple.GetPathTo(-2)); AssertEx.ThrowsException<IndexOutOfRangeException>(() => pathSimple.GetPathTo(1)); IdentityPath pathRoot = new IdentityPath(new Identity[0]); Assert.AreEqual(IdentityPath.ROOT, pathRoot); Assert.AreEqual(0, pathRoot.Length); Assert.AreEqual(-1, pathRoot.Depth); AssertEx.ThrowsException<IndexOutOfRangeException>(() => pathRoot.Child); AssertEx.ThrowsException<IndexOutOfRangeException>(() => pathRoot.Parent); const int count = 5; List<Identity> listId1 = new List<Identity>(); List<Identity> listId2 = new List<Identity>(); HashSet<IdentityPath> setPaths = new HashSet<IdentityPath>(); IdentityPath last = IdentityPath.ROOT; for (int i = 0; i < count; i++) { listId1.Add(new NumericIdentity(i)); listId2.Add(new NumericIdentity(i)); IdentityPath path = new IdentityPath(listId1); Assert.AreEqual(path, new IdentityPath(listId1)); Assert.AreNotEqual(path, new IdentityPath(listId2)); Assert.AreEqual(last, path.Parent); Assert.AreSame(listId1[i], path.Child); Assert.AreEqual(path, new IdentityPath(path.Parent, path.Child)); Assert.AreEqual(i, path.Depth); Assert.AreEqual(listId1.Count, path.Length); Assert.AreSame(path.Child, path.GetIdentity(path.Depth)); Assert.AreEqual(path.Parent, path.GetPathTo(path.Depth - 1)); Assert.AreEqual("/" + listId1.ToString("/"), path.ToString()); for (int j = 0; j < i; j++) Assert.IsTrue(setPaths.Contains(path.GetPathTo(j))); setPaths.Add(path); last = path; } }