Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HELLoWorld
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hall of Fame
HELLoWorld
Commits
7f1cff42
Commit
7f1cff42
authored
3 years ago
by
Balog Lóránd
Browse files
Options
Downloads
Patches
Plain Diff
Added more tests
parent
c019de06
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!43
Tests
Pipeline
#17482
passed
3 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
HELLo_World.Test/GameTest.cs
+149
-15
149 additions, 15 deletions
HELLo_World.Test/GameTest.cs
with
149 additions
and
15 deletions
HELLo_World.Test/GameTest.cs
+
149
−
15
View file @
7f1cff42
...
@@ -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
GameSpeedTest
Start
()
{
{
_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
NumberOfRepairmen
ExceptionTest
()
public
void
NumberOfRepairmen
InvalidNumber
()
{
{
_model
.
NewGame
(
"test"
);
_model
.
NewGame
(
"test"
);
_model
.
NumberOfRepairmen
=
-
3
;
_model
.
NumberOfRepairmen
=
-
3
;
}
}
#
endregion
#
region
ParkStatus
tests
[
TestMethod
]
[
TestMethod
]
public
void
ParkStatusSet
Test
()
public
void
ParkStatusSet
Open
()
{
{
_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
GetVisitorInfoInval
i
dTest
()
public
void
GetVisitorInfoInval
I
dTest
()
{
{
_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
AdvanceTimeT
est
()
public
void
AdvanceTimeT
imeChanged
()
{
{
_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
Set
ter
method
tests
#
region
Set
Ticket
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
SetTicketValidValue
Test
()
public
void
SetTicketValidValue
Increase
()
{
{
_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
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment