Exemplo n.º 1
0
        public DummyTeams()
        {
            this.DummyTeamOne = new Team
                                (
                new TeamName("Dummy TeamOne"),
                new ArenaName("Dummy ArenaOne"),
                new EmailAddress("*****@*****.**")
                                );
            this.DummyTeamTwo = new Team
                                (
                new TeamName("Dummy TeamTwo"),
                new ArenaName("Dummy ArenaTwo"),
                new EmailAddress("*****@*****.**")
                                );
            this.DummyTeamThree = new Team
                                  (
                new TeamName("Dummy TeamThree"),
                new ArenaName("Dummy ArenaThree"),
                new EmailAddress("*****@*****.**")
                                  );
            this.DummyTeamFour = new Team
                                 (
                new TeamName("Dummy TeamFour"),
                new ArenaName("Dummy ArenaFour"),
                new EmailAddress("*****@*****.**")
                                 );

            var teamService = new TeamService();

            teamService.Add(this.DummyTeamOne);
            teamService.Add(this.DummyTeamTwo);
            teamService.Add(this.DummyTeamThree);
            teamService.Add(this.DummyTeamFour);
            this.FillTeamsWithPlayer();
        }
Exemplo n.º 2
0
        private void GeneratDummySeriesSchedual()
        {
            var teamService = new TeamService();

            teamService.Add(this.DummyTeams.DummyTeamOne);
            teamService.Add(this.DummyTeams.DummyTeamTwo);
            teamService.Add(this.DummyTeams.DummyTeamThree);
            teamService.Add(this.DummyTeams.DummyTeamFour);
            DomainService.ScheduleGenerator(this.SeriesDummy.Id);
        }
Exemplo n.º 3
0
        public void AddTest()
        {
            //Arange
            TeamDto teamDto = new TeamDto()
            {
                Id   = "0",
                Name = "T0"
            };
            bool isAdded = false;
            Mock <IUnitOfWork>         unitOfWorkMock = new Mock <IUnitOfWork>();
            Mock <IRepository <Team> > repositoryMock = new Mock <IRepository <Team> >();

            repositoryMock.Setup(repo => repo.Get(It.IsAny <Expression <Func <Team, bool> > >()))
            .Returns <Expression <Func <Team, bool> > >(predicate =>
                                                        _teams.Where(predicate.Compile()).AsQueryable());
            repositoryMock.Setup(repo => repo.Add(It.IsAny <Team>())).Callback(() => isAdded = true);
            unitOfWorkMock.Setup(getRepo => getRepo.GetRepository <Team>()).Returns(repositoryMock.Object);
            TeamService teamService = new TeamService(unitOfWorkMock.Object);

            //Act
            teamService.Add(teamDto);

            //Assert
            Assert.True(isAdded);
        }
Exemplo n.º 4
0
        public async void TestPost()
        {
            using (var client = server.CreateClient().AcceptJson())
            {
                var step        = 1;
                var service     = new TeamService();
                var countBefore = service.GetAll().Count();
                var item        = service.GetAll().FirstOrDefault();
                if (item == null)
                {
                    var newItem = new Team()
                    {
                        Id   = 0,
                        Name = string.Format("Team {0}", countBefore)
                    };

                    service.Add(item);
                    item = service.GetAll().FirstOrDefault();

                    step = 2;
                }

                var response = await client.PostAsJsonAsync("/api/Teams", item);

                var result = await response.Content.ReadAsJsonAsync <Team>();

                var countAfter = service.GetAll().Count();

                Assert.Equal(countBefore, countAfter - step);
                Assert.Equal((int)response.StatusCode, 201);
            }
        }
Exemplo n.º 5
0
 public void Add()
 {
     if (!IsEdit)
     {
         SelectedEmployees = ActualEmployees.ToList();
         string x = TeamService.Add(Name, SelectedTeamType?.Id, Responsibilities);
         if (x == null)
         {
             EmployeeService.AddEmployeesToTeam(SelectedEmployees, TeamService.GetAll().Last().Id);
             TryClose();
         }
         else
         {
             Error = x;
         }
     }
     else
     {
         SelectedEmployees       = ActualEmployees.ToList();
         toEdit.Name             = Name;
         toEdit.Responsibilities = Responsibilities;
         toEdit.TeamTypeId       = SelectedTeamType.Id;
         string x = TeamService.Edit(toEdit);
         if (x == null)
         {
             EmployeeService.AddEmployeesToTeam(SelectedEmployees, toEdit.Id);
             TryClose();
         }
         else
         {
             Error = x;
         }
     }
 }
