From 5eb7f9796b56d93bc716e51345ebbeaf6fcbfc0d Mon Sep 17 00:00:00 2001 From: mo k Date: Wed, 30 May 2012 21:58:02 -0600 Subject: override each template method and publish event. --- src/core/RoboMom.cs | 30 +++++++++++------------------- src/specs/Mock.cs | 12 ++++++++++++ src/specs/RoboMomSpecs.cs | 9 --------- src/specs/specs.csproj | 1 + 4 files changed, 24 insertions(+), 28 deletions(-) create mode 100755 src/specs/Mock.cs diff --git a/src/core/RoboMom.cs b/src/core/RoboMom.cs index 50d577e..6a23a7d 100755 --- a/src/core/RoboMom.cs +++ b/src/core/RoboMom.cs @@ -13,11 +13,6 @@ namespace core public override void Run() { - while(true) - { - TurnLeft(10); - Ahead(5); - } } public override void OnBulletHit(BulletHitEvent evnt) @@ -27,60 +22,57 @@ namespace core public override void OnBulletHitBullet(BulletHitBulletEvent evnt) { - base.OnBulletHitBullet(evnt); + publisher.Publish(evnt); } public override void OnBulletMissed(BulletMissedEvent evnt) { - base.OnBulletMissed(evnt); + publisher.Publish(evnt); } public override void OnDeath(DeathEvent evnt) { - base.OnDeath(evnt); + publisher.Publish(evnt); } public override void OnHitByBullet(HitByBulletEvent evnt) { - base.OnHitByBullet(evnt); + publisher.Publish(evnt); } public override void OnHitRobot(HitRobotEvent evnt) { - base.OnHitRobot(evnt); + publisher.Publish(evnt); } public override void OnHitWall(HitWallEvent evnt) { - base.OnHitWall(evnt); - TurnRight(180); + publisher.Publish(evnt); } public override void OnRobotDeath(RobotDeathEvent evnt) { - base.OnRobotDeath(evnt); + publisher.Publish(evnt); } public override void OnScannedRobot(ScannedRobotEvent evnt) { - base.OnScannedRobot(evnt); - TurnGunLeft(Heading - evnt.Bearing); - Fire(10); + publisher.Publish(evnt); } public override void OnWin(WinEvent evnt) { - base.OnWin(evnt); + publisher.Publish(evnt); } public override void OnRoundEnded(RoundEndedEvent evnt) { - base.OnRoundEnded(evnt); + publisher.Publish(evnt); } public override void OnBattleEnded(BattleEndedEvent evnt) { - base.OnBattleEnded(evnt); + publisher.Publish(evnt); } public override bool IsAdjustGunForRobotTurn diff --git a/src/specs/Mock.cs b/src/specs/Mock.cs new file mode 100755 index 0000000..cd59a6a --- /dev/null +++ b/src/specs/Mock.cs @@ -0,0 +1,12 @@ +using Rhino.Mocks; + +namespace specs +{ + public static class Mock + { + public static T An() where T : class + { + return MockRepository.GenerateMock(); + } + } +} \ No newline at end of file diff --git a/src/specs/RoboMomSpecs.cs b/src/specs/RoboMomSpecs.cs index d20b81b..0869299 100755 --- a/src/specs/RoboMomSpecs.cs +++ b/src/specs/RoboMomSpecs.cs @@ -16,7 +16,6 @@ namespace specs static RoboMom sut; static IPublishEvents publisher; - public class when_hit { It should_publish_the_event = () => @@ -37,12 +36,4 @@ namespace specs static BulletHitEvent message; } } - - public static class Mock - { - public static T An() where T : class - { - return MockRepository.GenerateMock(); - } - } } \ No newline at end of file diff --git a/src/specs/specs.csproj b/src/specs/specs.csproj index 0d7bef0..c1a7786 100755 --- a/src/specs/specs.csproj +++ b/src/specs/specs.csproj @@ -53,6 +53,7 @@ + -- cgit v1.2.3