public void CreateEquilateralTriangleFromZeroZeroPoint()
        {
            int            numberOfVertices = 3;
            RegularPolygon polygon          = _factory.CreateRegularPolygon(numberOfVertices, _standardLength, _initiaVertex);

            Vertex[] vertices = polygon.Vertices;
            Assert.IsTrue(new Vertex(0, 0).Equals(vertices[0]));
            Assert.IsTrue(new Vertex(2, 0).Equals(vertices[1]));
            Assert.IsTrue(new Vertex(1, 1.73).Equals(vertices[2]));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Given the application parameters, creates regular polygon and depending on the option: saves it to default file or displays it on console
        /// /// </summary>
        /// <param name="parameters">Already parsed application parameters</param>
        private static void ProcessInput(AppParameters parameters)
        {
            RegularPolygonFactory factory = new RegularPolygonFactory();

            try
            {
                RegularPolygon polygon =
                    factory.CreateRegularPolygon(parameters.NumberOfVertices, parameters.SideLength, DefaultInitialVertex);
                switch (parameters.Option)
                {
                case AppParameters.ProcessType.DisplayOnConsole:
                    DU.DisplayText(polygon.ToString());
                    DU.DisplayText("Successfully completed operation", DU.InformationType.OnSuccess);
                    break;

                case AppParameters.ProcessType.SaveToFile:
                    SavePolygonToFile(DefaultFilePath, polygon);
                    break;
                }
            }
            catch (RegularPolygonFactoryLogicalException e)
            {
                DU.DisplayText(e.Message, DU.InformationType.OnError);
            }
        }