-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestFlyingObject.cs
121 lines (112 loc) · 5.97 KB
/
TestFlyingObject.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Minecraft.Models;
using Minecraft.Control;
using System;
using System.Collections.Generic;
using System.Drawing;
namespace UnitTestProject1
{
[TestClass]
public class QuadraticEquatonSolverTest
{
private readonly int[,] map ={ { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2 },{2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,2},{2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,2},{ 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,2},
{ 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,2},{ 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,2},{ 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,2},{ 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,2},
{ 2,0,0,0,0,0,0,6,6,6,6,0,0,0,0,0,0,0,1,1,2},{ 2,0,0,0,0,0,6,6,0,0,6,6,0,0,0,0,0,0,1,1,2},{ 2,0,0,0,0,0,6,0,0,0,0,6,0,0,0,0,0,0,1,1,2}};
private readonly int[] decorationObject = { 0, 4, 5 };
List<ICreature> creatures = new List<ICreature>();
List<GlowingBalls> flyingObjects = new List<GlowingBalls>();
[TestMethod]
public void startPointIsFinishPoint()
{
var flyingObject = new GlowingBalls(new Point() { X = 0, Y = 0 }, new Point() { X = 0, Y = 0 }, "player", 40,map,decorationObject);
Assert.AreEqual(flyingObject.GetPosition(), new Point() { X = 0, Y = 0 });
}
[TestMethod]
public void FinsihPointInFourSquare()
{
var flyingObject = new GlowingBalls(new Point() { X = 100, Y = 200 }, new Point() { X = 200, Y = 250 }, "player", 40,map,decorationObject);
var player = new Player(new Point() { X = 0, Y = 0 });
var position = new Point() { X = 0, Y = 0 };
while (!flyingObject.IsDied(creatures, flyingObjects, player, map, decorationObject))
{
position = flyingObject.GetPosition();
}
Assert.AreEqual(true, IsPointIntoArea(new Point() { X = 200, Y = 250 }, position, 50));
}
[TestMethod]
public void FinishPointInThreeSquare()
{
var flyingObject = new GlowingBalls(new Point() { X = 400, Y = 200 }, new Point() { X = 200, Y = 250 }, "player", 40,map,decorationObject);
var player = new Player(new Point() { X = 0, Y = 0 });
var position = new Point() { X = 0, Y = 0 };
while (!flyingObject.IsDied(creatures, flyingObjects, player, map, decorationObject))
{
position = flyingObject.GetPosition();
}
Assert.AreEqual(true, IsPointIntoArea(new Point() { X = 200, Y = 250}, position, 50));
}
[TestMethod]
public void FinishPointInFourSquare()
{
var flyingObject = new GlowingBalls(new Point() { X = 400, Y = 140 }, new Point() { X = 400, Y = 200 }, "player", 40,map,decorationObject);
var player = new Player(new Point() { X = 0, Y = 0 });
var position = new Point() { X = 0, Y = 0 };
while (!flyingObject.IsDied(creatures, flyingObjects, player, map, decorationObject))
{
position = flyingObject.GetPosition();
}
Assert.AreEqual(true, IsPointIntoArea(new Point() { X = 400, Y = 200 }, position, 50));
}
[TestMethod]
public void FinishPointIsOneSquare()
{
var flyingObject = new GlowingBalls(new Point() { X = 321, Y = 441 }, new Point() { X = 464, Y = 433 }, "player", 40,map,decorationObject);
var player = new Player(new Point() { X = 0, Y = 0 });
var position = new Point() { X = 0, Y = 0 };
while (!flyingObject.IsDied(creatures, flyingObjects, player, map, decorationObject))
{
position = flyingObject.GetPosition();
}
Assert.AreEqual(true, IsPointIntoArea(new Point() { X = 464, Y = 433 }, position, 50));
}
[TestMethod]
public void TestSoleveRandom()
{
var flyingObject = new GlowingBalls(new Point() { X = 321, Y = 441 }, new Point() { X = 464, Y = 433 }, "player", 40,map,decorationObject);
var player = new Player(new Point() { X = 0, Y = 0 });
var position = new Point() { X = 0, Y = 0 };
while (!flyingObject.IsDied(creatures, flyingObjects, player, map, decorationObject))
{
position = flyingObject.GetPosition();
}
Assert.AreEqual(true, IsPointIntoArea(new Point() { X = 464, Y = 433 }, position, 50));
}
[TestMethod]
public void IsAddGlowingBall()
{
var creatures = new List<ICreature>();
var screen = new ScreenPoint(new Point() { X = 0, Y = 0 });
var player = new Player(new Point() { X = 200, Y = 1020 });
var glowingBalls = new List<GlowingBalls>();
new Point() { X = 500, Y = 1020 }.DoAction(Trials.MainTrial, creatures, screen, player, glowingBalls, 1000, map, decorationObject);
Assert.IsTrue(glowingBalls.Count == 1);
}
[TestMethod]
public void TestSolveRandom2()
{
var flyingObject = new GlowingBalls(new Point() { X = 300, Y = 300 }, new Point() { X = 400, Y = 200 }, "player", 40,map,decorationObject);
var player = new Player(new Point() { X = 0, Y = 0 });
var position = new Point() { X = 0, Y = 0 };
while (!flyingObject.IsDied(creatures, flyingObjects, player, map, decorationObject))
{
position = flyingObject.GetPosition();
}
Assert.AreEqual(true, IsPointIntoArea(new Point() { X = 400, Y = 200 }, position, 50));
}
private bool IsPointIntoArea(Point areaPoint, Point objectPoint, int sizeArea)
{
return Math.Abs(areaPoint.X - objectPoint.X) <= sizeArea
&& Math.Abs(objectPoint.Y - objectPoint.Y) <= sizeArea;
}
}
}