public void GetAllLogsFromDatabaseByIdExpectSetCount() { var email = "*****@*****.**"; var logTitle = "newlog"; AddPersonToDatabase(email); var userId = _personRepository.GetPersonByUsername(email).Id; var log = CreateTestLog(userId, logTitle); _logRepository.AddLog(log); var exerciseRepository = new ExerciseRepository(); exerciseRepository.AddExercise("Squat"); var exercise = exerciseRepository.GetAllExercises().FirstOrDefault(); log = _logRepository.GetAllLogsByUserId(userId).FirstOrDefault(); var set = new Set() { Log = log, Exercise = exercise, Weight = 30, Reps = 20, PositionInLog = 1 }; var setRepository = new SetRepository(); setRepository.AddSet(set); set.PositionInLog = 2; setRepository.AddSet(set); var allLogs = _logRepository.GetAllLogsByUserId(userId); Assert.AreEqual(2, allLogs.FirstOrDefault().SetCount); }
public void GetLogWithSetsReturnsTheNumberOfSets() { var email = "*****@*****.**"; var logTitle = "newlog"; AddPersonToDatabase(email); var userId = _personRepository.GetPersonByUsername(email).Id; _logRepository.AddLog(CreateTestLog(userId, logTitle)); var logs = _logRepository.GetAllLogsByUserId(userId); var log = _logRepository.GetLogById(logs[0].Id); var exerciseRepository = new ExerciseRepository(); exerciseRepository.AddExercise("Squat"); var exercise = exerciseRepository.GetAllExercises().FirstOrDefault(); var set = new Set() { Log = log, Exercise = exercise, Weight = 30, Reps = 20, PositionInLog = 1 }; var setRepository = new SetRepository(); setRepository.AddSet(set); set.PositionInLog = 2; setRepository.AddSet(set); var returnedLog = _logRepository.GetLogById(log.Id); Assert.AreEqual(2, returnedLog.SetCount); }