Пример #1
0
        public void AreaCalculatorWithDefaultsTest()
        {
            var areaCalculator = new AreaCalculator(true);
            var circleResult   = areaCalculator.Calculate(3);

            Assert.AreEqual(Math.Round(circleResult, 2), 28.27d);
            var triangleResult = areaCalculator.Calculate(3, 4, 5);

            Assert.AreEqual(triangleResult, 6);
        }
Пример #2
0
    // Update is called once per frame
    //void Update()
    //{
    //
    //}

    #region Setup new SpawnAreas
    private void CalculateSpawnAreas()
    {
        spawnAreas = new List <SpawnArea>();

        Dictionary <Tile, GameObject>      oldEntitiesPosition    = this.entitiesPosition;
        Dictionary <Tile, HeightLevelType> oldEntitiesHeightLevel = this.entitiesHeightLevel;

        this.entitiesPosition    = new Dictionary <Tile, GameObject>();
        this.entitiesHeightLevel = new Dictionary <Tile, HeightLevelType>();
        areaCalculator.Calculate();

        foreach (HeightLevelType levelType in Enum.GetValues(typeof(HeightLevelType)))
        {
            //alle Flächen auf einem Höhenlevel bestimmen
            List <Area> areas = areaCalculator.ContiguousAreasOnHeightLevel(levelType);
            //aus den Flächen die SpawnAreas generieren
            if (areas != null && levelType != HeightLevelType.UNDEFINED)
            {
                DetermineCorrectlyLocatedEntities(areas, levelType, oldEntitiesPosition, oldEntitiesHeightLevel);
                IEnumerable <SpawnArea> spawnAreasOnHeightLevel = SetupSpawnAreasForHeightLevel(areas, levelType);
                spawnAreas.AddRange(spawnAreasOnHeightLevel);
            }
        }

        DestroyOrphanGameObjects(oldEntitiesPosition);
    }
Пример #3
0
        public static void Main(string[] args)
        {
            var square     = new Square(4);
            var calculator = new AreaCalculator();
            var area       = calculator.Calculate(square);

            Console.WriteLine($"Square with a side of 4 has an area of {area}");
        }
Пример #4
0
        public void CalculateTriangleAreaTest()
        {
            double triangleArea = 2143.2;

            Shape      triangle   = new Triangle(125, 55, 88.88);
            Calculator calculator = new AreaCalculator();

            Assert.AreEqual(triangleArea, Math.Round(calculator.Calculate(triangle), 2));
        }
Пример #5
0
        public void CalculateRectangleAreaTest()
        {
            double triangleArea = 256;

            Shape      rectangle  = new Rectangle(32, 8);
            Calculator calculator = new AreaCalculator();

            Assert.AreEqual(triangleArea, Math.Round(calculator.Calculate(rectangle), 2));
        }
Пример #6
0
        public void CalculateSquareAreaTest()
        {
            double triangleArea = 64;

            Shape      square     = new Square(8);
            Calculator calculator = new AreaCalculator();

            Assert.AreEqual(triangleArea, Math.Round(calculator.Calculate(square), 2));
        }
Пример #7
0
        public void TestTriangle()
        {
            var triangle = new Triangle(1, 2, 2);

            Assert.AreEqual(0.9682458365518543, AreaCalculator.Calculate(triangle));
            var falseTriangle = new Triangle(2, 1, -2);

            Assert.IsFalse(ShapeValidator.IsValid(falseTriangle));
        }
Пример #8
0
        public void TestCircle()
        {
            var circle = new Circle(5);

            Assert.AreEqual(78.53981633974483, AreaCalculator.Calculate(circle));
            var falseCircle = new Circle(-6);

            Assert.IsFalse(ShapeValidator.IsValid(falseCircle));
        }
Пример #9
0
        public void CalculateCircleAreaTest()
        {
            double circleArea = 94.985;

            Shape      circle     = new Circle(5.5);
            Calculator calculator = new AreaCalculator();

            Assert.AreEqual(circleArea, calculator.Calculate(circle));
        }
Пример #10
0
        public void CalculateWithNoNameTest2()
        {
            //Arrange
            AreaCalculator calcTest = new AreaCalculator();

            double[] var = { 3, 4, 5 };

            //Act /Assert
            Assert.True(calcTest.Calculate(var) == 6);
        }
