public void PulseDeserializationTest() { SequenceData seq = (SequenceData)SharedTestFunctions.loadTestFile("pulseSerTest.seq", typeof(SequenceData)); Assert.IsNotNull(seq.DigitalPulses[0]); Assert.AreEqual("testPulse", seq.DigitalPulses[0].PulseName); Assert.AreEqual(1.5, seq.DigitalPulses[0].startDelay.getBaseValue()); Assert.AreEqual(2.5, seq.DigitalPulses[0].pulseDuration.getBaseValue()); }
public void getTimeStepAtTimeTest() { SequenceData target = (SequenceData)SharedTestFunctions.loadTestFile("gettimesteptestseq.seq", typeof(SequenceData), true, null); Assert.AreEqual("1", target.getTimeStepAtTime(.5).StepName); Assert.AreEqual("1", target.getTimeStepAtTime(.5).StepName); Assert.AreEqual("1", target.getTimeStepAtTime(1).StepName); Assert.AreEqual("2", target.getTimeStepAtTime(1.5).StepName); Assert.AreEqual("4", target.getTimeStepAtTime(4).StepName); Assert.IsNull(target.getTimeStepAtTime(-1)); Assert.IsNull(target.getTimeStepAtTime(10)); }
private void testSnapshot(string path) { BufferTestSnapshot snapshot = (BufferTestSnapshot)SharedTestFunctions.loadTestFile(path, typeof(BufferTestSnapshot)); BufferTestSnapshot newShapshot = snapshot.Sequence._createBufferSnapshot(snapshot.Settings, snapshot.MasterTimebaseSampleDuration); // compare digital buffers Assert.AreEqual(snapshot.DigitalFixed.Count, newShapshot.DigitalFixed.Count, "Number of digital channels differ."); foreach (int digitalId in snapshot.Settings.logicalChannelManager.Digitals.Keys) { Assert.AreEqual(snapshot.DigitalFixed[digitalId].Length, newShapshot.DigitalFixed[digitalId].Length, "Digital fixed buffer lengths differ."); for (int i = 0; i < snapshot.DigitalFixed[digitalId].Length; i++) { Assert.AreEqual(snapshot.DigitalFixed[digitalId][i], newShapshot.DigitalFixed[digitalId][i], "Snapshots differ at Digital Fixed, channel id " + digitalId + " sample " + i); } Assert.AreEqual(snapshot.DigitalVar[digitalId].Length, newShapshot.DigitalVar[digitalId].Length, "Digital var buffer lengths differ."); for (int i = 0; i < snapshot.DigitalVar[digitalId].Length; i++) { Assert.AreEqual(snapshot.DigitalVar[digitalId][i], newShapshot.DigitalVar[digitalId][i], "Snapshots differ at Digital Var, channel id " + digitalId + " sample " + i); } } // compare analog buffers Assert.AreEqual(snapshot.AnalogFixed.Count, newShapshot.AnalogFixed.Count, "Number of analog channels differ."); foreach (int analogId in snapshot.Settings.logicalChannelManager.Analogs.Keys) { Assert.AreEqual(snapshot.AnalogFixed[analogId].Length, newShapshot.AnalogFixed[analogId].Length, "Analog fixed buffer lengths differ."); for (int i = 0; i < snapshot.AnalogFixed[analogId].Length; i++) { Assert.AreEqual(snapshot.AnalogFixed[analogId][i], newShapshot.AnalogFixed[analogId][i], "Snapshots differ at Analog Fixed, channel id " + analogId + " sample " + i); } Assert.AreEqual(snapshot.AnalogVar[analogId].Length, newShapshot.AnalogVar[analogId].Length, "Analog var buffer lengths differ."); for (int i = 0; i < snapshot.AnalogVar[analogId].Length; i++) { Assert.AreEqual(snapshot.AnalogVar[analogId][i], newShapshot.AnalogVar[analogId][i], "Snapshots differ at Analog Var, channel id " + analogId + " sample " + i); } } }
public void LoadTest() { /* * string path = string.Empty; // TODO: Initialize to an appropriate value * object expected = null; // TODO: Initialize to an appropriate value * object actual; * actual = Storage_Accessor.SaveAndLoad.Load(path); * Assert.AreEqual(expected, actual); * Assert.Inconclusive("Verify the correctness of this test method.");*/ // Loading a sequence file with old-style GPIB address should produce an exception bool expectedException = false; try { SharedTestFunctions.loadTestFile("SettingsData-1.5.set", typeof(DataStructures.SettingsData), false); } catch (ArgumentException e) { if (e.Message.Contains("NationalInstruments.NI4882.Address")) { expectedException = true; } else { Assert.Fail("Unexpected Argument exception (wrong message)."); } } catch (Exception e) { Assert.Fail("Unexpected exception (wrong exception type)"); } if (!expectedException) { Assert.Fail("Loading old sequence file failed to produce expected exception."); } // The above exception is fixed if we use the custom "GPIB Fix" binder when deserializing SharedTestFunctions.loadTestFile("SettingsData-1.5.set", typeof(DataStructures.SettingsData), true, new Common.GpibBinderFix()); SharedTestFunctions.loadTestFile("Empty1.60Sequence.seq", typeof(DataStructures.SequenceData)); SharedTestFunctions.loadTestFile("Empty1.61Sequence.seq", typeof(DataStructures.SequenceData)); }
public void retriggerOptionsSerializationTest() { SequenceData target = (SequenceData)SharedTestFunctions.loadTestFile("retriggers.seq", typeof(SequenceData)); Assert.AreEqual(false, target.TimeSteps[0].RetriggerOptions.WaitForRetrigger); Assert.AreEqual(true, target.TimeSteps[1].RetriggerOptions.WaitForRetrigger); Assert.AreEqual(true, target.TimeSteps[2].RetriggerOptions.WaitForRetrigger); Assert.AreEqual(true, target.TimeSteps[1].RetriggerOptions.RetriggerOnEdge); Assert.AreEqual(true, target.TimeSteps[1].RetriggerOptions.RetriggerOnNegativeValueOrEdge); Assert.AreEqual(false, target.TimeSteps[2].RetriggerOptions.RetriggerOnEdge); Assert.AreEqual(false, target.TimeSteps[2].RetriggerOptions.RetriggerOnNegativeValueOrEdge); Assert.AreEqual((double)17, target.TimeSteps[1].RetriggerOptions.RetriggerTimeout.getBaseValue()); }
public void LoadOldGpibTest() { SettingsData gpibTestSettings = (SettingsData) SharedTestFunctions.loadTestFile("OldGpibAddressSettings.set", typeof(SettingsData), true, new Common.GpibBinderFix()); Assert.AreEqual(5, gpibTestSettings.logicalChannelManager.GPIBs.Count); for (int i = 0; i < gpibTestSettings.logicalChannelManager.GPIBs.Count; i++) { LogicalChannel chan = gpibTestSettings.logicalChannelManager.GPIBs[i]; Assert.AreEqual(HardwareChannel.HardwareConstants.ChannelTypes.gpib, chan.HardwareChannel.ChannelType); Assert.AreEqual("test description " + i, chan.HardwareChannel.ChannelDescription); Assert.AreEqual("test channel " + i, chan.HardwareChannel.ChannelName); Assert.AreEqual("test device " + i, chan.HardwareChannel.DeviceName); // Assert.AreEqual(i, chan.HardwareChannel.GpibAddress.PrimaryAddress); // These asserts are expected to fail // Assert.AreEqual(i, chan.HardwareChannel.GpibAddress.SecondaryAddress); // due to incompatibility in deserializing // old gpib channel addresses } }