Exemplo n.º 6
0
        public ActionResult Create(PocoClasses.Entries.Team newTeam, int entryId)
        {
            Mapper.Initialize(cfg => cfg.CreateMap <PocoClasses.Entries.Team, Team>());
            Team team = Mapper.Map <Team>(newTeam);

            team.EntryId = entryId;

            if (ModelState.IsValid)
            {
                using (var context = new TeamContext())
                {
                    var service = new TeamService(context);
                    service.Add(team);
                }
                using (var context = new RaceEntryContext())
                {
                    var service = new RaceEntryService(context);
                    service.Add(team.Id, newTeam.EventId);
                }

                Entry entry;
                using (var context = new EntryContext())
                {
                    var service = new EntryService(new RosContext <Entry>());
                    entry = service.GetById(entryId);
                }
                return(RedirectToAction("Index", entry));
            }
            return(View(team));
        }
Exemplo n.º 7
0
        public void TestAddTeam()
        {
            /* ================== Montando Cenario =================== */

            ITeamService teamService = new TeamService(GetInMemoryTeamRepository());
            var          brasil      = new Team("Brasil", "BRA");

            /* ================== Execucao =================== */
            var teamSaved = teamService.Add(brasil);

            /* ================== Verificacao =================== */

            // Testando com Assert
            Assert.NotEmpty(teamService.GetAll().ToList());
            //Assert.Equal(1, teamSaved.TeamId);
            Assert.Equal("Brasil", teamSaved.Name);
            Assert.Equal("BRA", teamSaved.Flag);

            // Testando com FluentAssertions
            //teamService.GetAll().Should().NotBeNull(teamService.GetAll().ToList().Count.ToString(),
            //    $"O objeto esperado não corresponde com ao objeto obtido" +
            //    $" ({teamService.GetAll().ToList().Count.ToString()})");

            //teamSaved.TeamId.Should().Be(1,
            //    $"O Id do objeto esperado não corresponde com o Id do objeto obtido {teamSaved.TeamId}");
            //teamSaved.Name.Should().Be("Brasil",
            //    $"O nome do time esperado não corresponde com o nome obtido {teamSaved.Name}");
            //teamSaved.Flag.Should().Be("BRA",
            //    $"A bandeira não corresponde coma a obtida {teamSaved.Flag}");
        }
Exemplo n.º 8
0
        private void AddTeam_Clicked(object sender, RoutedEventArgs e)
        {
            var addTeamWindow = new AddTeamWindow(false);
            var windowRes     = addTeamWindow.ShowDialog();

            Trace.WriteLine(windowRes);
            if (windowRes.HasValue && !windowRes.Value)
            {
                Trace.WriteLine("We did not press the add button");
                return;
            }

            if (addTeamWindow.Team == null)
            {
                Trace.WriteLine("Team is null");
                return;
            }

            if (addTeamWindow.Coach == null)
            {
                Trace.WriteLine("Coach is null");
                return;
            }

            _teamService.Add(addTeamWindow.Team);
            _personService.Add(addTeamWindow.Coach);
            Teams.Add(addTeamWindow.Team);
        }
Exemplo n.º 9
0
        public void CallTeamsReposAddMethodWithCorrectlySetLeagueToTeamModel_WhenAlValidationPassed()
        {
            // arrange
            var teamsRepo   = new Mock <IEfRepository <Team> >();
            var leaguesRepo = new Mock <IEfRepository <League> >();

            var team = new Team()
            {
                Name = "someName"
            };

            teamsRepo.Setup(tr => tr.All).Returns(new List <Team>().AsQueryable());

            var league = new League()
            {
                Name = "someLeague"
            };

            leaguesRepo.Setup(lr => lr.All).Returns(new List <League>()
            {
                league
            }.AsQueryable());

            var teamService = new TeamService(teamsRepo.Object, leaguesRepo.Object);

            // act
            teamService.Add(team, league.Name);

            // assert
            teamsRepo.Verify(tr => tr.Add(It.Is <Team>(t => t.League == league)));
        }
Exemplo n.º 10
0
        // POST: Team?tenant_id
        public void Post(string tenant_id, [FromBody] Team Team)
        {
            //ID = AutoIncrement & Owner = tenant_id.

            Team.Owner = tenant_id;
            TeamService.Add(Team);
            TeamService.Commit();
        }
