public BasketballTeam CreateTeam(BasketballTeam basketballTeam) { var teamToCreate = _BTRepository.Create(basketballTeam); _unitOfWork.Commit(); return(teamToCreate); }
private Team buildBasketballTeam() { Team team = new BasketballTeam(rnd.Next(1000000)); MyCollection <Character> characters = new MyCollection <Character>(); for (int i = 0; i < (int)TeamType.Basketball; i++) { characters.pushBack(getPlayer()); } team.Coach = getCoach(); team.Players = characters; return(team); }
public void GetTeamById() { var unitOfWork = new Mock <IUnitOfWork>(); var teamFinder = new Mock <IBasketballTeamFinder>(); var teamCollection = new Mock <IRepository <BasketballTeam> >(); var team = new BasketballTeam(); var basketballTeamService = new BasketballTeamService(unitOfWork.Object, teamFinder.Object, teamCollection.Object); teamFinder.Setup(x => x.FindBasketballTeamById(team.Id)) .Returns(new List <BasketballTeam>()); basketballTeamService.GetTeamById(team.Id); teamFinder.Verify(x => x.FindBasketballTeamById(It.IsAny <int>())); }
public void DeleteTeam() { //initiallizing var basketballTeam = new BasketballTeam(); var unitOfWork = new Mock <IUnitOfWork>(); var teamFinder = new Mock <IBasketballTeamFinder>(); var teamCollection = new Mock <IRepository <BasketballTeam> >(); var basketballTeamService = new BasketballTeamService(unitOfWork.Object, teamFinder.Object, teamCollection.Object); //act teamCollection.Setup(x => x.Delete(basketballTeam)); basketballTeamService.DeleteTeam(basketballTeam); //assert teamCollection.Verify(x => x.Delete(It.IsAny <BasketballTeam>()), Times.Once); }
static void Main(string[] args) { BasketballTeam bt = new BasketballTeam("MyTeam"); BasketballPlayer bp = new BasketballPlayer("Bob"); bt.AddPlayer(bp); foreach (BasketballPlayer player in bt.Players) { Console.WriteLine(player.Name); } foreach (IAthlete a in bt.Players) { Console.WriteLine(a.Name); } }
public void GetTeamsByWins() { //initiallizing var team = new BasketballTeam(); var unitOfWork = new Mock <IUnitOfWork>(); var finder = new Mock <IBasketballTeamFinder>(); var teamCollection = new Mock <IRepository <BasketballTeam> >(); var service = new BasketballTeamService(unitOfWork.Object, finder.Object, teamCollection.Object); //act finder.Setup(x => x.FindBasketballTeamsByWins(team.WinsCount)) .Returns(new List <BasketballTeam>()); service.GetTeamsByWins(team.WinsCount); //assert finder.Verify(x => x.FindBasketballTeamsByWins(It.IsAny <int>())); }
public void CreateTeam() { //arrange var basketballTeam = new BasketballTeam(); var teamCollection = new Mock <IRepository <BasketballTeam> >(); var unitOfWork = new Mock <IUnitOfWork>(); var teamFinder = new Mock <IBasketballTeamFinder>(); var basketballTeamService = new BasketballTeamService(unitOfWork.Object, teamFinder.Object, teamCollection.Object); //act teamCollection.Setup(x => x.Create(basketballTeam)) .Returns(basketballTeam); basketballTeamService.CreateTeam(basketballTeam); //test teamCollection.Verify(x => x.Create(It.IsAny <BasketballTeam>()), Times.Once); }
protected override void Seed(SportBets.DAL.EntitiesContext.SportBetsContext context) { var user1 = new User() { Email = "*****@*****.**", PasswordHash = "123456789", RegistrationDate = new DateTime(2018, 1, 14) }; var user2 = new User() { Email = "*****@*****.**", PasswordHash = "987654321", RegistrationDate = new DateTime(2018, 9, 10) }; var user3 = new User() { Email = "*****@*****.**", PasswordHash = "123456789", RegistrationDate = new DateTime(2018, 8, 8) }; var horse1 = new Horse() { Id = 1, Age = 15, WinsCount = 43, LossesCount = 12, Weight = 380, HorseName = "Junky" }; var horse2 = new Horse() { Id = 2, Age = 13, WinsCount = 65, LossesCount = 1, Weight = 450, HorseName = "Sonic" }; var horse3 = new Horse() { Id = 3, Age = 20, WinsCount = 43, LossesCount = 42, Weight = 553, HorseName = "Marco" }; var ftTeam1 = new FootballTeam() { Id = 1, WinsCount = 23, LossesCount = 16, TeamName = "Spark" }; var ftTeam2 = new FootballTeam() { Id = 2, WinsCount = 30, LossesCount = 1, TeamName = "OG" }; var ftTeam3 = new FootballTeam() { Id = 3, WinsCount = 14, LossesCount = 16, TeamName = "Bizons" }; var btTeam1 = new BasketballTeam() { Id = 1, LossesCount = 4, TeamName = "Team Liquid", WinsCount = 10 }; var btTeam2 = new BasketballTeam() { Id = 2, LossesCount = 15, TeamName = "EG", WinsCount = 2 }; var btTeam3 = new BasketballTeam() { Id = 3, LossesCount = 1, TeamName = "Virtus", WinsCount = 18 }; // This method will be called after migrating to the latest version. var users = new List <User> { user1, user2, user3 }; var horses = new List <Horse> { horse1, horse2, horse3 }; var ftTeams = new List <FootballTeam> { ftTeam1, ftTeam2, ftTeam3 }; var btTeams = new List <BasketballTeam> { btTeam1, btTeam2, btTeam3 }; //Users context.Users.AddOrUpdate(x => x.Id, user1, user2, user3); //Bets context.Bets.AddOrUpdate(x => x.Id, new Bet() { BetDate = DateTime.Today, BetItemType = ItemType.Horse, Coefficient = 9.25, User = user1 }, new Bet() { BetDate = DateTime.Today, BetItemType = ItemType.Football, Coefficient = 2.78, User = user2 }, new Bet() { BetDate = DateTime.Today, BetItemType = ItemType.Basketball, Coefficient = 3.45, User = user3 }); //Horses context.Horses.AddOrUpdate(x => x.Id, horse1, horse2, horse3); //Football Teams context.FootballTeams.AddOrUpdate(x => x.Id, ftTeam1, ftTeam2, ftTeam3); //Basketball Teams context.BasketballTeams.AddOrUpdate(x => x.Id, btTeam1, btTeam2, btTeam3); }
public void DeleteTeam(BasketballTeam basketballTeam) { _BTRepository.Delete(basketballTeam); _unitOfWork.Commit(); }