상속: MonoBehaviour
예제 #1
0
        public void Constructor_with_string_parameter_should_use_a_factor()
        {
            // Arrange
            string rawValue = "100";

            // Act
            var actual = new PowerValue(rawValue);

            // Assert
            Assert.AreEqual(1, actual.Value);
        }
예제 #2
0
        public void Constructor_with_string_parameter_should_handle_invalid_value()
        {
            // Arrange
            string rawValue = "-";

            // Act
            var actual = new PowerValue(rawValue);

            // Assert
            Assert.AreEqual(double.NaN, actual.Value);
        }
    public void CanConvertPowerToVoltage(Type powerModeType, Voltage voltage, PowerValue expected)
    {
        //arrange
        var powerMode = (IPowerMode)Activator.CreateInstance(powerModeType) !;

        //act
        var power = voltage.ToPowerValue(powerMode);

        //assert
        Assert.Equal(expected, power);
    }
예제 #4
0
        public void Constructor_with_double_parameter_should_use_a_factor()
        {
            // Arrange
            double rawValue = 100;

            // Act
            var actual = new PowerValue(rawValue);

            // Assert
            Assert.AreEqual(1, actual.Value);
        }
예제 #5
0
        public void Convert_should_use_a_factor()
        {
            // Arrange
            double rawValue = 100;
            var    actual   = new PowerValue();

            // Act
            actual.Convert(rawValue);

            // Assert
            Assert.AreEqual(1, actual.Value);
        }
예제 #6
0
 /// <summary>Sets each column to the same value</summary>
 /// <param name="power">The power value to set each column to</param>
 public void SetAllColumns(PowerValue power)
 => SetColumns(new PowerSet
 {
     Item1 = power,
     Item2 = power,
     Item3 = power,
     Item4 = power,
     Item5 = power,
     Item6 = power,
     Item7 = power,
     Item8 = power
 });
예제 #7
0
        public void SetPowerValues(PowerValue center, PowerValue upperLeft, PowerValue top, PowerValue upperRight, PowerValue lowerLeft, PowerValue bottom, PowerValue lowerRight, PowerValue decimalPoint = PowerValue.Off)
        {
            Center.Power     = center;
            UpperLeft.Power  = upperLeft;
            Top.Power        = top;
            UpperRight.Power = upperRight;
            LowerLeft.Power  = lowerLeft;
            Bottom.Power     = bottom;
            LowerRight.Power = lowerRight;

            if (Decimal != null)
            {
                Decimal.Power = decimalPoint;
            }
        }
예제 #8
0
        public void CanSetPower(Type powerModeType, PowerValue power, string expected)
        {
            //arrange
            var fs = Substitute.For <IFileSystem>();

            fs.Read("/sys/class/gpio/gpio123/direction").Returns("out");

            //act
            var pinInterface = new LinuxPinInterface(123, fs)
            {
                Enabled   = true,
                PowerMode = (IPowerMode)Activator.CreateInstance(powerModeType),
                Power     = power
            };

            //assert
            fs.Received().Write("/sys/class/gpio/gpio123/value", expected);
        }
예제 #9
0
        public void CanSetPower(Type powerModeType, PowerValue power, byte expected)
        {
            //arrange
            var gpio = Substitute.For <IGpioController>();

            gpio.GetPinMode(123).Returns(PinMode.Output);

            //act
            var pinInterface = new SystemPinInterface(123, gpio)
            {
                Enabled   = true,
                PowerMode = (IPowerMode)Activator.CreateInstance(powerModeType),
                Power     = power
            };

            //assert
            gpio.Received().Write(123, expected);
        }
    public void CanGetPower(Type powerModeType, byte value, PowerValue expected)
    {
        //arrange
        var gpio = Substitute.For <IGpioController>();

        gpio.Read(123).Returns(value);
        var pwm          = Substitute.For <IPwmChannel>();
        var pinInterface = new SystemPinInterface(123, gpio, pwm)
        {
            Direction = Direction.Out,
            PowerMode = (IPowerMode)Activator.CreateInstance(powerModeType) !
        };

        //act
        var power = pinInterface.Power;

        //assert
        Assert.Equal(expected, power);
    }
예제 #11
0
        public void CanGetPower(Type powerModeType, string value, PowerValue expected)
        {
            //arrange
            var fs = Substitute.For <IFileSystem>();

            fs.Read("/sys/class/gpio/gpio123/value").Returns(value);

            var pinInterface = new LinuxPinInterface(123, fs)
            {
                Direction = Direction.Out,
                PowerMode = (IPowerMode)Activator.CreateInstance(powerModeType)
            };

            //act
            var power = pinInterface.Power;

            //assert
            Assert.Equal(expected, power);
        }
예제 #12
0
 /// <summary>Sends a power value to the component</summary>
 /// <param name="value">The power value to send</param>
 public void Send(PowerValue value)
 {
     _data.Power = value;
     _clock.Spike();
 }
예제 #13
0
 /// <summary>Sets all pixels to the same value</summary>
 /// <param name="power">The power value to set each pixel to</param>
 public void SetAll(PowerValue power)
 {
     SetAllRows(power);
     SetAllColumns(power);
 }