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
Revision 51:6bf268cd1a1b, committed 2017-04-12
- Comitter:
- Maxime Dupuis
- Date:
- Wed Apr 12 10:33:32 2017 -0400
- Parent:
- 50:8cf0be9a61db
- Commit message:
- Update tests to ignore target hits before 750ms threshold
Changed in this revision
TESTS/TargetManagerTest.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 8cf0be9a61db -r 6bf268cd1a1b TESTS/TargetManagerTest.cpp --- a/TESTS/TargetManagerTest.cpp Wed Apr 12 14:30:01 2017 +0000 +++ b/TESTS/TargetManagerTest.cpp Wed Apr 12 10:33:32 2017 -0400 @@ -62,14 +62,27 @@ TEST_F(TargetManagerTest, WhenActiveTargetIsHitThenSendTheEvent) { EXPECT_CALL(mock_target_a, ally_command()); - EXPECT_CALL(mock_nerfus_ticker_a, start(1000)); + EXPECT_CALL(mock_nerfus_ticker_a, start(1200)); EXPECT_CALL(mock_nerfus_ticker_a, get_time_ms()) - .WillOnce(::testing::Return(42)); + .WillOnce(::testing::Return(1200)); EXPECT_CALL(mock_nerfus_ticker_a, stop()); - EXPECT_CALL(mock_target_a, hit(42)); + EXPECT_CALL(mock_target_a, hit(1200)); TargetManager target_manager(targets, tickers); - target_manager.execute(make_TargetInfo(0, TARGET_TYPE_ALLY, 1000)); + target_manager.execute(make_TargetInfo(0, TARGET_TYPE_ALLY, 1200)); + + target_manager.target_hit(0); +} + +TEST_F(TargetManagerTest, WhenActiveTargetIsHitTooSoonBefore750MsThenIgnoreTheEvent) +{ + EXPECT_CALL(mock_target_a, ally_command()); + EXPECT_CALL(mock_nerfus_ticker_a, start(700)); + EXPECT_CALL(mock_nerfus_ticker_a, get_time_ms()) + .WillOnce(::testing::Return(700)); + + TargetManager target_manager(targets, tickers); + target_manager.execute(make_TargetInfo(0, TARGET_TYPE_ALLY, 700)); target_manager.target_hit(0); }