public Match4x4Test() { match = DbSeed.Create4x4Match(); Session.Store(match); Session.SaveChanges(); match = Session.Load<Match4x4>(match.Id); }
public static Match4x4 Create4x4Match() { var series = new List<Serie4x4> { new Serie4x4(new List<Game4x4> { new Game4x4("Tomas Gustavsson", 160, 0), new Game4x4("Markus Norbeck", 154, 0), new Game4x4("Lars Norbeck", 169, 1), new Game4x4("Matz Classon", 140, 0), }), new Serie4x4(new List<Game4x4> { new Game4x4("Tomas Gustavsson", 141, 0), new Game4x4("Markus Norbeck", 114, 0), new Game4x4("Lars Norbeck", 163, 1), new Game4x4("Matz Classon", 127, 0), }), new Serie4x4(new List<Game4x4> { new Game4x4("Tomas Gustavsson", 128, 1), new Game4x4("Markus Norbeck", 165, 0), new Game4x4("Lars Norbeck", 231, 1), new Game4x4("Matz Classon", 165, 0), }), new Serie4x4(new List<Game4x4> { new Game4x4("Tomas Gustavsson", 132, 0), new Game4x4("Markus Norbeck", 165, 0), new Game4x4("Lars Norbeck", 154, 1), new Game4x4("Matz Classon", 162, 1), }) }; var match = new Match4x4( location: "Bowl-O-Rama", date: new DateTime(2012, 01, 28), homeTeam: new Team4x4("Fredrikshof C", 6, series), awayTeam: new Team4x4("Librex", 14)); return match; }
public void CanEditTeam() { // Arrange var originalMatch = new Match4x4("Place", DateTime.Now, new Team4x4("Home", 13), new Team4x4("Away", 6)); Session.Store(originalMatch); Session.SaveChanges(); // Act var controller = new MatchController { DocumentSession = Session }; var result = controller.EditTeam4x4(new EditTeam4x4ViewModel { Id = originalMatch.Id, IsHomeTeam = false, Team = DbSeed.Create4x4Match().HomeTeam.MapTo<Team4x4ViewModel>() }); Session.SaveChanges(); // Assert result.AssertActionRedirect().ToAction("Details4x4").WithParameter("id", originalMatch.Id); var match = Session.Load<Match4x4>(originalMatch.Id); TestData.VerifyTeam(match.AwayTeam); }
public void CanEditDetails() { // Arrange var then = DateTime.Now.AddDays(-1); var originalMatch = new Match4x4("Place", then, new Team4x4("Home", 13), new Team4x4("Away", 6)); Session.Store(originalMatch); Session.SaveChanges(); // Act var controller = new MatchController { DocumentSession = Session }; var now = DateTimeOffset.Now; var result = controller.EditDetails4x4(new Match4x4ViewModel.MatchDetails { Id = originalMatch.Id, Location = "NewPlace", Date = now }); // Assert result.AssertActionRedirect().ToAction("Details4x4").WithParameter("id", originalMatch.Id); var match = Session.Load<Match4x4>(originalMatch.Id); Assert.Equal("NewPlace", match.Location); Assert.Equal(now, match.Date); }
public ActionResult Register4x4(Register4x4MatchViewModel model) { if (!ModelState.IsValid) return View(model); var match = new Match4x4( model.Location, model.Date, model.HomeTeam.MapTo<Team4x4>(), model.AwayTeam.MapTo<Team4x4>()); DocumentSession.Store(match); return RedirectToAction("Details4x4", new { id = match.Id }); }