public void CanReadManagerHistoryView() { var team = TeamAjax; var firstmanager = new Manager("Scott", "Hunter"); team.ChangeManagement(firstmanager); team.ChangeManagement(new Manager("Erik", "ten Hag")); var teamdotNet = new Team("dotNet", "The Nerds", "2002", "MS Campus"); teamdotNet.ChangeManagement(firstmanager); teamdotNet.ChangeManagement(new Manager("David", "Fowler")); using (var context = new TeamContext()) { context.AddRange(team, teamdotNet, firstmanager); context.SaveChanges(); } using (var context2 = new TeamContext()) { var histories = context2.ManagerHistories.ToList(); int counter = 0; foreach (var history in context2.ManagerHistories.ToList()) { counter += 1; output.WriteLine($"{history.Manager}: {history.Team}"); } Assert.Equal(4, counter); } }
public void CanStoreAndRetrieveManagerTeamHistory() { var team = TeamAjax; var firstmanager = new Manager("Marcel", "Keizer"); team.ChangeManagement(firstmanager); team.ChangeManagement(new Manager("Erik", "ten Hag")); using (var context = new TeamContext()) { context.AddRange(team, firstmanager); context.SaveChanges(); } using (var context = new TeamContext()) { var M1 = context.Managers.Include(m => m.PastTeams).FirstOrDefault(m => m.NameFactory.Last == "Keizer"); var M2 = context.Managers.Include(m => m.PastTeams).FirstOrDefault(m => m.NameFactory.Last == "ten Hag"); Assert.Equal(new { M1 = "Marcel Keizer", M1Count = 1, M2 = "Erik ten Hag", M2Count = 0 }, new { M1 = M1.Name, M1Count = M1.PastTeams.Count, M2 = M2.Name, M2Count = M2.PastTeams.Count }); } }