public void TestSensorMultipleStreamCreation() { Sensor <FileInfo> sensor = Sensor <FileInfo> .Create( FileSensor.Create, SensorParams.Create( SensorParams.Keys.Path, "", ResourceLocator.Path(typeof(Resources), "rec-center-hourly-small.Csv"))); HTMSensor <FileInfo> htmSensor = (HTMSensor <FileInfo>)sensor; htmSensor.InitEncoder(GetTestEncoderParams()); // Ensure that the HTMSensor's output stream can be retrieved more than once. IStream <int[]> outputStream = htmSensor.GetOutputStream(); IStream <int[]> outputStream2 = htmSensor.GetOutputStream(); IStream <int[]> outputStream3 = htmSensor.GetOutputStream(); // Check to make sure above multiple retrieval doesn't flag the underlying stream as operated upon Assert.IsFalse(htmSensor.IsTerminal()); Assert.AreEqual(17, outputStream.Count()); //After the above we cannot request a new stream, so this will fail //however, the above streams that were already requested should be unaffected. Assert.IsTrue(htmSensor.IsTerminal(), "Terminal sensor stream expected"); try { //@SuppressWarnings("unused") IStream <int[]> outputStream4 = (Stream <int[]>)htmSensor.GetOutputStream(); Assert.Fail(); } catch (Exception e) { Assert.AreEqual("Stream is already \"terminal\" (operated upon or empty)", e.Message); } //These Streams were created before operating on a stream Assert.AreEqual(17, outputStream2.Count()); Assert.AreEqual(17, outputStream3.Count()); // Verify that different streams are retrieved. Assert.IsFalse(outputStream.GetHashCode() == outputStream2.GetHashCode()); Assert.IsFalse(outputStream2.GetHashCode() == outputStream3.GetHashCode()); }
public void TestInputIntegerArray() { Sensor <FileInfo> sensor = Sensor <FileInfo> .Create(FileSensor.Create, SensorParams.Create(SensorParams.Keys.Path, "", ResourceLocator.Path(typeof(Resources), "1_100.Csv"))); HTMSensor <FileInfo> htmSensor = (HTMSensor <FileInfo>)sensor; htmSensor.InitEncoder(GetArrayTestParams()); // Ensure that the HTMSensor's output stream can be retrieved more than once. FanOutStream <int[]> outputStream = (FanOutStream <int[]>)htmSensor.GetOutputStream(); Assert.AreEqual(884, ((int[])outputStream.First()).Length); }