// GET: Matches/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MatchDTO matchDTO = await service.GetMatch(id.Value);

            if (matchDTO == null)
            {
                return(HttpNotFound());
            }

            MatchViewModel viewmodel = new MatchViewModel
            {
                Id        = matchDTO.Id,
                DateTime  = matchDTO.DateTime,
                G1P1Score = matchDTO.G1P1Score,
                G1P2Score = matchDTO.G1P2Score,
                G2P1Score = matchDTO.G2P1Score,
                G2P2Score = matchDTO.G2P2Score,
                G3P1Score = matchDTO.G3P1Score,
                G3P2Score = matchDTO.G3P2Score,
                PlayerId1 = matchDTO.PlayerId1,
                PlayerId2 = matchDTO.PlayerId2
            };
            var players = await playerService.GetPlayersAsync();

            viewmodel.LoadPlayersIntoSelectList(players);

            return(View(viewmodel));
        }
Exemple #2
0
        public void GetMatchTest_Check_Player_Name()
        {
            //arrange
            var matches = new List <Matches>
            {
                new Matches
                {
                    Id           = 5,
                    MatchesScore = new List <MatchesScore>
                    {
                        new MatchesScore {
                            TeamId = 1, HalfTimeScore = 3, FullTimeScore = 2
                        },
                        new MatchesScore {
                            TeamId = 2, HalfTimeScore = 2, FullTimeScore = 4
                        }
                    },
                    MatchesLineUp = new List <MatchesLineUp>
                    {
                        new MatchesLineUp {
                            Player = new Players {
                                NickName = "Sopel"
                            },
                            PlayersScore = new List <PlayersScore>()
                        }
                    },
                    MatchesSpectators = new List <MatchesSpectators>(),
                }
            }.AsQueryable();

            var mockSet = new Mock <DbSet <Matches> >();

            mockSet.As <IQueryable <Matches> >().Setup(m => m.Provider).Returns(matches.Provider);
            mockSet.As <IQueryable <Matches> >().Setup(m => m.Expression).Returns(matches.Expression);
            mockSet.As <IQueryable <Matches> >().Setup(m => m.ElementType).Returns(matches.ElementType);
            mockSet.As <IQueryable <Matches> >().Setup(m => m.GetEnumerator()).Returns(matches.GetEnumerator());
            var mockContext = new Mock <MulderContext>();

            mockContext.Setup(c => c.Matches).Returns(mockSet.Object);

            ///act
            var service = new MatchesService(mockContext.Object);
            var result  = service.GetMatch(5);

            //assert
            Assert.IsTrue(result.Players[0].PlayerNick == "Sopel");
        }