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); }
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); }
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); }
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); }
/// <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 });
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; } }
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); }
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); }
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); }
/// <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(); }
/// <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); }