public void GetVideoSampleTest() { List <JSONWrappers.VideoInfo> sample = VideosDataBase.GetVideoSample(EmotionType.Astonishment, EmotionType.Fear); Assert.AreEqual(sample[0].Type, "Astonishment"); Assert.AreEqual(sample[1].Type, "Fear"); }
public IActionResult SubmitVideoSessionResult(JSONWrappers.VideoResult jsonResult) { try { if (ModelState.IsValid) { /* Fetching parameters from wrapper class */ ulong subjectID = Convert.ToUInt64(jsonResult.SubjectID); IEnumerable <JSONWrappers.WatchInfo> jsonWatchSession = jsonResult.WatchSession; List <WatchInfo> watchSession = new List <WatchInfo>(jsonWatchSession.Count()); foreach (JSONWrappers.WatchInfo info in jsonWatchSession) { watchSession.Add(WatchInfo.FromJSON(info)); } VideosDataBase.SubmitVideoSessionResult(subjectID, watchSession); m_Logger.LogInformation($"Submitted watch session result for subject with ID {subjectID}"); return(Ok(subjectID)); } return(BadRequest(ModelState)); } catch (Exception e) { m_Logger.LogError(e.Message); throw; } }
public void ConvertPathToUrlTest() { Directory.SetCurrentDirectory(c_WorkingDir); string path = Path.Combine(c_WorkingDir, @"DataBase\Videos\Happiness\Happiness3.mp4"); string result = VideosDataBase.ConvertPathToUrl(path); Assert.AreEqual(result, "Videos/Happiness/Happiness3.mp4"); }
public void ConvertUrlToPathTest() { Directory.SetCurrentDirectory(c_WorkingDir); string expected = Path.Combine(c_WorkingDir, @"DataBase\Videos\Sadness\Sadness6.mp4"); string url = "Videos/Sadness/Sadness6.mp4"; string result = VideosDataBase.ConvertUrlToPath(url); Assert.AreEqual(result, expected); }
public IEnumerable <JSONWrappers.VideoInfo> GetVideos() { try { m_Logger.LogDebug("Request for videos"); return(VideosDataBase.GetAllVideos()); } catch (Exception e) { m_Logger.LogError(e.Message); throw; } }
public IEnumerable <JSONWrappers.VideoInfo> GetVideoSampleForSubject(ulong id) { try { m_Logger.LogInformation($"Request for video sample by subject with ID {id}"); (EmotionType best, EmotionType worst) = TestDataBase.GetBestAndWorstRecognizedEmotionTypesForSubject(id); if ((best == EmotionType.Undefined) || (worst == EmotionType.Undefined)) { /* There is no subject with this ID */ m_Logger.LogDebug($"Attempt to access non-existent subject with ID {id}"); return(new List <JSONWrappers.VideoInfo>()); } return(VideosDataBase.GetVideoSample(best, worst)); } catch (Exception e) { m_Logger.LogError(e.Message); throw; } }
public void GetAllVideosTest() { List <JSONWrappers.VideoInfo> videos = VideosDataBase.GetAllVideos(); Assert.AreEqual(videos.Count, 62); }