コード例 #1
0
        public void CalculateTest(double firstAgrument, double secondArgument, double expectedResult)
        {
            var calculator   = new GeometricCalculator();
            var actualResult = calculator.Calculate(firstAgrument, secondArgument);

            Assert.AreEqual(expectedResult, actualResult, 0.001);
        }
コード例 #2
0
        public void CalculationTest(double firstValue, double secondValue, double expected)
        {
            var calculator   = new GeometricCalculator();
            var actualResult = calculator.Calculate(firstValue, secondValue);

            Assert.AreEqual(expected, actualResult, 0.01);
        }
コード例 #3
0
        public void GetAreaAllNullArray()
        {
            var   calc     = new GeometricCalculator();
            float expected = 0f;
            var   actual   = calc.GetArea(new GeometricThing[] { null });

            Assert.AreEqual(expected, actual);
        }
コード例 #4
0
        public void GetCircumferenceTestNull()
        {
            var calc     = new GeometricCalculator();
            var actual   = calc.GetCircumference(new IGeometricThing[] { null });
            var expected = 0;

            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
        public void GetAreaTestOneShapeNull()
        {
            var   calc     = new GeometricCalculator();
            float expected = 0f;
            var   square   = new Geometry.Square(0);
            var   actual   = calc.GetArea(square);

            Assert.AreEqual(expected, actual);
        }
コード例 #6
0
        public void GetPerimeterTestOneShapeNegative()
        {
            var   calc     = new GeometricCalculator();
            float expected = 0f;
            var   square   = new Geometry.Square(-10);
            var   actual   = calc.GetPerimeter(square);

            Assert.AreEqual(expected, actual);
        }
コード例 #7
0
 public WeatherMachine(GeometricCalculator geometricCalculator,
                       WeatherValidator weatherValidator)
 {
     this.geometricCalculator = geometricCalculator;
     this.weatherValidator    = weatherValidator;
     OccurrencesByWeather.Add(WeatherType.Drought, 0);
     OccurrencesByWeather.Add(WeatherType.Rainy, 0);
     OccurrencesByWeather.Add(WeatherType.IdealConditions, 0);
     OccurrencesByWeather.Add(WeatherType.NotDefined, 0);
 }
コード例 #8
0
        public void GetPerimeterEmptyArray()
        {
            var   calc     = new GeometricCalculator();
            float expected = 0f;
            var   actual   = calc.GetPerimeter(new GeometricThing[]
            {
            });

            Assert.AreEqual(expected, actual);
        }
コード例 #9
0
        public void GetPerimeterOneNullArray()
        {
            var   calc     = new GeometricCalculator();
            float expected = 70f;
            var   actual   = calc.GetPerimeter(new GeometricThing[]
            {
                new Geometry.Square(10),
                new Geometry.Rectangle(5, 10),
                new Geometry.Circle()
            });

            Assert.AreEqual(expected, actual);
        }
コード例 #10
0
        public void GetPerimeterTest()
        {
            var objectArray = new GeometricThing[]
            {
                new Circle(12),
                new Triangle(2, 2),
                new Square(5)
            };

            var geomatricCalculator = new GeometricCalculator();

            Assert.AreEqual(101, MathF.Round(geomatricCalculator.GetPerimeter(objectArray)));
        }
コード例 #11
0
        public void GetAreaTestOnlyNegatives()
        {
            var   calc     = new GeometricCalculator();
            float expected = 0f;
            var   actual   = calc.GetArea(new GeometricThing[]
            {
                new Geometry.Square(-630),
                new Geometry.Circle(-13.52314f),
                new Geometry.Rectangle(-20, -500),
                new Geometry.Triangle(-3000)
            });

            Assert.AreEqual(expected, actual);
        }
コード例 #12
0
        public void GetAreaTestWeirdValues()
        {
            var   calc     = new GeometricCalculator();
            float expected = 150f; // 100 + 0 + 0 + 50 = 150
            var   actual   = calc.GetArea(new GeometricThing[]
            {
                new Geometry.Square(10),
                new Geometry.Circle(0),
                new Geometry.Rectangle(10, -20),
                new Geometry.Triangle(10)
            });

            Assert.AreEqual(expected, actual);
        }
コード例 #13
0
        public void GetPerimeterManyNullValues()
        {
            var   calc     = new GeometricCalculator();
            float expected = 40f;
            var   actual   = calc.GetPerimeter(new GeometricThing[]
            {
                new Geometry.Square(10),
                new Geometry.Triangle(),
                null,
                new Geometry.Circle(0)
            });

            Assert.AreEqual(expected, actual);
        }
コード例 #14
0
        public void GetAreaTest()
        {
            var   calc     = new GeometricCalculator();
            float expected = 428.53983f; // 100 + 78.53983 + 200 + 50 = 428.53983
            var   actual   = calc.GetArea(new GeometricThing[]
            {
                new Geometry.Square(10),
                new Geometry.Circle(5),
                new Geometry.Rectangle(10, 20),
                new Geometry.Triangle(10)
            });

            Assert.AreEqual(expected, actual);
        }
コード例 #15
0
        public void GetPerimeterTestWeirdValues()
        {
            var   calc     = new GeometricCalculator();
            float expected = 70f; // 40 + 0 + 0 + 30 = 70
            var   actual   = calc.GetPerimeter(new GeometricThing[]
            {
                new Geometry.Square(10),
                new Geometry.Circle(0),
                new Geometry.Rectangle(10, -20),
                new Geometry.Triangle(10)
            });

            Assert.AreEqual(expected, actual);
        }
コード例 #16
0
        public void GetPerimeterTest()
        {
            var   calc     = new GeometricCalculator();
            float expected = 161.41592f; // 40 + 31.41592 + 60 + 30 = 161.41592
            var   actual   = calc.GetPerimeter(new GeometricThing[]
            {
                new Geometry.Square(10),
                new Geometry.Circle(5),
                new Geometry.Rectangle(10, 20),
                new Geometry.Triangle(10)
            });

            Assert.AreEqual(expected, actual);
        }
コード例 #17
0
        public void GetPerimeterTest()
        {
            var geoCal    = new GeometricCalculator();
            var geoThings = new IGeometric[]
            {
                new Triangle(3, 4, 5),
                new Square(10),
                new Circle(3)
            };

            var actual   = geoCal.GetPerimeter(geoThings);
            var expected = 12 + 40 + 18.85;

            Assert.AreEqual(expected, actual, 0.01);
        }
コード例 #18
0
        public void GetCircumferenceTest0()
        {
            var calc   = new GeometricCalculator();
            var actual = calc.GetCircumference(new IGeometricThing[]
            {
                new Square(0.0f),
                new Circle(0.0f),
                new Rectangle(0, 0.0f),
                new Triangle(0)
            });

            var expected = 0;

            Assert.AreEqual(expected, actual);
        }
コード例 #19
0
        public void GetCircumferenceTest()
        {
            var calc   = new GeometricCalculator();
            var actual = calc.GetCircumference(new IGeometricThing[]
            {
                new Square(10),
                new Circle(2),
                new Rectangle(2, 4),
                new Triangle(4)
            });

            var expected = 40 + 6.2832f + 12 + 12;

            Assert.AreEqual(expected, actual);
        }
コード例 #20
0
        public IEnumerable <Individual> Cross(Individual individual1, Individual individual2)
        {
            var midpoint = GeometricCalculator.GetMidpoint(individual1.Semantics, individual2.Semantics);

            bool triedBackPropagation1;
            var  child1 = GenerateChildren(individual1, individual2, midpoint, out triedBackPropagation1);

            bool triedBackPropagation2;
            var  child2 = GenerateChildren(individual2, individual1, midpoint, out triedBackPropagation2);

            if (!triedBackPropagation1 && !triedBackPropagation2 && Fallback != null)
            {
                return(Fallback.Cross(individual1, individual2));
            }

            return(new[] { child1, child2 });
        }
コード例 #21
0
        static void Main(string[] args)
        {
            var initializer       = new ConsoleDataInitializer();
            var initializedResult = initializer.InitializeData();

            if (initializedResult.IsSuccessful)
            {
                var calculator = new GeometricCalculator(initializedResult.Parameters.GeneralArea);
                Console.WriteLine(calculator.GetFullInfo());
            }
            else
            {
                Console.WriteLine(initializedResult.ErrorMessage);
            }

            Console.ReadKey();
        }
コード例 #22
0
ファイル: Program.cs プロジェクト: bpfau79/geometric-layout
        public static void Main(string[] args)
        {
            var calc = new GeometricCalculator(length: 10, numColumns: 12);

            var keys = calc.GenerateKeys();

            foreach (var key in keys)
            {
                var vertices = calc.CalculateVerticesFromKey(key);
                PrintResult(key, vertices);

                var keyFromVertices = calc.CalculateKeyFromVertices(vertices);
                Console.Write($" Reverse={keyFromVertices}");
                Console.WriteLine();
            }

            Console.WriteLine("Hit any key to exit...");
            Console.ReadKey();
        }
コード例 #23
0
 public WeatherValidatorTest()
 {
     this.geometricCalculator = new GeometricCalculator();
     this.weatherValidator    = new WeatherValidator(geometricCalculator);
 }
コード例 #24
0
 public bool ContainsCoordinates(Vector2 coordinatesCenterOfFigure, Vector2 otherCoordinates)
 {
     return(GeometricCalculator.SquareContainsPoint(coordinatesCenterOfFigure, otherCoordinates, halfTileSize, tileArea));
 }
コード例 #25
0
 public SquareTileCoordinateProcessor(float tileSize)
 {
     this.tileSize = tileSize;
     halfTileSize  = tileSize / 2f;
     tileArea      = GeometricCalculator.CalculateAreaOfSquare(tileSize);
 }
コード例 #26
0
 public bool ContainsCoordinates(Vector2 coordinatesCenterOfFigure, Vector2 otherCoordinates)
 {
     return(GeometricCalculator.CircleContainsPoint(coordinatesCenterOfFigure, otherCoordinates, radius));
 }
コード例 #27
0
 public GeometricCalculatorTest()
 {
     geometricCalculator = new GeometricCalculator();
 }
コード例 #28
0
 public WeatherValidator(GeometricCalculator geometricCalculator)
 {
     this.geometricCalculator = geometricCalculator;
 }