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 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); }