public void Find_Test() { //Arrange var shapeFinder = new ShapeFinder(); var shapes = new List <IShape> { new Circle(new Point(5, 5), 2), new Triangle(new Point(2, 2), new Point(4, 2), new Point(2, 5)), new Square(new Point(2, 5), new Point(5, 2)), new Triangle(new Point(-10, 2), new Point(-4, 4), new Point(2, 2)), new Circle(new Point(-5, 5), 6), new Circle(new Point(-1, 1), 10), new Circle(new Point(-1, 10), 6), new Circle(new Point(-5, -5), 2), new Square(new Point(-10, -1), new Point(-1, -10)), new Square(new Point(-1, 1), new Point(5, -5)), new Circle(new Point(0, 0), 1) }; //Act var firstQuarter = shapeFinder.Find(shapes, Quarter.First).ToList(); var secondQuarter = shapeFinder.Find(shapes, Quarter.Second).ToList(); var thirdQuarter = shapeFinder.Find(shapes, Quarter.Third).ToList(); var fourthQuarter = shapeFinder.Find(shapes, Quarter.Fourth).ToList(); var noneQuarter = shapeFinder.Find(shapes, Quarter.None).ToList(); //Assert Assert.AreEqual(firstQuarter.Count, 3); Assert.AreEqual(secondQuarter.Count, 4); Assert.AreEqual(thirdQuarter.Count, 2); Assert.AreEqual(fourthQuarter.Count, 1); Assert.AreEqual(noneQuarter.Count, 1); }
/// <summary> /// Displays the page. /// </summary> public override void Display() { base.Display(); try { if (Data.Shapes == null || Data.Shapes.Count == 0) { Output.DisplayInfo("Collection is empty!"); } else { var choice = Input.ReadEnum <Quarter>("Enter the Quarter"); var collection = ShapeSorter .SortByDescending(_shapeFinder.Find(Data.Shapes, choice), SortShapesBy.Perimeter).ToList(); var path = Input.ReadString("Enter file path: "); _fileManager.Save(path, collection); ShapePrinter.Print(collection); } } catch (ArgumentException e) { Output.DisplayError(e.Message + e.ParamName); } catch (FileNotFoundException e) { Output.DisplayError(e.Message); } catch (IOException e) { Output.DisplayError(e.Message); } catch (Exception e) { Output.DisplayError(e.Message); } Output.DisplayInfo("Press any key to navigate home"); Input.AnyKey(); Program.NavigateBack(); }