public void ShouldConvertOutputUnitsInIClamp( [Values(MultiClampInterop.OperatingMode.I0, MultiClampInterop.OperatingMode.IClamp)] MultiClampInterop.OperatingMode operatingMode ) { var c = new Controller(); var mc = new FakeMulticlampCommander(); var mcd = new MultiClampDevice(mc, c, new Dictionary <MultiClampInterop.OperatingMode, IMeasurement>() { { operatingMode, UNUSED_BACKGROUND } } ); var data = new MultiClampInterop.MulticlampData() { OperatingMode = operatingMode, ExternalCommandSensitivity = 2.5, ExternalCommandSensitivityUnits = MultiClampInterop.ExternalCommandSensitivityUnits.A_V }; mc.FireParametersChanged(DateTimeOffset.Now, data); var cmd = new Measurement(20, -12, "A"); var expected = operatingMode == MultiClampInterop.OperatingMode.I0 ? new Measurement(0, "V") : new Measurement(cmd.QuantityInBaseUnit / (decimal)data.ExternalCommandSensitivity, cmd.Exponent, "V"); var actual = MultiClampDevice.ConvertOutput(cmd, data); Assert.That(actual, Is.EqualTo(expected)); }
public void ShouldThrowExceptionConvertingOutputGivenEmptyParametersQueue() { var c = new Controller(); var mc = new FakeMulticlampCommander(); var mcd = new MultiClampDevice(mc, c, UNUSED_BACKGROUND_DICTIONARY); Assert.Throws <MultiClampDeviceException>(() => mcd.ConvertOutput(new Measurement(0, "V"), DateTimeOffset.Now)); }
public void ShouldThrowExceptionConvertingOutputGivenNoParametersForTime() { var c = new Controller(); var mc = new FakeMulticlampCommander(); var mcd = new MultiClampDevice(mc, c, UNUSED_BACKGROUND_DICTIONARY); mcd.BindStream(new DAQOutputStream(UNUSED_NAME)); mc.FireParametersChanged(DateTimeOffset.Now.Add(TimeSpan.FromHours(1)), new MultiClampInterop.MulticlampData()); Assert.Throws <MultiClampDeviceException>(() => mcd.ConvertOutput(new Measurement(0, "V"), DateTimeOffset.Now)); }
public void ShouldUseBackgroundForMode() { const string VClampUnits = "V"; const string IClampUnits = "A"; Measurement VClampBackground = new Measurement(2, -3, VClampUnits); Measurement IClampBackground = new Measurement(-10, -3, IClampUnits); var c = new Controller(); var mc = new FakeMulticlampCommander(); var bg = new Dictionary <MultiClampInterop.OperatingMode, IMeasurement>() { { MultiClampInterop.OperatingMode.VClamp, VClampBackground }, { MultiClampInterop.OperatingMode.IClamp, IClampBackground }, }; var mcd = new MultiClampDevice(mc, c, bg); mcd.BindStream(new DAQOutputStream(UNUSED_NAME)); var data = new MultiClampInterop.MulticlampData() { OperatingMode = MultiClampInterop.OperatingMode.VClamp, ExternalCommandSensitivity = 2.5, ExternalCommandSensitivityUnits = MultiClampInterop.ExternalCommandSensitivityUnits.V_V }; mc.FireParametersChanged(DateTimeOffset.Now, data); Assert.That(mcd.OutputBackground, Is.EqualTo(MultiClampDevice.ConvertOutput(VClampBackground, mcd.CurrentDeviceOutputParameters.Data))); data = new MultiClampInterop.MulticlampData() { OperatingMode = MultiClampInterop.OperatingMode.IClamp, ExternalCommandSensitivity = 1.5, ExternalCommandSensitivityUnits = MultiClampInterop.ExternalCommandSensitivityUnits.A_V }; mc.FireParametersChanged(DateTimeOffset.Now, data); Assert.That(mcd.OutputBackground, Is.EqualTo(MultiClampDevice.ConvertOutput(IClampBackground, mcd.CurrentDeviceOutputParameters.Data))); }
public void ShouldConvertOutputUnitsInVClamp( [Values(MultiClampInterop.OperatingMode.VClamp)] MultiClampInterop.OperatingMode operatingMode ) { var data = new MultiClampInterop.MulticlampData() { OperatingMode = operatingMode, ExternalCommandSensitivity = 2.5, ExternalCommandSensitivityUnits = MultiClampInterop.ExternalCommandSensitivityUnits.V_V }; var cmd = new Measurement(20, -3, "V"); var expected = new Measurement(cmd.QuantityInBaseUnit / (decimal)data.ExternalCommandSensitivity, cmd.Exponent, "V"); var actual = MultiClampDevice.ConvertOutput(cmd, data); Assert.That(actual, Is.EqualTo(expected)); }
public void ShouldThrowExceptionConvertingOutputGivenNoParametersForTime() { var c = new Controller(); var mc = new FakeMulticlampCommander(); var mcd = new MultiClampDevice(mc, c, UNUSED_BACKGROUND_DICTIONARY); mcd.BindStream(new DAQOutputStream(UNUSED_NAME)); mc.FireParametersChanged(DateTimeOffset.Now.Add(TimeSpan.FromHours(1)), new MultiClampInterop.MulticlampData()); Assert.Throws<MultiClampDeviceException>(() => mcd.ConvertOutput(new Measurement(0, "V"), DateTimeOffset.Now)); }
public void ShouldThrowExceptionConvertingOutputGivenEmptyParametersQueue() { var c = new Controller(); var mc = new FakeMulticlampCommander(); var mcd = new MultiClampDevice(mc, c, UNUSED_BACKGROUND_DICTIONARY); Assert.Throws<MultiClampDeviceException>(() => mcd.ConvertOutput(new Measurement(0, "V"), DateTimeOffset.Now)); }