public string CreateSessie(Sessie newSessie)
        {
            var           newSessieCode = "-1";
            List <Team>   teams         = new List <Team>();
            List <Puzzel> puzzels       = _puzzelRepo.GetPuzzels().ToList();
            int           startpuzzel   = 0;

            foreach (Team t in newSessie.Teams)
            {
                t.DiamantenVerzameld = 0;
                t.Score       = 0;
                t.Spelers     = null;
                t.TeamMode    = 0;
                t.StartPuzzel = startpuzzel;

                var newT = _teamRepo.NewTeam(t);
                _teamRepo.AddPuzzels(newT, puzzels);

                teams.Add(newT);

                startpuzzel++;
            }
            newSessie.Teams = teams;
            newSessie.Code  = RandomString(6);
            _sessieRepo.AddSessie(newSessie);
            newSessieCode = newSessie.Code;
            return(newSessieCode);
        }
Example #2
0
        public void Create_Sessie()
        {
            var sessieMock = new Mock <ISessionRepository>();
            var teamMock   = new Mock <ITeamRepository>();
            var puzzelMock = new Mock <IPuzzelRepository>();

            sessieMock.Setup(s => s.AddSessie(It.IsAny <Sessie>())).Returns((Sessie newS) => {
                newS.Id   = 5;
                newS.Code = "12";
                return(newS);
            });
            puzzelMock.Setup(p => p.GetPuzzels()).Returns(_fakePuzzelRepo.GetPuzzels());
            var sessie = new SessieService(sessieMock.Object, teamMock.Object, puzzelMock.Object);
            //Arrange
            var newSessie = new Sessie()
            {
                StartTijd = DateTime.Now,
                Teams     = new List <Team>()
                {
                    new Team()
                    {
                        TeamNaam = "Jonas"
                    },
                    new Team()
                    {
                        TeamNaam = "Viktor"
                    },
                    new Team()
                    {
                        TeamNaam = "Joren"
                    },
                }
            };

            // Act
            var result = sessie.CreateSessie(newSessie);

            Console.WriteLine(result.ToString());
            // Assert
            Assert.NotEqual("-1", result);
        }
 public ICollection <Puzzel> GetPuzzels()
 {
     return(_puzzelRepo.GetPuzzels());
 }