コード例 #1
0
        public void CurrentConverter_CanConvertToBit_ReturnProperShort()
        {
            // Arrange & Act
            var result = CurrentConverter.GetBit(36.2);

            //Assert
            Assert.IsType <short>(result);
            Assert.Equal(1000, result);
        }
コード例 #2
0
        private void ExtendedTexBbox_OnEnterPressed(object sender, KeyEventArgs e)
        {
            var textBox = (ExtendedTexBbox)sender;

            //this is needed to force update RAW only view textboxes
            var binding = textBox.GetBindingExpression(TextBox.TextProperty);

            binding?.UpdateSource();

            object sendingValue;

            switch (textBox.ECommand)
            {
            case ESenderCommand.CriticalVoltageAlarm:
            case ESenderCommand.VoltageAlarm:
                sendingValue = VoltageConverter.GetBit(Convert.ToDouble(textBox.Text));
                break;

            case ESenderCommand.CurrentLeftAlarm:
            case ESenderCommand.CurrentRightAlarm:
                sendingValue = CurrentConverter.GetBit(Convert.ToDouble(textBox.Text));
                break;

            case ESenderCommand.CriticalTemperatureAlarm:
            case ESenderCommand.TemperatureAlarm:
                sendingValue = TemperatureConverter.GetBit(Convert.ToDouble(textBox.Text));
                break;

            default:
                sendingValue = 0;
                break;
            }

            TextBoxEnterPressed?.Invoke(sender, new SendingTextBoxEventArgs {
                Value = sendingValue.ToString()
            });
        }