summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo k <mo@mokhan.ca>2012-05-30 21:58:02 -0600
committermo k <mo@mokhan.ca>2012-05-30 21:58:02 -0600
commit5eb7f9796b56d93bc716e51345ebbeaf6fcbfc0d (patch)
tree32cd9cb15cce2c6c9cce42af92402baa517c3a8d
parent959434b36702eb2effe6788d22d1eddea6681d8c (diff)
override each template method and publish event.
-rwxr-xr-xsrc/core/RoboMom.cs30
-rwxr-xr-xsrc/specs/Mock.cs12
-rwxr-xr-xsrc/specs/RoboMomSpecs.cs9
-rwxr-xr-xsrc/specs/specs.csproj1
4 files changed, 24 insertions, 28 deletions
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<T>() where T : class
+ {
+ return MockRepository.GenerateMock<T>();
+ }
+ }
+} \ 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<T>() where T : class
- {
- return MockRepository.GenerateMock<T>();
- }
- }
} \ 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 @@
</ItemGroup>
<ItemGroup>
<Compile Include="EventAggregatorSpec.cs" />
+ <Compile Include="Mock.cs" />
<Compile Include="RoboMomSpecs.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>