public void InitServices() { this.services = new ServiceCollection() .AddLogging() .AddSingleton <IDiceUtility, MockDice>() // Always rolls sixes on d6; always rolls 99 on d100 .BuildServiceProvider(); this.weapon = new BeamBatterySystem(3, "(All arcs)"); this.weaponAllocation = new GameUnitFireAllocation(); this.distanceGraph = new FormationDistanceGraph(); this.totalDummy = new TestDummyActor(this.services); this.phaseDummy = new TestDummyPhaseActor(this.services); this.engine = new EventHandlingEngine(); this.phaseEvent = new FiringPhaseEvent(1, 1, this.distanceGraph) as GamePhaseEvent; this.attackEvent = new WeaponAttackEvent(new TargetingData(), new AttackData(this.weapon, this.weaponAllocation)); }
public void TestDummyActorEventHandlerTypeRouting() { // Processes pretty much nothing var totalDummy = new TestDummyActor(this.services); // Processes GamePhase, FiringPhase, and WeaponAttack events var phaseDummy = new TestDummyPhaseActor(this.services); var actors = new List <IEventActor>() { totalDummy, phaseDummy }; this.engine.ExecuteGamePhase(actors, this.phaseEvent, 1, 1); Assert.AreEqual(1, phaseDummy.EventReceivedCount); Assert.AreEqual(1, phaseDummy.GamePhaseEventDetectedCount); Assert.AreEqual(0, phaseDummy.WeaponAttackEventDetectedCount); Assert.AreEqual(0, phaseDummy.TestDummyActorEventReceivedCount); Assert.AreEqual(1, totalDummy.EventReceivedCount); Assert.AreEqual(0, totalDummy.TestDummyActorEventReceivedCount); }