public void Swap2_should_(int src, int dest) { int org_src = src; int org_dest = dest; SwapService.Swap(ref src, ref dest); Assert.AreEqual(org_src, dest); Assert.AreEqual(org_dest, src); }
public void Swap2_should_swap_arg_src_to_dest() { // Arrange int src = 0; int dest = 10; // Act SwapService.Swap(ref src, ref dest); // Assert Assert.AreEqual(10, src); Assert.AreEqual(0, dest); }
private static UnitAction CreateAction(SimUnit unit, SimGame game) { var selectedAction = unit.GetBestNode(); var aim = unit.AimTarget; var pos = unit.Position; var shoot = unit.Shoot; var enemies = unit.Enemies.OrderBy(e => e.Position.Dist(pos) + e.Health * 0.01).ToList(); var targetPos = enemies.First().Position; UnitAction action = new UnitAction { Velocity = selectedAction.Dx * Const.Properties.UnitMaxHorizontalSpeed, Jump = selectedAction.JumpUp, JumpDown = selectedAction.JumpDown, Aim = new Vec2Double(aim.X - pos.X, aim.Y - pos.Y), Shoot = shoot, Reload = !shoot && unit.HasWeapon && pos.Dist(targetPos) > 5 && unit.HasWeapon && unit.Weapon.Magazine < unit.Weapon.Parameters.MagazineSize * 0.3, SwapWeapon = SwapService.ShouldSwap(game, unit), PlantMine = unit.Position.Dist(unit.TargetEnemy.Position) < 3 }; return(action); }
static void Main(string[] args) { var array = new List <int> { 4, 5, 1, 3, 4, 8, 10 }; var swap = new SwapService(); ISort sort = new SelectSort(swap); var tmpArray = sort.Sort(array); for (var i = 0; i < tmpArray.Count; i++) { Console.WriteLine(tmpArray[i]); } sort = new InsertionSort(swap); tmpArray = sort.Sort(array); for (var i = 0; i < tmpArray.Count; i++) { Console.WriteLine(tmpArray[i]); } Console.ReadKey(); }