Exemplo n.º 1
0
        public async void CreateButtonTest()
        {
            //Arrange
            var db = MockDb.CreateMockDb();
            var c  = new PlayerStatisticsController(db);


            var playerStatistic = new PlayerStatistics {
                Player_Statistics_Id = 2, FgPercent = 0.379F, FtPercent = 1.000F, ThreePointersMade = 3, PointsMade = 15, Rebounds = 2, Assists = 6, Steals = 6, Blocks = 5, TurnOvers = 3, Player_Id = 1
            };

            //Act
            await c.Create(playerStatistic);

            var r = c.Create();

            //Assert
            Assert.IsType <ViewResult>(r);
        }
Exemplo n.º 2
0
        public async void DeleteConfirmTest()
        {
            //Arrange
            var db = MockDb.CreateMockDb();
            var c  = new PlayerStatisticsController(db);

            var playerStatistic = new PlayerStatistics {
                Player_Statistics_Id = 2, FgPercent = 0.379F, FtPercent = 1.000F, ThreePointersMade = 3, PointsMade = 15, Rebounds = 2, Assists = 6, Steals = 6, Blocks = 5, TurnOvers = 3, Player_Id = 1
            };
            //Act
            var r = await c.Create(playerStatistic);

            //Finds the second element stores in a tmp variable
            var elementToDelete = db.PlayerStatistics.Find(2);

            await c.DeleteConfirmed(elementToDelete.Player_Statistics_Id);

            Assert.DoesNotContain(elementToDelete, db.PlayerStatistics);
        }
Exemplo n.º 3
0
        public async void EditTest()
        {
            //Arrange
            var   db          = MockDb.CreateMockDb();
            var   c           = new PlayerStatisticsController(db);
            short tempRebound = 4;

            var playerStatistic = new PlayerStatistics {
                Player_Statistics_Id = 2, FgPercent = 0.379F, FtPercent = 1.000F, ThreePointersMade = 3, PointsMade = 15, Rebounds = 2, Assists = 6, Steals = 6, Blocks = 5, TurnOvers = 3, Player_Id = 1
            };
            //Act
            await c.Create(playerStatistic);

            playerStatistic.Rebounds = tempRebound;
            var r = await c.Edit(db.PlayerStatistics.Find(2).Player_Statistics_Id, playerStatistic);

            //Assert
            Assert.IsType <RedirectToActionResult>(r);
            Assert.Equal(db.PlayerStatistics.Find(2).Rebounds, tempRebound);
        }
Exemplo n.º 4
0
        public async void TestAddPlayerStatistic()
        {
            //Arrange
            var db = MockDb.CreateMockDb();
            var c  = new PlayerStatisticsController(db);

            var playerStatistic = new PlayerStatistics {
                Player_Statistics_Id = 2, FgPercent = 0.379F, FtPercent = 1.000F, ThreePointersMade = 3, PointsMade = 15, Rebounds = 2, Assists = 6, Steals = 6, Blocks = 5, TurnOvers = 3, Player_Id = 1
            };
            //Act
            var r = await c.Create(playerStatistic);

            //Assert
            var result = Assert.IsType <RedirectToActionResult>(r);

            Assert.Equal("Index", result.ActionName);
            Assert.Equal(1, db.PlayerStatistics.Where(x => x.Player_Statistics_Id == playerStatistic.Player_Statistics_Id && x.FgPercent == playerStatistic.FgPercent && x.FtPercent == playerStatistic.FtPercent &&
                                                      x.ThreePointersMade == playerStatistic.ThreePointersMade && x.PointsMade == playerStatistic.PointsMade && x.Rebounds == playerStatistic.Rebounds && x.Assists == playerStatistic.Assists && x.Blocks == playerStatistic.Blocks &&
                                                      x.TurnOvers == playerStatistic.TurnOvers && x.Player_Id == playerStatistic.Player_Id).Count());
        }
Exemplo n.º 5
0
        public async void DeletePageTest()
        {
            //Arrange
            var db = MockDb.CreateMockDb();
            var c  = new PlayerStatisticsController(db);

            var playerStatistic = new PlayerStatistics {
                Player_Statistics_Id = 2, FgPercent = 0.379F, FtPercent = 1.000F, ThreePointersMade = 3, PointsMade = 15, Rebounds = 2, Assists = 6, Steals = 6, Blocks = 5, TurnOvers = 3, Player_Id = 1
            };
            //Act
            await c.Create(playerStatistic);

            var r = await c.Delete(db.PlayerStatistics.Find(2).Player_Statistics_Id);


            //Assert
            var result = Assert.IsType <ViewResult>(r);
            var model  = Assert.IsAssignableFrom <PlayerStatistics>(result.ViewData.Model);

            Assert.Equal(db.PlayerStatistics.Find(2).Player_Statistics_Id, model.Player_Statistics_Id);
            Assert.Equal(db.PlayerStatistics.Find(2).Rebounds + db.PlayerStatistics.Find(2).Steals, model.Rebounds + model.Steals);
        }
Exemplo n.º 6
0
        public async void TestAddInvalidPlayerStatistic()
        {
            //Arrange
            var db = MockDb.CreateMockDb();
            var c  = new PlayerStatisticsController(db);


            var playerStatistic = new PlayerStatistics {
                Player_Statistics_Id = 2, FgPercent = 0.379F, FtPercent = 1.000F, ThreePointersMade = 3, PointsMade = 15, Assists = 6, Steals = 6, Blocks = 5, TurnOvers = 3, Player_Id = 1
            };

            c.ModelState.AddModelError("Rebounds", "Required");
            //Act
            var r = await c.Create(playerStatistic);

            //Assert
            var result = Assert.IsType <ViewResult>(r);
            var model  = Assert.IsAssignableFrom <PlayerStatistics>(result.ViewData.Model);

            Assert.Equal(playerStatistic, model);
            Assert.IsType <SelectList>(result.ViewData["Player_Id"]);
        }