public void Test_AddSensorData() { // Arrange var evaluator = new SensorsEvaluator(context, new HttpClient(new FakeHttpMessageHandler())); var accelFileStream = new FileStream("../../../../../machine_learning/training_sets/untagged_sets/new-1-roberto-d11_MetaWear Prime_2018-12-11T15.41.32.039_D0D172CD1CFC_Accelerometer_25.000Hz_1.4.2.csv", FileMode.Open); var gyroFileStream = new FileStream("../../../../../machine_learning/training_sets/untagged_sets/new-1-roberto-d11_MetaWear Prime_2018-12-11T15.41.32.039_D0D172CD1CFC_Gyroscope_25.000Hz_1.4.2.csv", FileMode.Open); var accelMemoryStream = new MemoryStream(); var gyroMemoryStream = new MemoryStream(); accelFileStream.CopyTo(accelMemoryStream); gyroFileStream.CopyTo(gyroMemoryStream); var accelFile = new FormFile(accelMemoryStream, 0, accelFileStream.Length, "new-1-roberto-d11_MetaWear Prime_2018-12-11T15.41.32.039_D0D172CD1CFC_Accelerometer_25.000Hz_1.4.2.csv", "new-1-roberto-d11_MetaWear Prime_2018-12-11T15.41.32.039_D0D172CD1CFC_Accelerometer_25.000Hz_1.4.2.csv"); var gyroFile = new FormFile(gyroMemoryStream, 0, gyroFileStream.Length, "new-1-roberto-d11_MetaWear Prime_2018-12-11T15.41.32.039_D0D172CD1CFC_Gyroscope_25.000Hz_1.4.2.csv", "new-1-roberto-d11_MetaWear Prime_2018-12-11T15.41.32.039_D0D172CD1CFC_Gyroscope_25.000Hz_1.4.2.csv"); // Act evaluator.AddSensorData(patientId, accelFile, gyroFile); // Assert var accelData = from accel in context.AccelerometerData where accel.PatientId == patientId select new { accel.Id }; Assert.Equal(9189, accelData.Count()); }
public IActionResult AddSensorData(int patientId, IFormFile accelerometerFile, IFormFile gyroscopeFile) { try { evaluator.AddSensorData(patientId, accelerometerFile, gyroscopeFile); return(Ok()); } catch (Exception e) { return(BadRequest(e.Message)); } }