public void lawn_cant_move_outside_lawn_dimensions() { var lawn = new Lawn(5, 5); lawn.AddMowner(1, 4, 'N'); var finalPosition = lawn.MoveMowner("LMMMRRML"); Assert.AreEqual("1 4 N", finalPosition); }
public void case_scenario_3_3_E() { var lawn = new Lawn(5, 5); lawn.AddMowner(3, 3, 'E'); var finalPosition = lawn.MoveMowner("MMRMMRMRRM"); Assert.AreEqual(finalPosition, "5 1 E"); }
public void case_scenario_1_2_N() { var lawn = new Lawn(5, 5); lawn.AddMowner(1, 2, 'N'); var finalPosition = lawn.MoveMowner("LMLMLMLMM"); Assert.AreEqual(finalPosition, "1 3 N"); }
public void lawn_cant_have_negative_dimensions() { Exception failed = null; try { var lawn = new Lawn(-1, 5); } catch (Exception ex) { failed = ex; } Assert.IsNotNull(failed); }
public void mowner_cant_be_added_outside_lawn_dimensions() { var lawn = new Lawn(5, 5); Exception failed = null; try { lawn.AddMowner(5, 6, 'N'); } catch (Exception ex) { failed = ex; } Assert.IsNotNull(failed); }
public void mowner_can_move_to_all_directions() { var lawn = new Lawn(5, 5); lawn.AddMowner(2, 2, 'N'); var direction = lawn.MoveMowner("RM"); Assert.AreEqual("3 2 E", direction); direction = lawn.MoveMowner("RM"); Assert.AreEqual("3 1 S", direction); direction = lawn.MoveMowner("RM"); Assert.AreEqual("2 1 W", direction); direction = lawn.MoveMowner("RM"); Assert.AreEqual("2 2 N", direction); }
static void Main(string[] args) { var width = -1; var length = -1; var orientation = ' '; var coordX = -1; var coordY = -1; Console.WriteLine(""); PromptUser(ref width, ref length, ref orientation, ref coordX, ref coordY); try { var lawn = new Lawn(width, length); lawn.AddMowner(coordX, coordY, orientation); Console.WriteLine("Please inform Mowner path."); Console.Write("?: "); var path = Console.ReadLine(); var finalPosition = lawn.MoveMowner(path); Console.WriteLine(""); Console.WriteLine("-------------------------------------"); Console.WriteLine("Final position: {0}", finalPosition); Console.WriteLine("-------------------------------------"); } catch (Exception ex) { Console.WriteLine(""); Console.WriteLine("-------------------------------------"); Console.WriteLine(string.Concat("ERROR: ", ex.Message)); Console.WriteLine("-------------------------------------"); } Console.WriteLine(""); }
public void mowner_orientation_must_be_N_E_S_W() { var lawn = new Lawn(5, 5); Exception failed = null; try { lawn.AddMowner(3, 2, 'T'); } catch (Exception ex) { failed = ex; } Assert.IsNotNull(failed); }
public void mowner_can_turn_to_all_directions() { var lawn = new Lawn(5, 5); lawn.AddMowner(2, 2, 'N'); var direction = lawn.MoveMowner("R"); Assert.AreEqual("2 2 E", direction); direction = lawn.MoveMowner("R"); Assert.AreEqual("2 2 S", direction); direction = lawn.MoveMowner("R"); Assert.AreEqual("2 2 W", direction); direction = lawn.MoveMowner("R"); Assert.AreEqual("2 2 N", direction); direction = lawn.MoveMowner("L"); Assert.AreEqual("2 2 W", direction); direction = lawn.MoveMowner("L"); Assert.AreEqual("2 2 S", direction); direction = lawn.MoveMowner("L"); Assert.AreEqual("2 2 E", direction); direction = lawn.MoveMowner("L"); Assert.AreEqual("2 2 N", direction); }