public void Scanner_MockScannerIsInternalInstallOnly() { var sut = new MockBotFactory().CreateBasicMockBot().WithMockActionProvider().WithItemSupport().ToBot(); EquipmentInstallationResult ae = sut.InstallEquipment(KnownEquipmentIds.MOCKSCANNER, "FriendlyName", MountPoint.Internal); Assert.True(ae.InstanceId != Guid.Empty, "The scanner must be installed successfully"); }
public void Equipment_InstallNoPrepare_Blows() { Assert.Throws <BdBaseException>(() => { var sut = new MockBotFactory().CreateBasicMockBot().ToBot(); sut.InstallEquipment(KnownEquipmentIds.MOCKINSTALLEVERYWHERE, "FriendlyName", MountPoint.Internal); }); }
public void Equipment_InstallBadIdentity_Blows() { Assert.Throws <BdBaseException>(() => { var sut = new MockBotFactory().CreateBasicMockBot().ToBot(); sut.InstallEquipment(-1, "FriendlyName", MountPoint.Internal); }); }
public void Equipment_UseByName_InvalidNAmeBlows() { Assert.Throws <BdBaseException>(() => { var sut = new MockBotFactory().CreateBasicMockBot().WithItemSupport().WithMockActionProvider().ToBot(); var ai = sut.InstallEquipment(KnownEquipmentIds.MOCKINSTALLEVERYWHERE, "DummyUseEquipment1", MountPoint.Internal); var result = sut.UseEquipment("monkey fish"); }); }
public void Equipment_InstallDuplicateName_Blows() { Assert.Throws <BdBaseException>(() => { var sut = new MockBotFactory().CreateBasicMockBot().WithMockActionProvider().WithItemSupport().ToBot(); sut.InstallEquipment(KnownEquipmentIds.MOCKINSTALLEVERYWHERE, "FriendlyName", MountPoint.Internal); sut.InstallEquipment(KnownEquipmentIds.MOCKINSTALLEVERYWHERE, "FriendlyName", MountPoint.Internal); }); }
public void MockBot_ChangeHeadingSendsTurnMessage() { var mbf = new MockBotFactory().CreateBasicMockBot().WithMockActionProvider(); var sut = mbf.ToBot(); sut.ChangeHeading(15); Assert.True(mbf.MockActionProviderUsed.LastHeadingChangeValue == 15, "The engine should recieve a 15 degree change value"); }
public void StartsAlive() { var mbf = new MockBotFactory(); MockMappedBot atk = new MockMappedBot(mbf.CreateBasicMockBot().ToBot()); atk.Test_Initialise(); Assert.True(atk.IsAlive()); }
public void MockBot_SetDirectionToPoint_CalculatesSimpleCorrectly() { var mbf = new MockBotFactory().CreateBasicMockBot().WithMockActionProvider(); var sut = mbf.ToBot(); sut.HeadToPoint(new Point(2, 2)); Assert.Equal(45, mbf.MockActionProviderUsed.LastHeadingChangeValue); }
public void Equipment_InstallWrongExternal_ReturnsCorrectError() { var sut = new MockBotFactory().CreateBasicMockBot().WithMockActionProvider().WithItemSupport().ToBot(); var kit = sut.InstallEquipment(KnownEquipmentIds.MOCKINSTALLINTERNALONLY, "Teste Equipment1", MountPoint.Forward); Assert.NotNull(kit); Assert.Equal(InstallationResult.Fail_InvalidMountpoint, kit.Result); }
public void MockBot_DecellerateSendsDecelerateMessage() { var fac = new MockBotFactory().CreateBasicMockBot().WithMockActionProvider(); var sut = fac.ToBot(); sut.Decelerate(); Assert.True(fac.MockActionProviderUsed.LastSpeedChangeValue == -1, "The engine should recieve a -1 speed change when accelerate is called"); }
public void Equipment_UseByGuid_Works() { var sut = new MockBotFactory().CreateBasicMockBot().WithItemSupport().WithMockActionProvider().ToBot(); var ai = sut.InstallEquipment(KnownEquipmentIds.MOCKINSTALLEVERYWHERE, "DummyUseEquipment1", MountPoint.Internal); var result = sut.UseEquipment(ai.InstanceId); Assert.True(result.State == UsageEndState.Success, "The usage must be a success"); }
public void Equipment_UseWithInvalidGuid_Blows() { Assert.Throws <BdBaseException>(() => { Guid g = Guid.NewGuid(); var sut = new MockBotFactory().CreateBasicMockBot().ToBot(); sut.UseEquipment(g); }); }
public void MockBot_AccellerateCallsEngineAccelerate() { var engineHub = new MockBotActionProvider(); var fac = new MockBotFactory().CreateBasicMockBot().WithMockActionProvider(); var sut = fac.ToBot(); sut.Accelerate(); Assert.Equal(1, fac.MockActionProviderUsed.LastSpeedChangeValue); }
public void Equipment_MountTwoPowerpacks_SecondFails() { var sut = new MockBotFactory().CreateBasicMockBot().WithMockActionProvider().WithItemSupport().ToBot(); var r1 = sut.InstallEquipment(KnownEquipmentIds.MOCKPOWERPACK, "PP1", MountPoint.Internal); var r2 = sut.InstallEquipment(KnownEquipmentIds.MOCKPOWERPACK, "PP2", MountPoint.Internal); Assert.NotNull(r1); Assert.Null(r2); }
public void Equipment_GtePowerpack_GetsPowerpack() { var sut = new MockBotFactory().CreateBasicMockBot().WithMockActionProvider().WithItemSupport().ToBot(); sut.InstallEquipment(KnownEquipmentIds.MOCKPOWERPACK, "PP", MountPoint.Internal); var pp = sut.GetPowerPack(); Assert.NotNull(pp); Assert.True(pp.EquipmentId == KnownEquipmentIds.MOCKPOWERPACK, "The wrong equipment was installed"); }
public void Equipment_TooBigForTurrent_FailsToInstall() { var sut = new MockBotFactory().CreateBasicMockBot().WithMockActionProvider().WithItemSupport().ToBot(); var kit = sut.InstallEquipment(KnownEquipmentIds.MOCKWAYTOOBIG, "Test Equipment1", MountPoint.Turret); BasicMockBot bmb = (BasicMockBot)sut; Assert.NotNull(kit); Assert.Equal(InstallationResult.Fail_NoSpace, kit.Result); }
public void Equipment_Install_ReturnsSuccess() { var sut = new MockBotFactory().CreateBasicMockBot().WithMockActionProvider().WithItemSupport().ToBot(); BasicMockBot bmb = (BasicMockBot)sut; int preInstall = bmb.GetEquipmentCount(); var kit = sut.InstallEquipment(KnownEquipmentIds.MOCKINSTALLEVERYWHERE, "Teste Equipment1", MountPoint.Internal); Assert.NotNull(kit); Assert.Equal(InstallationResult.Installed, kit.Result); }
public static mockBd2Engine SetupForPowerTests() { var bot = new MockBotFactory().CreateBasicMockBot().WithEquipmentCallback(ab => { ab.InstallEquipment(KnownEquipmentIds.MOCKPOWERPACK, "PP", MountPoint.Internal); }).ToBot(); var tef = new TestEngineFactory().WithDefaultWorld().WithBot(bot).WithBotSupport().WithEquipmentSupport(); var sut = tef.ToMockEngine(); sut.RegisterForMessages(); PowerPackEquipmentItem ppi = (PowerPackEquipmentItem)tef.EngineSuppliedEquipmentSupport.GetEquipmentTypeById(KnownEquipmentIds.MOCKPOWERPACK); sut.StartBattle(); return sut; }
public void Equipment_Install_AddsToCount() { var sut = new MockBotFactory().CreateBasicMockBot().WithMockActionProvider().WithItemSupport().ToBot(); BasicMockBot bmb = (BasicMockBot)sut; int preInstall = bmb.GetEquipmentCount(); var kit = sut.InstallEquipment(KnownEquipmentIds.MOCKINSTALLEVERYWHERE, "Teste Equipment1", MountPoint.Internal); int postInstall = bmb.GetEquipmentCount(); Assert.Equal(preInstall + 1, postInstall); }
public void Equipment_UseByName_UsesSameItem() { var fac = new MockBotFactory().CreateBasicMockBot().WithItemSupport().WithMockActionProvider(); var sut = fac.ToBot(); var ai = sut.InstallEquipment(KnownEquipmentIds.MOCKINSTALLEVERYWHERE, "DummyUseEquipment1", MountPoint.Internal); Assert.True(ai.Result == InstallationResult.Installed, "The prerequisite for this test is that the equipment installs"); var result = sut.UseEquipment(ai.InstanceId); result = sut.UseEquipment("DummyUseEquipment1"); int ae = fac.MockActionProviderUsed.Mock_GetEquipmentUseCount(ai.InstanceId); Assert.True(result.State == UsageEndState.Success, "The usage must be a success"); Assert.Equal(2, ae); }
public void Equipment_InstallTurret_AddsToTurretCount() { var mbf = new MockBotFactory().CreateBasicMockBot().WithMockActionProvider().WithItemSupport(); var sut = mbf.ToBot(); var map = mbf.MockActionProviderUsed; BasicMockBot bmb = (BasicMockBot)sut; int preInstall = map.Mock_GetEquipmentCountAtPosition(MountPoint.Turret); var kit = sut.InstallEquipment(KnownEquipmentIds.MOCKINSTALLEVERYWHERE, "Teste Equipment1", MountPoint.Turret); int postInstall = map.Mock_GetEquipmentCountAtPosition(MountPoint.Turret); Assert.Equal(preInstall + 1, postInstall); }
public void Bot_FireWeaponPassesScanResultAsIParam() { Guid weaponGuid = Guid.Empty; var mbf = new MockBotFactory().CreateBasicMockBot().WithItemSupport().WithMockActionProvider().WithItemSupport().WithEquipmentCallback(bb => { var ae = bb.InstallEquipment(KnownEquipmentIds.MOCKPROJECTILEWEAPON, "test", MountPoint.Turret); Assert.NotNull(ae); weaponGuid = ae.InstanceId; }); var sut = mbf.ToBot(); var eur = sut.FireWeapon(3, "test"); var eud = mbf.MockActionProviderUsed.Mock_GetMostRecentEUD(); var ap = mbf.MockActionProviderUsed.Mock_GetEquipemntByGuid(weaponGuid); Assert.Equal(UsageEndState.Success, eur.State); Assert.True(eud.IParam == 3); Assert.True(eud.InstanceIdentity == weaponGuid); }
public void MockBot_AccellerateCallsReadSpeedMessage() { Hub testHub = new Hub(true); var actionProvider = new bd2MessageBasedBotSupport(); actionProvider.InjectHub(testHub); bool messageRecieved = false; testHub.LookFor <Message_Query>(ab => { if (ab.SubKind == KnownSubkinds.ReadSpeed) { messageRecieved = true; NavigationInfoContext nic = new NavigationInfoContext(); nic.SpeedDelta = 1; ab.ResponseContext = nic; } }); var sut = new MockBotFactory().CreateBasicMockBot().WithThisActionProvider(actionProvider, actionProvider).ToBot(); sut.Accelerate(); Assert.True(messageRecieved, "The query speed message was not requested by the accelerate function"); }
public void FullResolve_DoesHit() { b.Info.Flow(); var mckRand = new MockBd2Randomiser(); mckRand.Mock_SetD100Result(0); mckRand.Mock_SetD10Result(100); mckRand.Mock_SetCanTargetHit(true); MockBd2Map mp = new MockBd2Map(); MockBd2World wld = new MockBd2World(mp); wld.Test_LOSCanHitReturn(true); var sut = new CombatManager(wld, mckRand); var mbf = new MockBotFactory(); var atk = new MockMappedBot(mbf.CreateBasicMockBot().ToBot()); atk.Test_Initialise(); var vic = new MockMappedBot(mbf.CreateBasicMockBot().ToBot()); vic.Test_Initialise(); var mw = new MockWeapon(); CombatAttack ca = new CombatAttack(); ca.Attacker = atk; ca.Victim = vic; ca.Weapon = mw; ca.WeaponInstance = new ActiveEquipment(mw); ca.WeaponInstance.MountPoint = MountPoint.Turret; var res = sut.ResolveAttack(ca); Assert.NotNull(res); Assert.True(res.DidHit); }
private ScanEquipmentUseResult GetDefinedScanResult(int definedResult, bool includeSecondBot = false) { Hub testHub = new Hub(); var scanningBot = new MockBotFactory().CreateBasicMockBot().WithMockPack().ToBot(); var scannedBot = new MockBotFactory().CreateBasicMockBot().WithMockPack().ToBot(); TestEngineFactory tef = new TestEngineFactory().WithHub(testHub).WithDefaultWorld().WithEquipmentSupport().WithBotSupport().WithBot(scanningBot); if (includeSecondBot) { tef = tef.WithBot(scannedBot); } var engx = tef.WithPrepare().ToMockEngine(); engx.PerformNextTick(); engx.Mock_DirectSetBotLocation(scanningBot.PublicId, new Point(99, 99)); // Set bot to top right of the map. if (includeSecondBot) { engx.Mock_DirectSetBotLocation(scannedBot.PublicId, new Point(97, 99)); // Set bot to top right of the map. } bd2Engine ee = (bd2Engine)engx; var ae = scanningBot.InstallEquipment(KnownEquipmentIds.MOCKSCANNER, "FriendlyName", MountPoint.Internal); engx.Mock_DirectSetBotCharge(scanningBot.PublicId, 100); var result = scanningBot.UseEquipment(ae.InstanceId); ScanEquipmentUseResult resASR = (ScanEquipmentUseResult)result; Assert.Equal <UsageEndState>(UsageEndState.Success, resASR.State); return(resASR); }
public void MockBot_AccellerateCallsAccellerateMessage() { var testHub = new Hub(true); testHub.UseStrongReferences = true; var engineHub = new bd2MessageBasedBotSupport(); engineHub.InjectHub(testHub); bool messageRecieved = false; int valueChange = 0; testHub.LookFor <Message_Query>(ab => { if (ab.SubKind == KnownSubkinds.ReadSpeed) { NavigationInfoContext nic = new NavigationInfoContext(); nic.SpeedDelta = 1; ab.ResponseContext = nic; } }); testHub.LookFor <Message_BotPerformAction>(ab => { if (ab.SubKind == KnownSubkinds.ChangeSpeed) { messageRecieved = true; NavigationInfoContext nic = (NavigationInfoContext)ab.RequestContext; Assert.NotNull(nic); valueChange = nic.SpeedDelta; } }); var sut = new MockBotFactory().CreateBasicMockBot().WithThisActionProvider(engineHub, engineHub).ToBot(); sut.Accelerate(); Assert.True(messageRecieved, "The accellerate call did not send the change speed request message"); Assert.True(valueChange == 1, "The accelerate value should be 1"); }