public void TestMethod1() { WbsEngine engine = new WbsEngine(); Unit guardsman = UnitFactory.Createguardsman(); Weapon lasgun = UnitFactory.Createlasgun(); Unit fireWarrior = UnitFactory.Createfirewarrior(); // Act double killRatio = engine.DoBattle(guardsman, lasgun, fireWarrior, 10000); killRatio = killRatio * 100; // Assert //Assert.IsTrue(killRatio > 0.5 && killRatio <0.51); Console.WriteLine($"Kill ratio in percent: {killRatio}"); }
public void SavingThrow_Fail(int diceRoll, bool result) { IDice dice = A.Fake <IDice>(); A.CallTo(() => dice.Roll()).Returns(diceRoll); WbsEngine engine = new WbsEngine(dice); Weapon lasgun = UnitFactory.Createlasgun(); Unit fireWarrior = UnitFactory.Createfirewarrior(); // Act bool save = engine.WasSaved(lasgun, fireWarrior); // Assert Assert.AreEqual(save, result); }
public void WoundRoll() { // Arrange IDice dice = A.Fake <IDice>(); A.CallTo(() => dice.Roll()).Returns(1); WbsEngine engine = new WbsEngine(dice); Weapon lasgun = UnitFactory.Createlasgun(); Unit fireWarrior = UnitFactory.Createfirewarrior(); // Act bool wound = engine.Wound(lasgun, fireWarrior); // Assert Assert.IsFalse(wound); }
public void Hit_Test(int diceRoll, bool result) { // Arrange IDice dice = A.Fake <IDice>(); A.CallTo(() => dice.Roll()).Returns(diceRoll); WbsEngine engine = new WbsEngine(dice); Unit guardsman = UnitFactory.Createguardsman(); Unit fireWarrior = UnitFactory.Createfirewarrior(); // Act bool hit = engine.Hit(guardsman, fireWarrior); // Assert Assert.AreEqual(hit, result); }
public void Defender_Killed(int hitRoll, int woundRoll, int saveRoll, bool result) { // Arrange IDice dice = A.Fake <IDice>(); A.CallTo(() => dice.Roll()).ReturnsNextFromSequence(hitRoll, woundRoll, saveRoll); WbsEngine engine = new WbsEngine(dice); Unit guardsman = UnitFactory.Createguardsman(); Weapon lasgun = UnitFactory.Createlasgun(); Unit fireWarrior = UnitFactory.Createfirewarrior(); // Act bool DefenderKilled = engine.WasDefenderKilled(guardsman, lasgun, fireWarrior); // Assert Assert.AreEqual(result, DefenderKilled); }
public void Hit_False() { // Arrange IDice dice = A.Fake <IDice>(); A.CallTo(() => dice.Roll()).Returns(1); WbsEngine engine = new WbsEngine(dice); Unit guardsman = new Unit(); guardsman.Name = "Guardsman"; guardsman.Movement = 6; guardsman.WeaponSkill = 4; guardsman.BallisticSkill = 4; guardsman.Strength = 3; guardsman.Toughness = 3; guardsman.Wounds = 1; guardsman.Attack = 1; guardsman.Leadership = 6; guardsman.Save = 5; Unit fireWarrior = new Unit(); fireWarrior.Name = "Fire Warrior"; fireWarrior.Movement = 6; fireWarrior.WeaponSkill = 5; fireWarrior.BallisticSkill = 4; fireWarrior.Strength = 3; fireWarrior.Toughness = 3; fireWarrior.Wounds = 1; fireWarrior.Attack = 1; fireWarrior.Leadership = 6; fireWarrior.Save = 4; // Act bool hit = engine.Hit(guardsman, fireWarrior); // Assert Assert.IsFalse(hit); }