public void MigrateTest() { Storm <MallardDuck> storm = new Storm <MallardDuck>(); storm.FillStorm(nDucks); //migrazione storm.Migrate(Direction.NORD, 25.3); storm.Migrate(Direction.OVEST, 25.3); storm.Migrate(Direction.SUD, 25.3); storm.Migrate(Direction.EST, 25.3); Assert.AreEqual(0d, storm.PositionX); Assert.AreEqual(0d, storm.PositionY); Assert.AreEqual(0d, storm.LineDistanceFromStart); //altra migrazione storm.Migrate(Direction.NORD, 25.3); storm.Migrate(Direction.EST, 67.3); Assert.AreEqual(67.3, storm.PositionX); Assert.AreEqual(25.3, storm.PositionY); Assert.AreEqual(71.90, storm.LineDistanceFromStart); storm.Migrate(Direction.SUD, 30.9); storm.Migrate(Direction.EST, 14.9); Assert.AreEqual(82.2, storm.PositionX); Assert.AreEqual(-5.6, storm.PositionY); Assert.AreEqual(82.39, storm.LineDistanceFromStart); Assert.AreEqual(storm.TotalDistance, 239.6); Assert.IsTrue(storm.Ducks.TrueForAll(dk => dk.TotalFly == storm.TotalDistance)); }
public void MigrateExceptionTest() { Storm <MallardDuck> storm = new Storm <MallardDuck>(); try { storm.Migrate(Direction.NORD, 25.3); Assert.Fail(); }catch (ArgumentException) { } Assert.AreEqual(0d, storm.PositionX); Assert.AreEqual(0d, storm.PositionY); Assert.AreEqual(storm.TotalDistance, 0d); }
public void MigrateExceptionTest() { Storm <MallardDuck> storm = new Storm <MallardDuck>(); try { storm.Migrate(Direction.NORD, 25.3); Assert.Fail(); }catch (Exception) { } Assert.AreEqual(0d, storm.PositionX); Assert.AreEqual(0d, storm.PositionY); Assert.AreEqual(storm.TotalDistance, 0d); Assert.IsTrue(storm.Ducks.TrueForAll(dk => dk.TotalFly == storm.TotalDistance)); }