Exemplo n.º 1
0
 public Tournament CreateTournament(Tournament Tour)
 {
     try
     {
         _tourVali.CheckIfTournamentIsNull(Tour);
         _tourVali.ValidateDatesIsNotBeforeTodayOnCreatedTournament(Tour);
         return(_tourRepo.CreateTour(_tourVali.ValidateTournament(Tour)));
     }catch (Exception ex)
     {
         throw ex;
     }
 }
        public void TestThrowsExceptionIfTournamentEndDateAndStartdateIsBeforeToday()
        {
            TournamentValidator tourVali = new TournamentValidator();
            Tournament          tour     = new Tournament
            {
                Name           = "TestTournament",
                NumberOfRounds = 3,
                EndDate        = new DateTime(2019, 10, 25),
                StartDate      = new DateTime(2019, 10, 20)
            };
            Exception ex = Assert.Throws <InvalidDataException>(() =>
                                                                tourVali.ValidateDatesIsNotBeforeTodayOnCreatedTournament(tour));

            Assert.Equal("End date or start date cannot be before today", ex.Message);
        }