Пример #11
0
        public void CalculateWithNoNameTest1()
        {
            //Arrange
            AreaCalculator calcTest = new AreaCalculator();

            double[] var = { 1 };

            //Act /Assert
            Assert.True(calcTest.Calculate(var) == 3.141592);
        }
Пример #12
0
    public static void Main(string[] args)
    {
        var square     = new Square(4);
        var calculator = new AreaCalculator();
        var area       = calculator.Calculate(square);
        /* inserted */
        int _11 = 18;

        Console.WriteLine($" Square with a side of 4 has an area of  area ");
    }
Пример #13
0
        public void WrongVarQtyTest()
        {
            //Arrange
            AreaCalculator calcTest = new AreaCalculator();

            double[] var = { 1 };

            //Act /Assert
            var ex = Assert.Throws <ArgumentException>(() => calcTest.Calculate("triangle_3s", var));

            Assert.That(ex.Message, Is.EqualTo("not enough arguments"));
        }
Пример #14
0
        public void NegativeVarTest()
        {
            //Arrange
            AreaCalculator calcTest = new AreaCalculator();

            double[] var = { -1 };

            //Act /Assert
            var ex = Assert.Throws <ArgumentException>(() => calcTest.Calculate("circle", var));

            Assert.That(ex.Message, Is.EqualTo("only positive arguments must be used"));
        }
Пример #15
0
        public void CalculateWithNoStringFound()
        {
            //Arrange
            AreaCalculator calcTest = new AreaCalculator();

            double[] var = { 1 };

            //Act /Assert
            var ex = Assert.Throws <ArgumentException>(() => calcTest.Calculate("polygon", var));

            Assert.That(ex.Message, Is.EqualTo("Shape name not found"));
        }
Пример #16
0
        public void CalculateWithNoNameTest3()
        {
            //Arrange
            AreaCalculator calcTest = new AreaCalculator();

            double[] var = { -3, 4, 5 };

            //Act /Assert
            var ex = Assert.Throws <ArgumentException>(() => calcTest.Calculate(var));

            Assert.That(ex.Message, Is.EqualTo("only positive arguments must be used"));
        }
Пример #17
0
        public void CalculateAreaViaCalcTest()
        {
            //Arrange

            AreaCalculator calcTest = new AreaCalculator();

            double[] values = { 3, 4, 5 };

            //Act
            double result = calcTest.Calculate("triangle_3s", values);

            //Assert
            Assert.IsTrue(result == 6);
        }
Пример #18
0
        public void CalculateTest()
        {
            //Arrange
            AreaCalculator calcTest     = new AreaCalculator();
            NewShape       newShapeTest = new NewShape();

            calcTest.AddShape(newShapeTest);

            //Act
            double[] testVar = { 1, 2 };

            // Assert
            Assert.IsTrue(calcTest.Calculate("test", testVar) == 999);
        }
Пример #19
0
        public static void Main(string[] args)
        {
            var square     = new Square(4);
            var calculator = new AreaCalculator();
            var area       = calculator.Calculate(square);

            Console.WriteLine($"Square with a side of 4 has an area of {area}");

            #region moar
            //double* ptr;
            //ptr = &area;

            //// displaying value of area using pointer
            //Console.WriteLine("The value of area using a pointer is " + *ptr);
            #endregion
        }
Пример #20
0
        public void AreaCalculatorWithoutDefaultsTest()
        {
            var areaCalculator = new AreaCalculator(false);

            Assert.Throws <ArgumentException>(() => areaCalculator.Calculate(3));
            areaCalculator.AddShapeSidesCountConformity(1, typeof(Circle));
            Assert.AreEqual(Math.Round(areaCalculator.Calculate(3), 2), 28.27d);

            Assert.Throws <ArgumentException>(() => areaCalculator.Calculate(3, 4, 5));
            areaCalculator.AddShapeSidesCountConformity(3, typeof(Triangle));
            Assert.AreEqual(Math.Round(areaCalculator.Calculate(3, 4, 5), 2), 6);

            areaCalculator.RemoveShapeSidesCountConformity(1);
            Assert.Throws <ArgumentException>(() => areaCalculator.Calculate(3));
            areaCalculator.RemoveShapeSidesCountConformity(3);
            Assert.Throws <ArgumentException>(() => areaCalculator.Calculate(3, 4, 5));
        }
 public void Notify()
 {
     areaCalculator.Calculate();
 }