Skip to content
Snippets Groups Projects
Commit 7f1cff42 authored by Balog Lóránd's avatar Balog Lóránd
Browse files

Added more tests

parent c019de06
No related branches found
No related tags found
1 merge request!43Tests
Pipeline #17482 passed
...@@ -67,43 +67,101 @@ namespace HELLo_World.Test ...@@ -67,43 +67,101 @@ namespace HELLo_World.Test
#endregion #endregion
#region Property tests #region Speed tests
[TestMethod] [TestMethod]
public void GameSpeedTest() public void GameSpeedTestStart()
{ {
_model.NewGame("test"); _model.NewGame("test");
_model.GameSpeed = Speed.SLOW; Assert.AreEqual(Speed.PAUSE, _model.GameSpeed);
_model.GameSpeed = Speed.NORMAL;
Assert.AreEqual(Speed.SLOW, _model.GameSpeed); Assert.AreEqual(Speed.NORMAL, _model.GameSpeed);
}
[TestMethod]
public void GameSpeedTestPause()
{
_model.NewGame("test");
_model.GameSpeed = Speed.NORMAL;
_model.GameSpeed = Speed.PAUSE; _model.GameSpeed = Speed.PAUSE;
Assert.AreEqual(Speed.PAUSE, _model.GameSpeed); Assert.AreEqual(Speed.PAUSE, _model.GameSpeed);
} }
[TestMethod] [TestMethod]
public void NumberOfRepairmenTest() public void GameSpeedTestSpeedUp()
{
_model.NewGame("test");
_model.GameSpeed = Speed.NORMAL;
_model.GameSpeed = Speed.FAST;
Assert.AreEqual(Speed.FAST, _model.GameSpeed);
}
[TestMethod]
public void GameSpeedTestSlowDown()
{
_model.NewGame("test");
_model.GameSpeed = Speed.NORMAL;
_model.GameSpeed = Speed.SLOW;
Assert.AreEqual(Speed.SLOW, _model.GameSpeed);
}
#endregion
#region Repairmen tests
[TestMethod]
public void NumberOfRepairmenIncrease()
{
_model.NewGame("test");
_model.NumberOfRepairmen = 3;
Assert.AreEqual(3, _model.NumberOfRepairmen);
foreach (var repairmen in _model.GameMap.Repairmen)
{
Assert.AreEqual(repairmen.Coord.Item1, 14);
Assert.AreEqual(repairmen.Coord.Item2, 7);
}
_model.NumberOfRepairmen = 5;
Assert.AreEqual(5, _model.NumberOfRepairmen);
}
[TestMethod]
public void NumberOfRepairmenDecrease()
{ {
_model.NewGame("test"); _model.NewGame("test");
_model.NumberOfRepairmen = 3; _model.NumberOfRepairmen = 3;
Assert.AreEqual(3, _model.NumberOfRepairmen); Assert.AreEqual(3, _model.NumberOfRepairmen);
_model.NumberOfRepairmen = 1;
Assert.AreEqual(1, _model.NumberOfRepairmen);
}
_model.NumberOfRepairmen = 2; [TestMethod]
Assert.AreEqual(2, _model.NumberOfRepairmen); public void NumberOfRepairmenSetToZero()
{
_model.NewGame("test");
_model.NumberOfRepairmen = 3;
Assert.AreEqual(3, _model.NumberOfRepairmen);
_model.NumberOfRepairmen = 0;
Assert.AreEqual(0, _model.NumberOfRepairmen);
} }
[TestMethod] [TestMethod]
[ExpectedException(typeof(ArgumentException))] [ExpectedException(typeof(ArgumentException))]
public void NumberOfRepairmenExceptionTest() public void NumberOfRepairmenInvalidNumber()
{ {
_model.NewGame("test"); _model.NewGame("test");
_model.NumberOfRepairmen = -3; _model.NumberOfRepairmen = -3;
} }
#endregion
#region ParkStatus tests
[TestMethod] [TestMethod]
public void ParkStatusSetTest() public void ParkStatusSetOpen()
{ {
_model.NewGame("test"); _model.NewGame("test");
_model.ParkStatus = ParkStatus.OPEN; _model.ParkStatus = ParkStatus.OPEN;
...@@ -111,6 +169,29 @@ namespace HELLo_World.Test ...@@ -111,6 +169,29 @@ namespace HELLo_World.Test
Assert.AreEqual(ParkStatus.OPEN, _model.ParkStatus); Assert.AreEqual(ParkStatus.OPEN, _model.ParkStatus);
} }
[TestMethod]
public void ParkStatusSetClosed()
{
_model.NewGame("test");
_model.ParkStatus = ParkStatus.OPEN;
_model.ParkStatus = ParkStatus.CLOSED;
Assert.AreEqual(ParkStatus.CLOSED, _model.ParkStatus);
}
[TestMethod]
public void ParkStatusSetClosedVisitorsLeaving()
{
_model.NewGame("test");
_model.ParkStatus = ParkStatus.OPEN;
_model.GameMap.Visitors.Add(new MapData.People.Visitor(1, new Tuple<int, int>(14, 7), new Tuple<int, int>(25, 25)));
_model.GameMap.Visitors.Add(new MapData.People.Visitor(2, new Tuple<int, int>(13, 7), new Tuple<int, int>(12, 45)));
_model.ParkStatus = ParkStatus.CLOSED;
Assert.AreEqual(MapData.People.Activity.ARRIVED_TO_EXIT, _model.GameMap.Visitors[0].CurrentActivity);
Assert.AreEqual(MapData.People.Activity.LEAVING, _model.GameMap.Visitors[1].CurrentActivity);
}
#endregion #endregion
#region Build tests #region Build tests
...@@ -317,7 +398,7 @@ namespace HELLo_World.Test ...@@ -317,7 +398,7 @@ namespace HELLo_World.Test
} }
[TestMethod] [TestMethod]
public void GetVisitorInfoInvalidTest() public void GetVisitorInfoInvalIdTest()
{ {
_model.NewGame("test"); _model.NewGame("test");
VisitorInfo info = _model.GetVisitorInfo(3); VisitorInfo info = _model.GetVisitorInfo(3);
...@@ -329,7 +410,7 @@ namespace HELLo_World.Test ...@@ -329,7 +410,7 @@ namespace HELLo_World.Test
#region AdvanceTime tests #region AdvanceTime tests
[TestMethod] [TestMethod]
public void AdvanceTimeTest() public void AdvanceTimeTimeChanged()
{ {
_model.NewGame("test"); _model.NewGame("test");
_model.Build(new Tuple<int, int>(1,1), 1); _model.Build(new Tuple<int, int>(1,1), 1);
...@@ -339,9 +420,39 @@ namespace HELLo_World.Test ...@@ -339,9 +420,39 @@ namespace HELLo_World.Test
Assert.AreEqual(1, (_model.GameMap.Buildings[1] as Facility).TimeSpentInStatus); Assert.AreEqual(1, (_model.GameMap.Buildings[1] as Facility).TimeSpentInStatus);
} }
[TestMethod]
public void AdvanceTimeVisitorStatusChanged()
{
_model.NewGame("test");
_model.Build(new Tuple<int, int>(12, 7), 0);
_model.Build(new Tuple<int, int>(11, 7), 0);
_model.ParkStatus = ParkStatus.OPEN;
_model.GameSpeed = Speed.FAST;
_model.GameMap.Visitors.Add(new MapData.People.Visitor(1, new Tuple<int, int>(14,7), new Tuple<int, int>(25,25)));
_model.AdvanceTime();
Assert.AreEqual(MapData.People.Activity.WANDERING, _model.GameMap.Visitors[0].CurrentActivity);
}
[TestMethod]
public void AdvanceTimeRepairmenWandering()
{
_model.NewGame("test");
_model.Build(new Tuple<int, int>(12, 7), 0);
_model.Build(new Tuple<int, int>(11, 7), 0);
_model.ParkStatus = ParkStatus.OPEN;
_model.GameSpeed = Speed.FAST;
_model.NumberOfRepairmen = 1;
_model.AdvanceTime();
_model.AdvanceTime();
Assert.AreEqual(MapData.People.Activity.WANDERING, _model.GameMap.Repairmen[0].CurrentActivity);
Assert.AreNotEqual(25, _model.GameMap.Repairmen[0].InTileCoord.Item1);
}
#endregion #endregion
#region Setter method tests #region SetTicket method tests
[TestMethod] [TestMethod]
[ExpectedException(typeof(ArgumentException))] [ExpectedException(typeof(ArgumentException))]
...@@ -352,7 +463,7 @@ namespace HELLo_World.Test ...@@ -352,7 +463,7 @@ namespace HELLo_World.Test
} }
[TestMethod] [TestMethod]
public void SetTicketValidValueTest() public void SetTicketValidValueIncrease()
{ {
_model.NewGame("test"); _model.NewGame("test");
_model.SetTicket(70); _model.SetTicket(70);
...@@ -361,7 +472,20 @@ namespace HELLo_World.Test ...@@ -361,7 +472,20 @@ namespace HELLo_World.Test
} }
[TestMethod] [TestMethod]
public void SetFeeValidTest() public void SetTicketValidValueDecrease()
{
_model.NewGame("test");
_model.SetTicket(20);
Assert.AreEqual(20, _model.GameMap.Ticket);
}
#endregion
#region SetFee method tests
[TestMethod]
public void SetFeeIncreaseFee()
{ {
_model.NewGame("test"); _model.NewGame("test");
_model.Build(new Tuple<int, int>(1, 1), 1); _model.Build(new Tuple<int, int>(1, 1), 1);
...@@ -370,6 +494,16 @@ namespace HELLo_World.Test ...@@ -370,6 +494,16 @@ namespace HELLo_World.Test
Assert.AreEqual(1111, (_model.GameMap.Buildings[1] as Facility).Fee); Assert.AreEqual(1111, (_model.GameMap.Buildings[1] as Facility).Fee);
} }
[TestMethod]
public void SetFeeDecreaseFee()
{
_model.NewGame("test");
_model.Build(new Tuple<int, int>(1, 1), 1);
_model.SetBuildingFee(2, 1);
Assert.AreEqual(1, (_model.GameMap.Buildings[1] as Facility).Fee);
}
[TestMethod] [TestMethod]
[ExpectedException(typeof(ArgumentException))] [ExpectedException(typeof(ArgumentException))]
public void SetFeeInvalidIdTest() public void SetFeeInvalidIdTest()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment