Esempio n. 1
0
        public void GetOrientation_ShouldReturnNullIfNotPlaced()
        {
            //Arrange
            var    mockTable = new Mock <RectangularTable>(5, 5);
            IRobot robot     = new ToyRobotLibrary.Robot.Robot(mockTable.Object);

            //Act
            var result = robot.GetOrientation();

            //Assert
            Assert.Null(result);
        }
Esempio n. 2
0
        public void GetOrientation_ShouldReturnOrientation(Orientation orientation)
        {
            //Arrange
            var    mockTable        = new Mock <RectangularTable>(5, 5);
            IRobot robot            = new ToyRobotLibrary.Robot.Robot(mockTable.Object);
            var    orientationField = robot.GetType().GetField("_orientation", BindingFlags.NonPublic | BindingFlags.Instance);
            var    isPlacedProperty = robot.GetType().GetProperty("IsPlaced", BindingFlags.Public | BindingFlags.Instance);

            orientationField.SetValue(robot, orientation);
            isPlacedProperty.SetValue(robot, true);

            //Act
            var result = robot.GetOrientation();

            //Assert
            Assert.NotNull(result);
            Assert.IsType <Orientation>(result);
            Assert.Equal(orientation, result);
        }