public void OneElementList() { List <Tuple <string, string> > list = new List <Tuple <string, string> >(); list.Add(new Tuple <string, string>("two", "three")); PathConstructor pathConstructor = new PathConstructor(); var result = pathConstructor.ConstructPath(list); var firstNotSecond = result.Except(list).ToList(); Assert.AreEqual(firstNotSecond.Count(), 0, "using ListExcept"); }
public void TwoPaths() { List <Tuple <string, string> > list = new List <Tuple <string, string> >(); list.Add(new Tuple <string, string>("one", "two")); list.Add(new Tuple <string, string>("two", "three")); list.Add(new Tuple <string, string>("three", "four")); list.Add(new Tuple <string, string>("one1", "two1")); list.Add(new Tuple <string, string>("two1", "three1")); PathConstructor pathConstructor = new PathConstructor(); var result = pathConstructor.ConstructPath(list); }
public void BranchTwo() { List <Tuple <string, string> > list = new List <Tuple <string, string> >(); list.Add(new Tuple <string, string>("one", "two")); list.Add(new Tuple <string, string>("two", "three")); list.Add(new Tuple <string, string>("three", "four")); list.Add(new Tuple <string, string>("seven", "two")); list.Add(new Tuple <string, string>("four", "five")); PathConstructor pathConstructor = new PathConstructor(); var result = pathConstructor.ConstructPath(list); }
public void CreatePath_PathReturned() { // arrange string fileName = "CSV//UserData.csv"; // act PathConstructor path = new PathConstructor(); string actual = path.pathConstructor(fileName); bool actualFlag = actual.Contains(fileName); // assert Assert.IsTrue(actualFlag); }
public void When_Construting_Multiline_Path(string [] lines, int position, string excpectedPath) { //Act var constructor = new PathConstructor(); //Act var linesEnumerator = lines.Reverse().GetEnumerator(); var pathResult = constructor.ConstructPathBackwards(linesEnumerator, position); //Assert Assert.That(pathResult, Is.EqualTo(excpectedPath)); }
public void When_Constucting_Elment_Path(string rawLine, int position, string excpectedPath) { //Act var constructor = new PathConstructor(); //Act var lines = new[] { rawLine }; var pathResult = constructor.ConstructPathBackwards(lines.Reverse().GetEnumerator(), position); //Assert Assert.That(pathResult, Is.EqualTo(excpectedPath)); }
public void Get_TotalUsers_CountReturned() { // arrange List <User> users = new List <User>(); string fileName = "CSV//UserData.csv"; int expected = 50; // act PathConstructor path = new PathConstructor(); CSVReader reader = new CSVReader(fileName.ToCsvFilePath()); UserAmounts amount = new UserAmounts(); users = reader.GetUsers(); int actual = amount.GetTotalUsersCount(users); // assert Assert.AreEqual(actual, expected); }
public static List <T> Search <T>(IUnweightedGraph <T> graph, T start, HashSet <T> goals) { var foundPath = Search(graph, start, goals, out var cameFrom); if (!foundPath) { return(null); } foreach (var goal in goals) { if (cameFrom.ContainsKey(goal)) { return(PathConstructor.RecontructPath(cameFrom, start, goal)); } } return(null); }
public void Get_UsersByCountry_CountReturned() { // arrange List <User> users = new List <User>(); string fileName = "CSV//UserData.csv"; string country = "LV"; int expected = 30; // act PathConstructor path = new PathConstructor(); CSVReader reader = new CSVReader(); UserAmounts amount = new UserAmounts(); users = reader.GetTotal(path.pathConstructor(fileName)).Item1; int actual = amount.GetUsersByCountryCount(country, users); // assert Assert.AreEqual(actual, expected); }
public void MultiElementListMyOwnComparator() { List <Tuple <string, string> > list = new List <Tuple <string, string> >(); list.Add(new Tuple <string, string>("two", "three")); list.Add(new Tuple <string, string>("four", "five")); list.Add(new Tuple <string, string>("one", "two")); list.Add(new Tuple <string, string>("three", "four")); PathConstructor pathConstructor = new PathConstructor(); var result = pathConstructor.ConstructPath(list); List <Tuple <string, string> > correctList = new List <Tuple <string, string> >(); correctList.Add(new Tuple <string, string>("one", "two")); correctList.Add(new Tuple <string, string>("two", "three")); correctList.Add(new Tuple <string, string>("three", "four")); correctList.Add(new Tuple <string, string>("four", "five")); var firstNotSecond = result.Except(correctList).ToList(); Assert.AreEqual(true, Comparator(result, correctList), "My own Comparator"); }
public void MultiElemRepeatingElementsMyOwnCompr() { List <Tuple <string, string> > list = new List <Tuple <string, string> >(); list.Add(new Tuple <string, string>("two", "three")); list.Add(new Tuple <string, string>("four", "five")); list.Add(new Tuple <string, string>("one", "two")); list.Add(new Tuple <string, string>("three", "four")); list.Add(new Tuple <string, string>("four", "five")); PathConstructor pathConstructor = new PathConstructor(); var result = pathConstructor.ConstructPath(list); List <Tuple <string, string> > correctList = new List <Tuple <string, string> >(); correctList.Add(new Tuple <string, string>("one", "two")); correctList.Add(new Tuple <string, string>("two", "three")); correctList.Add(new Tuple <string, string>("three", "four")); correctList.Add(new Tuple <string, string>("four", "five")); var firstNotSecond = result.Except(correctList).ToList(); Assert.AreEqual(firstNotSecond.Count(), 0, "using ListExcept"); }
public void Compare_CreatedCSVandProvidedCSV() { // arrange int id = 1; int total = 50; int LV = 30; int LT = 15; int EE = 5; List <Result> results = new List <Result>(); Result r = new Result { Id = id, Total = total, LV = LV, LT = LT, EE = EE }; results.Add(r); // act CSVWriter writer = new CSVWriter(); CSVReader reader = new CSVReader(); PathConstructor path = new PathConstructor(); Result result = new Result(); Validator validator = new Validator(writer, reader, path, result); // assert try { validator.VerifyData(total, LV, LT, EE, results); Assert.IsTrue(true); } catch { Assert.IsTrue(false); } }
/// <summary> /// gets a path from start to goal if possible. If no path is found null is returned. /// </summary> /// <param name="graph">Graph.</param> /// <param name="start">Start.</param> /// <param name="goal">Goal.</param> /// <typeparam name="T">The 1st type parameter.</typeparam> public static List <T> Search <T>(IAstarGraph <T> graph, T start, T goal) { var foundPath = Search(graph, start, goal, out var cameFrom); return(foundPath ? PathConstructor.RecontructPath(cameFrom, start, goal) : null); }
public void IputNULLTest() { PathConstructor pathConstructor = new PathConstructor(); pathConstructor.ConstructPath(null); }