Example #1
0
        public void RemoveTrainingTest()
        {
            //Arrange
            SetRepoAndContext();
            var runSes0 = new RunningSession(DateTime.Now, 5001, new TimeSpan(0, 25, 48), 4, TrainingType.Endurance, null);
            var runSes1 = new RunningSession(DateTime.Now.AddDays(1), 5000, new TimeSpan(0, 25, 48), 15, TrainingType.Endurance, null);
            var runSes2 = new RunningSession(DateTime.Now.AddDays(20), 5000, new TimeSpan(0, 25, 48), 10, TrainingType.Endurance, null);
            var runSes3 = new RunningSession(DateTime.Now.AddDays(-10), 5000, new TimeSpan(0, 25, 48), 8, TrainingType.Endurance, null);
            var runSes4 = new RunningSession(DateTime.Now.AddDays(1), 5000, new TimeSpan(0, 25, 48), 6, TrainingType.Endurance, null);

            _runRepo.AddTraining(runSes0);
            _runRepo.AddTraining(runSes1);
            _runRepo.AddTraining(runSes2);
            _runRepo.AddTraining(runSes3);
            _runRepo.AddTraining(runSes4);
            _context.SaveChanges();

            //Act
            _context = new TrainingContextTest(true);
            _runRepo = new RunningRepository(_context);
            _runRepo.RemoveTraining(1);
            //Assert
            _context.RunningSessions.Should().NotContain(runSes0);
        }
 public UnitOfWork(TrainingContext context)
 {
     this.context     = context;
     CyclingTrainings = new CyclingRepository(context);
     RunningTrainings = new RunningRepository(context);
 }
Example #3
0
 private void SetRepoAndContext()
 {
     _context = new TrainingContextTest();
     _runRepo = new RunningRepository(_context);
 }