Example #1
0
        private static (SensorDataEntity, SensorInfo) BuildDatasForTests(SensorType sensorType, bool withComment = true)
        {
            var sensorDataEntity = SensorDataEntitiesFactory.BuildSensorDataEntity(sensorType, withComment);
            var sensorInfo       = SensorInfoFactory.BuildSensorInfo(_productName, sensorDataEntity.DataType);

            return(sensorDataEntity, sensorInfo);
        }
Example #2
0
        public void SensorDataEntityToSensorDataConverter_WithoutSensorInfo_Test(SensorType type)
        {
            var sensorDataEntity = SensorDataEntitiesFactory.BuildSensorDataEntity(type);

            var data = sensorDataEntity.Convert(_productName);

            TestSensorDataCommonProperties(sensorDataEntity, data, _productName, (SensorType)sensorDataEntity.DataType);
        }
Example #3
0
        public void SensorDataEntityToSensorDataConverter_FileSensorToFileSensorBytes_WithoutSensorInfo_Test()
        {
            var fileSensorDataEntity     = SensorDataEntitiesFactory.BuildSensorDataEntity(SensorType.FileSensor);
            var expectedSensorDataEntity = GetExpectedFileSensorBytesDataEntity(fileSensorDataEntity);

            var data = fileSensorDataEntity.Convert(_productName);

            TestSensorDataCommonProperties(expectedSensorDataEntity, data, _productName, (SensorType)expectedSensorDataEntity.DataType);
        }
        private (byte[], string, string) AddFileSensorAndGetItsContentExtensionAndPath(SensorType type)
        {
            var dataEntity = SensorDataEntitiesFactory.BuildSensorDataEntity(type);

            _databaseAdapterManager.DatabaseAdapter.PutSensorData(dataEntity, TestProductsManager.ProductName);

            switch (dataEntity.DataType)
            {
            case (byte)SensorType.FileSensor:
                var fileSensorData = JsonSerializer.Deserialize <FileSensorData>(dataEntity.TypedData);
                return(Encoding.UTF8.GetBytes(fileSensorData.FileContent), fileSensorData.Extension, dataEntity.Path);

            case (byte)SensorType.FileSensorBytes:
                var fileSensorBytesData = JsonSerializer.Deserialize <FileSensorBytesData>(dataEntity.TypedData);
                return(fileSensorBytesData.FileContent, fileSensorBytesData.Extension, dataEntity.Path);

            default:
                return(Array.Empty <byte>(), string.Empty, null);
            }
        }