NerfUS mobile node that manages a target for the Nerf gun firing range
Dependencies: LedController mbed-rtos mbed NerfUSXbee Servomotor TargetManager
Fork of NerfUS by
TESTS/TargetManagerTest.cpp@31:c6dc9811ed14, 2017-03-27 (annotated)
- Committer:
- Maxime Dupuis
- Date:
- Mon Mar 27 19:10:07 2017 -0400
- Revision:
- 31:c6dc9811ed14
- Parent:
- 30:412a779cf607
- Child:
- 32:50b777bab5a4
Ignore target hits and misses on inactive targets
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Maxime Dupuis |
28:8fc53a870691 | 1 | #include "gmock/gmock.h" |
Maxime Dupuis |
28:8fc53a870691 | 2 | #include "gtest/gtest.h" |
Maxime Dupuis |
28:8fc53a870691 | 3 | |
Maxime Dupuis |
30:412a779cf607 | 4 | #include "mocks/MockNerfusTicker.hpp" |
Maxime Dupuis |
28:8fc53a870691 | 5 | #include "mocks/MockTarget.hpp" |
Maxime Dupuis |
28:8fc53a870691 | 6 | #include "TargetManager.hpp" |
Maxime Dupuis |
28:8fc53a870691 | 7 | |
Maxime Dupuis |
28:8fc53a870691 | 8 | class TargetManagerTest : public ::testing::Test |
Maxime Dupuis |
28:8fc53a870691 | 9 | { |
Maxime Dupuis |
28:8fc53a870691 | 10 | public: |
Maxime Dupuis |
28:8fc53a870691 | 11 | TargetManagerTest() |
Maxime Dupuis |
28:8fc53a870691 | 12 | { |
Maxime Dupuis |
30:412a779cf607 | 13 | targets.push_back(&mock_target_a); |
Maxime Dupuis |
30:412a779cf607 | 14 | targets.push_back(&mock_target_b); |
Maxime Dupuis |
28:8fc53a870691 | 15 | } |
Maxime Dupuis |
28:8fc53a870691 | 16 | |
Maxime Dupuis |
30:412a779cf607 | 17 | MockTarget mock_target_a; |
Maxime Dupuis |
30:412a779cf607 | 18 | MockTarget mock_target_b; |
Maxime Dupuis |
30:412a779cf607 | 19 | std::vector<TargetInterface*> targets; |
Maxime Dupuis |
30:412a779cf607 | 20 | |
Maxime Dupuis |
30:412a779cf607 | 21 | MockNerfusTicker mock_nerfus_ticker; |
Maxime Dupuis |
28:8fc53a870691 | 22 | }; |
Maxime Dupuis |
28:8fc53a870691 | 23 | |
Maxime Dupuis |
28:8fc53a870691 | 24 | TEST_F(TargetManagerTest, LibraryBuilds) |
Maxime Dupuis |
28:8fc53a870691 | 25 | { |
Maxime Dupuis |
30:412a779cf607 | 26 | TargetManager target_manager(targets, mock_nerfus_ticker); |
Maxime Dupuis |
28:8fc53a870691 | 27 | } |
Maxime Dupuis |
28:8fc53a870691 | 28 | |
Maxime Dupuis |
31:c6dc9811ed14 | 29 | TEST_F(TargetManagerTest, WhenNoTargetIsActiveThenCallsToTargetHitAndTargetMissedDoNothing) |
Maxime Dupuis |
31:c6dc9811ed14 | 30 | { |
Maxime Dupuis |
31:c6dc9811ed14 | 31 | TargetManager target_manager(targets, mock_nerfus_ticker); |
Maxime Dupuis |
31:c6dc9811ed14 | 32 | |
Maxime Dupuis |
31:c6dc9811ed14 | 33 | target_manager.target_missed(0); |
Maxime Dupuis |
31:c6dc9811ed14 | 34 | target_manager.target_hit(0); |
Maxime Dupuis |
31:c6dc9811ed14 | 35 | } |