public void GetLength_WithConstructorInputValue10_Output10() { //Arrange IJAssignment02.Rectangle rectangle = new IJAssignment02.Rectangle(10, 1); int expected = 10; //Act int actual = rectangle.GetLength(); //Assert Assert.AreEqual(expected, actual); }
public void GetLength_WithDefaultConstructor_Output1() { //Arrange IJAssignment02.Rectangle rectangle = new IJAssignment02.Rectangle(); int expected = 1; //Act int actual = rectangle.GetLength(); //Assert Assert.AreEqual(expected, actual); }
/// <summary> /// Main control logic is in this main method /// </summary> /// <param name="args"></param> static void Main(string[] args) { //Variable declaration int length = 0; int width = 0; int result = 0; int perimeter = 0; int area = 0; int chosenMenu = 0; Rectangle rectangle = new Rectangle(); //The exit option quits the program and is the only way to exit the program while (chosenMenu != 7) { //It displays the option menu ShowMenu(); //It parses the user input to an integer int.TryParse(Console.ReadLine(), out chosenMenu); Console.WriteLine(); //It will proceed logics depending on the users's choice. switch (chosenMenu) { //Get the rectangle length case 1: length = rectangle.GetLength(); Console.WriteLine($"The rectangle length is {length}\n"); break; //Change the rectangle length case 2: Console.WriteLine($"The current rectangle length is {length}"); length = ChangeRectangleLengthorWidth(); result = ResultCheck(length); length = rectangle.SetLength(result); Console.WriteLine($"The new rectangle length is {result}\n"); break; //Get the rectangle width case 3: width = rectangle.GetWidth(); Console.WriteLine($"The rectangle width is {width}\n"); break; //Change the rectangle width case 4: Console.WriteLine($"The current rectangle width is {width}"); width = ChangeRectangleLengthorWidth(); result = ResultCheck(width); width = rectangle.SetWidth(result); Console.WriteLine($"The new rectangle width is {result}\n"); break; //Get the rectangle's perimeter case 5: result = rectangle.GetPerimeter(); Console.WriteLine($"The rectangle's perimeter is {result}\n"); break; //Get the rectangle's area case 6: result = rectangle.GetArea(); Console.WriteLine($"The rectangle's area is {result}\n"); break; //Exit the program case 7: Environment.Exit(-1); break; default: break; } } }