Exemplo n.º 11
0
        public void ServiceRepoInstanceIsTheSame()
        {
            var service1 = new TeamService();
            var service2 = new TeamService();

            service1.Add(this.team);
            var teams = service2.GetAllTeams();

            Assert.IsTrue(teams.Contains(this.team));
        }
Exemplo n.º 12
0
 public void Post([FromBody] Team leaderboard)
 {
     try
     {
         _teamService.Add(leaderboard);
     }
     catch (System.Exception ex)
     {
         throw new System.Exception(ex.Message);
     }
 }
Exemplo n.º 13
0
        public void ThrowArgumentNullException_WhenPassedTeamIsNull()
        {
            // arrange
            var teamsRepo   = new Mock <IEfRepository <Team> >();
            var leaguesRepo = new Mock <IEfRepository <League> >();

            var teamService = new TeamService(teamsRepo.Object, leaguesRepo.Object);

            // act  & assert
            Assert.Throws <ArgumentNullException>(() => teamService.Add(null, null));
        }
Exemplo n.º 14
0
        public ActionResult Create([Bind(Include = "TeamID,TeamName,TeamLeaderCode,TeamDescription,teamleader.AccountID")] Team Team)
        {
            if (ModelState.IsValid)
            {
                Team.Owner = ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/tenantid").Value;
                TeamService.Add(Team);
                TeamService.Commit();
                return(RedirectToAction("Index"));
            }

            return(View(Team));
        }
Exemplo n.º 15
0
        public void AddListOfPlayerTest()
        {
            var teamOne   = new Team(new TeamName("Grunden Bois"), new ArenaName("Ullevi"), new EmailAddress("*****@*****.**"));
            var teamTwo   = new Team(new TeamName("Grunden Bois"), new ArenaName("Ullevi"), new EmailAddress("*****@*****.**"));
            var teamThree = new Team(new TeamName("Grunden Bois"), new ArenaName("Ullevi"), new EmailAddress("*****@*****.**"));

            var teams = new List <Team>
            {
                teamOne,
                teamTwo
            };

            service.Add(teams);
            var allTeams = DomainService.GetAllTeams();

            Assert.IsTrue(allTeams.Contains(teamOne));
            Assert.IsTrue(allTeams.Contains(teamTwo));
            Assert.IsFalse(allTeams.Contains(teamThree));
        }
Exemplo n.º 16
0
        public ActionResult Create(Team team)
        {
            try
            {
                team.CreatedOn   = DateTime.Now;
                team.CreatedById = User.Identity.GetUserId();

                TeamService.Add(team);

                TempData["MessageAlert"] = new Alert {
                    CssClass = "alert-success", Title = "Success!", Message = "Team is successfully created."
                };
                return(RedirectToAction("Create"));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 17
0
        public void TestAdd()
        {
            ConfigurationHelper.Ensure();

            var service = new TeamService();

            var countBefore = service.GetAll().Count();

            var newItem = new Team()
            {
                Id   = 0,
                Name = string.Format("Team {0}", countBefore)
            };

            service.Add(newItem);

            var countAfter = service.GetAll().Count();

            Assert.Equal(countBefore, countAfter - 1);
        }
Exemplo n.º 18
0
        public void ThrowInvalidOperationException_WhenLeagueNameDoesNotTargetExistingLeague()
        {
            // arrange
            var teamsRepo   = new Mock <IEfRepository <Team> >();
            var leaguesRepo = new Mock <IEfRepository <League> >();

            var team = new Team()
            {
                Name = "someName"
            };

            teamsRepo.Setup(tr => tr.All).Returns(new List <Team>().AsQueryable());

            leaguesRepo.Setup(lr => lr.All).Returns(new List <League>().AsQueryable());

            var teamService = new TeamService(teamsRepo.Object, leaguesRepo.Object);

            // act & assert
            Assert.Throws <ArgumentNullException>(() => teamService.Add(team, team.Name));
        }
Exemplo n.º 19
0
        public void ThrowInvalidOperationException_WhenPassedTeamAlreadyExists()
        {
            // arrange
            var teamsRepo   = new Mock <IEfRepository <Team> >();
            var leaguesRepo = new Mock <IEfRepository <League> >();

            var team = new Team()
            {
                Name = "someName"
            };

            teamsRepo.Setup(tr => tr.All).Returns(new List <Team>()
            {
                team
            }.AsQueryable());

            var teamService = new TeamService(teamsRepo.Object, leaguesRepo.Object);

            // act  & assert
            Assert.Throws <InvalidOperationException>(() => teamService.Add(team, team.Name));
        }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Team model)
 {
     return(dal.Add(model));
 }