Exemple #1
0
        public IActionResult CreateTournament()
        {
            var ts = new TournamentService(AllTournamentRepository, AllTeamRepository);

            ts.CreateTournament();
            return(RedirectToAction(nameof(Current)));
        }
Exemple #2
0
        public void ThrowArgumentException_WhenTheListWIthDivisionTypesIsNullOrEmpty()
        {
            // Arrange
            var expectedTournament = new Tournament
            {
                Name      = "Test name",
                Place     = "Test place",
                StartDate = DateTime.Now.Add(new TimeSpan(1, 0, 0, 0, 0)),
                EndDate   = DateTime.Now.Add(new TimeSpan(2, 0, 0, 0, 0)),
                CountryId = Guid.NewGuid()
            };

            var divisionTypeDbSetMock = QueryableDbSetMock.GetQueryableMockDbSet(new List <DivisionType>());

            var yoyoTournamentsDbContextMock = new Mock <IYoyoTournamentsDbContext>();

            yoyoTournamentsDbContextMock.Setup(x => x.DivisionTypes).Returns(divisionTypeDbSetMock.Object);

            var divisionTypeServiceMock = new Mock <IDivisionTypeService>();

            divisionTypeServiceMock.Setup(x => x.GetAllDivisionTypes()).Returns(new List <DivisionType>());


            var tournamentService = new TournamentService(yoyoTournamentsDbContextMock.Object, divisionTypeServiceMock.Object);

            // Act & Assert
            ThrowsAssert.Throws <NullReferenceException>(
                () => tournamentService.CreateTournament(expectedTournament.Name,
                                                         expectedTournament.Place,
                                                         expectedTournament.StartDate,
                                                         expectedTournament.EndDate,
                                                         expectedTournament.CountryId)
                );
        }
Exemple #3
0
        public void ThrowArgumentException_WhenTheTournamentPlaceIsNullOrEmpty()
        {
            // Arrange
            var expectedTournament = new Tournament
            {
                Name      = "Test name",
                Place     = String.Empty,
                StartDate = DateTime.Now,
                EndDate   = DateTime.Now,
                CountryId = Guid.NewGuid()
            };

            var yoyoTournamentsDbContextMock = new Mock <IYoyoTournamentsDbContext>();
            var divisionTypeService          = new Mock <IDivisionTypeService>();

            var tournamentService = new TournamentService(yoyoTournamentsDbContextMock.Object, divisionTypeService.Object);

            // Act & Assert
            ThrowsAssert.Throws <ArgumentException>(
                () => tournamentService.CreateTournament(expectedTournament.Name,
                                                         expectedTournament.Place,
                                                         expectedTournament.StartDate,
                                                         expectedTournament.EndDate,
                                                         expectedTournament.CountryId)
                );
        }
Exemple #4
0
        public void ThrowArgumentOutOfRangeException_WhenTheTournamentEndDateIsLessThenStartDate()
        {
            // Arrange
            var expectedTournament = new Tournament
            {
                Name      = "Test name",
                Place     = "Test place",
                StartDate = DateTime.Now.Add(new TimeSpan(2, 0, 0, 0, 0)),
                EndDate   = DateTime.Now.Add(new TimeSpan(1, 0, 0, 0, 0)),
                CountryId = Guid.NewGuid()
            };

            var yoyoTournamentsDbContextMock = new Mock <IYoyoTournamentsDbContext>();
            var divisionTypeService          = new Mock <IDivisionTypeService>();

            var tournamentService = new TournamentService(yoyoTournamentsDbContextMock.Object, divisionTypeService.Object);

            // Act & Assert
            ThrowsAssert.Throws <ArgumentOutOfRangeException>(
                () => tournamentService.CreateTournament(expectedTournament.Name,
                                                         expectedTournament.Place,
                                                         expectedTournament.StartDate,
                                                         expectedTournament.EndDate,
                                                         expectedTournament.CountryId)
                );
        }
Exemple #5
0
        public async Task <CreateTournamentResponse> CreateTournament([FromBody] CreateTournamentRequest request)
        {
            string id = await tournamentService.CreateTournament(request);

            return(new CreateTournamentResponse
            {
                TournamentId = id,
            });
        }
Exemple #6
0
        public void CreateTournament_GivenValidTournament_ShouldAddTournament()
        {
            var tournamentid = 5;
            var tournament   = new Tournament {
                TournamentId = tournamentid, TournamentName = "NewTournament"
            };

            _tournamentService.CreateTournament(tournament);
            var result = Db.Tournament.FirstOrDefault(x => x.TournamentId == tournamentid);

            Assert.IsNotNull(result);
        }
 public async Task <ActionResult> Create([Bind(Include = "TournamentName")] Tournament tournament)
 {
     if (await tournamentService.CreateTournament(tournament))
     {
         ShowResult(ResultCode.Success, "Create Tournament", "Tournament is created Successful");
         return(RedirectToAction("Index"));
     }
     else
     {
         ShowResult(ResultCode.Error, "Create Tournament", "Tournament is not created Successful");
     }
     return(View(tournament));
 }
Exemple #8
0
        public async Task <ActionResult> Create([Bind(Include = "TournamentName")] Tournament tournament)
        {
            tournament.CreatedByUserID = 1;
            tournament.CreatedDate     = DateTime.Now;

            int tournamentID = 1;
            await tournamentService.CreateTournament(tournament);

            if (tournamentID != 0)
            {
                return(RedirectToAction("Index"));
            }
            return(View(tournament));
        }
Exemple #9
0
 public void CreateTournament_ValidTournament_TournamentCreated()
 {
     tournamentService.CreateTournament(tournamentA);
 }
        public IActionResult CreateTournament([FromBody, Required] CreateTournamentRequest request)
        {
            var response = tournamentService.CreateTournament(request);

            return(Ok(response));
        }