public void AddNoDataAccessTest()
        {
            Mock <IEncounterRepository> fakeRepo = new Mock <IEncounterRepository>();

            fakeRepo.Setup(r => r.GetAll()).Throws(new DataInaccessibleException());
            fakeRepo.Setup(r => r.Add(It.IsAny <Encounter>())).Throws(new DataInaccessibleException());
            serviceToTest = new EncounterService(fakeRepo.Object, teamsRepo, sportsRepo, usersRepo, auth.Object);

            sportsRepo.Add(sport);
            teamsRepo.Add(teamA);
            teamsRepo.Add(teamB);

            serviceToTest.AddEncounter(matchAvsBDto);
        }
Beispiel #2
0
        private IActionResult TryPostMatch(int id, ICollection <int> teamIds, string sportName, DateTime date)
        {
            IActionResult result;

            try
            {
                SetSession();
                EncounterDto      added  = encounterService.AddEncounter(id, teamIds, sportName, date);
                EncounterModelOut output = factory.CreateModelOut(added);
                result = CreatedAtRoute("GetMatchById", new { matchId = added.id }, output);
            }
            catch (ServiceException e)
            {
                result = errors.GenerateError(e);
            }

            return(result);
        }
 public void AddMatchTest()
 {
     sportsRepo.Add(sport);
     teamsRepo.Add(teamA);
     teamsRepo.Add(teamB);
     serviceToTest.AddEncounter(matchAvsBDto);
     Assert.AreEqual(serviceToTest.GetAllEncounter().Count, 1);
 }