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); }
// 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); }
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}"); }
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)); }
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)); }
public void CalculateSquareAreaTest() { double triangleArea = 64; Shape square = new Square(8); Calculator calculator = new AreaCalculator(); Assert.AreEqual(triangleArea, Math.Round(calculator.Calculate(square), 2)); }
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)); }
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)); }
public void CalculateCircleAreaTest() { double circleArea = 94.985; Shape circle = new Circle(5.5); Calculator calculator = new AreaCalculator(); Assert.AreEqual(circleArea, calculator.Calculate(circle)); }
public void CalculateWithNoNameTest2() { //Arrange AreaCalculator calcTest = new AreaCalculator(); double[] var = { 3, 4, 5 }; //Act /Assert Assert.True(calcTest.Calculate(var) == 6); }
public void CalculateWithNoNameTest1() { //Arrange AreaCalculator calcTest = new AreaCalculator(); double[] var = { 1 }; //Act /Assert Assert.True(calcTest.Calculate(var) == 3.141592); }
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 "); }
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")); }
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")); }
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")); }
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")); }
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); }
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); }
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 }
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(); }