Ejemplo n.º 1
0
        public void GivenOperationDataFileWhenReadSpatialRecordsThenSpatialRecordsAreReturned()
        {
            var meter = new NumericWorkingData();

            _meters.Add(meter);

            var numericRepValue = new NumericRepresentationValue(RepresentationInstanceList.vrABLineHeading.ToModelRepresentation(), new NumericValue(UnitSystemManager.GetUnitOfMeasure("m"), 21.2));

            var spatialRecord1 = new SpatialRecord {
                Timestamp = DateTime.Now, Geometry = new Point {
                    X = 45.123456, Y = -65.456789
                }
            };

            spatialRecord1.SetMeterValue(meter, numericRepValue);
            spatialRecord1.SetAppliedLatency(meter, 2);
            _spatialRecords.Add(spatialRecord1);

            var spatialRecord2 = new SpatialRecord {
                Timestamp = DateTime.Now, Geometry = new Point {
                    X = 85.654875, Y = -65.3456212
                }
            };

            spatialRecord2.SetMeterValue(meter, numericRepValue);
            spatialRecord2.SetAppliedLatency(meter, 2);
            _spatialRecords.Add(spatialRecord2);

            var filePath = Path.Combine(_testCardPath, "OperationData-1.adm");

            _protobufSerializer.WriteSpatialRecords(filePath, _spatialRecords);

            var spatialRecords = _protobufSerializer.ReadSpatialRecords(filePath).ToList();

            Assert.AreEqual(spatialRecord1.Timestamp, spatialRecords[0].Timestamp);
            Assert.AreEqual(spatialRecord1.Geometry.Id, spatialRecords[0].Geometry.Id);
            Assert.AreEqual(numericRepValue.Value.Value, ((NumericRepresentationValue)spatialRecords[0].GetMeterValue(meter)).Value.Value);
            Assert.AreEqual(numericRepValue.Representation.Code, ((NumericRepresentationValue)spatialRecords[0].GetMeterValue(meter)).Representation.Code);
            Assert.AreEqual(numericRepValue.Value.UnitOfMeasure.Code, ((NumericRepresentationValue)spatialRecords[0].GetMeterValue(meter)).Value.UnitOfMeasure.Code);

            Assert.AreEqual(spatialRecord2.Timestamp, spatialRecords[1].Timestamp);
            Assert.AreEqual(spatialRecord2.Geometry.Id, spatialRecords[1].Geometry.Id);
            Assert.AreEqual(numericRepValue.Value.Value, ((NumericRepresentationValue)spatialRecords[1].GetMeterValue(meter)).Value.Value);
            Assert.AreEqual(numericRepValue.Representation.Code, ((NumericRepresentationValue)spatialRecords[1].GetMeterValue(meter)).Representation.Code);
            Assert.AreEqual(numericRepValue.Value.UnitOfMeasure.Code, ((NumericRepresentationValue)spatialRecords[1].GetMeterValue(meter)).Value.UnitOfMeasure.Code);
        }