public void Get_Teams_Sessie_NewCreated() { //Arrange var newSessie = new Sessie() { StartTijd = DateTime.Now, Teams = new List <Team>() { new Team() { TeamNaam = "Jonas" }, new Team() { TeamNaam = "Viktor" }, new Team() { TeamNaam = "Joren" }, } }; 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); }); sessieMock.Setup(s => s.GetSessies()).Returns(() => { var sessies = _fakeSessieRepo.GetSessies(); sessies.Add(newSessie); return(sessies); }); puzzelMock.Setup(p => p.GetPuzzels()).Returns(_fakePuzzelRepo.GetPuzzels()); var sessie = new SessieService(sessieMock.Object, teamMock.Object, puzzelMock.Object); // Act var resultId = sessie.CreateSessie(newSessie); var result = sessie.GetTeamsBySessie(resultId); // Assert Assert.Equal(result, newSessie.Teams); }
public void Get_Teams_WrongSessie() { var sessieMock = new Mock <ISessionRepository>(); var teamMock = new Mock <ITeamRepository>(); var puzzelMock = new Mock <IPuzzelRepository>(); sessieMock.Setup(s => s.GetSessies()).Returns(_fakeSessieRepo.GetSessies()); var sessie = new SessieService(sessieMock.Object, teamMock.Object, puzzelMock.Object); //Arrange var id = "-1"; // Act var result = sessie.GetTeamsBySessie(id); // Assert Assert.Null(result); }