コード例 #1
0
ファイル: Match4x4Test.cs プロジェクト: dlidstrom/Snittlistan
 public Match4x4Test()
 {
     match = DbSeed.Create4x4Match();
     Session.Store(match);
     Session.SaveChanges();
     match = Session.Load<Match4x4>(match.Id);
 }
コード例 #2
0
ファイル: DbSeed.cs プロジェクト: dlidstrom/Snittlistan
        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;
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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 });
        }