public void CanEditDetails()
        {
            // Arrange
            var then = DateTime.Now.AddDays(-1);
            var originalMatch = new Match8x4("Place", then, 1, new Team8x4("Home", 13), new Team8x4("Away", 6));
            Session.Store(originalMatch);
            Session.SaveChanges();

            // Act
            var controller = new MatchController { DocumentSession = Session };
            var now = DateTimeOffset.Now;
            var result = controller.EditDetails8x4(new Match8x4ViewModel.MatchDetails
            {
                Id = originalMatch.Id,
                Location = "NewPlace",
                Date = now,
                BitsMatchId = 2
            });

            // Assert
            result.AssertActionRedirect().ToAction("Details8x4").WithParameter("id", originalMatch.Id);
            var match = Session.Load<Match8x4>(originalMatch.Id);
            Assert.Equal("NewPlace", match.Location);
            Assert.Equal(now, match.Date);
            Assert.Equal(2, match.BitsMatchId);
        }
Beispiel #2
0
 public Match8x4Test()
 {
     match = DbSeed.Create8x4Match();
     Session.Store(match);
     Session.SaveChanges();
     match = Session.Load<Match8x4>(match.Id);
 }
        public void CanEditTeam()
        {
            // Arrange
            var originalMatch = new Match8x4("Place", DateTime.Now, 1, new Team8x4("Home", 13), new Team8x4("Away", 6));
            Session.Store(originalMatch);
            Session.SaveChanges();

            // Act
            var controller = new MatchController { DocumentSession = Session };
            var result = controller.EditTeam8x4(new EditTeam8x4ViewModel
            {
                Id = originalMatch.Id,
                IsHomeTeam = false,
                Team = DbSeed.Create8x4Match().AwayTeam.MapTo<Team8x4ViewModel>()
            });
            Session.SaveChanges();

            // Assert
            result.AssertActionRedirect().ToAction("Details8x4").WithParameter("id", originalMatch.Id);
            var match = Session.Load<Match8x4>(originalMatch.Id);
            TestData.VerifyTeam(match.AwayTeam);
        }
        public ActionResult Register8x4(Register8x4MatchViewModel model)
        {
            if (DocumentSession.BitsIdExists(model.BitsMatchId))
                ModelState.AddModelError("BitsMatchId", "Matchen redan registrerad");

            if (!ModelState.IsValid)
                return View(model);

            var match = new Match8x4(
                model.Location,
                model.Date,
                model.BitsMatchId,
                model.HomeTeam.MapTo<HomeTeamFactory>().CreateTeam(),
                model.AwayTeam.MapTo<AwayTeamFactory>().CreateTeam());
            DocumentSession.Store(match);

            return RedirectToAction("Details8x4", new { id = match.Id });
        }
Beispiel #5
0
        public static Match8x4 Create8x4Match()
        {
            var series = new List<Serie8x4>
            {
                new Serie8x4(new List<Table8x4>
                {
                    new Table8x4
                    {
                        Score = 1,
                        Game1 = new Game8x4("Mikael Axelsson", 202)
                        {
                            Strikes = 5,
                            Misses = 2,
                            OnePinMisses = 1,
                            Splits = 2,
                            CoveredAll = true
                        },
                        Game2 = new Game8x4("Christer Liedholm", 218)
                    },
                    new Table8x4
                    {
                        Score = 0,
                        Game1 = new Game8x4("Kjell Persson", 172),
                        Game2 = new Game8x4("Peter Sjöberg", 220),
                    },
                    new Table8x4
                    {
                        Score = 0,
                        Game1 = new Game8x4("Kjell Jansson", 166),
                        Game2 = new Game8x4("Hans Norbeck", 194)
                    },
                    new Table8x4
                    {
                        Score = 1,
                        Game1 = new Game8x4("Lars Öberg", 222),
                        Game2 = new Game8x4("Torbjörn Jensen", 204)
                    }
                }),
                new Serie8x4(new List<Table8x4>
                {
                    new Table8x4
                    {
                        Score = 1,
                        Game1 = new Game8x4("Lars Öberg", 182),
                        Game2 = new Game8x4("Torbjörn Jensen", 211)
                    },
                    new Table8x4
                    {
                        Score = 1,
                        Game1 = new Game8x4("Kjell Jansson", 208),
                        Game2 = new Game8x4("Hans Norbeck", 227)
                    },
                    new Table8x4
                    {
                        Score = 0,
                        Game1 = new Game8x4("Kjell Persson", 194),
                        Game2 = new Game8x4("Peter Sjöberg", 195)
                    },
                    new Table8x4
                    {
                        Score = 0,
                        Game1 = new Game8x4("Mikael Axelsson", 206),
                        Game2 = new Game8x4("Christer Liedholm", 150)
                    }
                }),
                new Serie8x4(new List<Table8x4>
                {
                    new Table8x4
                    {
                        Score = 0,
                        Game1 = new Game8x4("Kjell Persson", 174),
                        Game2 = new Game8x4("Peter Sjöberg", 182)
                    },
                    new Table8x4
                    {
                        Score = 1,
                        Game1 = new Game8x4("Mikael Axelsson", 214),
                        Game2 = new Game8x4("Christer Liedholm", 176)
                    },
                    new Table8x4
                    {
                        Score = 0,
                        Game1 = new Game8x4("Lars Öberg", 168),
                        Game2 = new Game8x4("Torbjörn Jensen", 199)
                    },
                    new Table8x4
                    {
                        Score = 0,
                        Game1 = new Game8x4("Kjell Jansson", 180),
                        Game2 = new Game8x4("Hans Norbeck", 212)
                    }
                }),
                new Serie8x4(new List<Table8x4>
                {
                    new Table8x4
                    {
                        Score = 0,
                        Game1 = new Game8x4("Kjell Jansson", 189),
                        Game2 = new Game8x4("Hans Norbeck", 181)
                    },
                    new Table8x4
                    {
                        Score = 0,
                        Game1 = new Game8x4("Lars Öberg", 227),
                        Game2 = new Game8x4("Torbjörn Jensen", 180)
                    },
                    new Table8x4
                    {
                        Score = 1,
                        Game1 = new Game8x4("Mikael Axelsson", 223),
                        Game2 = new Game8x4("Christer Liedholm", 191)
                    },
                    new Table8x4
                    {
                        Score = 0,
                        Game1 = new Game8x4("Thomas Gurell", 159),
                        Game2 = new Game8x4("Peter Sjöberg", 190)
                    }
                }),
            };
            var match = new Match8x4(
                location: "Sollentuna Bowlinghall",
                date: new DateTime(2011, 03, 26),
                bitsMatchId: 3003231,
                homeTeam: new Team8x4("Sollentuna Bwk", 13),
                awayTeam: new Team8x4("Fredrikshof IF", 6, series));

            return match;
        }