コード例 #1
0
ファイル: TeamTest.cs プロジェクト: hookFang/BlueGeeks
        public async void DeletePageTest()
        {
            //Arrange
            var db = MockDb.CreateMockDb();
            var c  = new TeamsController(db);

            var teams = new Teams {
                Team_Name = "Everett Otters", Team_Mascot = "Otter", Team_Id = 2, Conference = "Eastern", Wins = 0, Loses = 0, Ties = 0, Win_Streak = 0
            };
            //Act
            await c.Create(teams);

            var r = await c.Delete(db.Teams.Find(2).Team_Id);


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

            Assert.Equal(db.Teams.Find(2).Team_Id, model.Team_Id);
            Assert.Equal(db.Teams.Find(2).Team_Name, model.Team_Name);
        }
コード例 #2
0
ファイル: CoachTest.cs プロジェクト: hookFang/BlueGeeks
        public async void DetailPageTest()
        {
            //Arrange
            var db = MockDb.CreateMockDb();
            var c  = new CoachesController(db);

            var coach = new Coaches {
                Coaches_Id = 2, LastName = "Mar", Title = "Head", Team_Id = 1
            };
            //Act
            await c.Create(coach);

            var r = await c.Details(db.Coaches.Find(2).Coaches_Id);


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

            Assert.Equal(db.Coaches.Find(2).Coaches_Id, model.Coaches_Id);
            Assert.Equal(db.Coaches.Find(2).FirstName + db.Coaches.Find(2).LastName, model.FirstName + model.LastName);
        }
コード例 #3
0
        public async void DeletePageTest()
        {
            //Arrange
            var db = MockDb.CreateMockDb();
            var c  = new StadiumsController(db);

            var stadiums = new Stadium {
                Stadium_Id = 2, StadiumName = "Ever After", City = "Everett", Team_Id = 1
            };
            //Act
            await c.Create(stadiums);

            var r = await c.Delete(db.Stadium.Find(2).Stadium_Id);


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

            Assert.Equal(db.Stadium.Find(2).Stadium_Id, model.Stadium_Id);
            Assert.Equal(db.Stadium.Find(2).StadiumName, model.StadiumName);
        }
コード例 #4
0
ファイル: TeamTest.cs プロジェクト: hookFang/BlueGeeks
        public async void TestAddInvalidTeam()
        {
            //Arrange
            var db = MockDb.CreateMockDb();
            var c  = new TeamsController(db);

            var teams = new Teams {
                Team_Mascot = "Otter", Team_Id = 2, Conference = "Eastern", Wins = 0, Loses = 0, Ties = 0, Win_Streak = 0
            };

            c.ModelState.AddModelError("Team_Name", "Required");

            //Act

            var r = await c.Create(teams);

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

            Assert.Equal(teams, model);
        }
コード例 #5
0
        public async void TestAddInvalidStadium()
        {
            //Arrange
            var db = MockDb.CreateMockDb();
            var c  = new StadiumsController(db);


            var stadiums = new Stadium {
                Stadium_Id = 2, City = "Everett", Team_Id = 2
            };

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

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

            Assert.Equal(stadiums, model);
            Assert.IsType <SelectList>(result.ViewData["Team_Id"]);
        }
コード例 #6
0
        public async void DeletePageTest()
        {
            //Arrange
            var db = MockDb.CreateMockDb();
            var c  = new MatchesController(db);

            var match = new Matches {
                Matche_Id = 2, AwayTeam_Id = 2, MatchDate = DateTime.Now, Stadium_Id = 1
            };
            //Act
            await c.Create(match);

            var r = await c.Delete(db.Matches.Find(2).Matche_Id);


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

            Assert.Equal(db.Matches.Find(2).Matche_Id, model.Matche_Id);
            Assert.Equal(db.Matches.Find(2).AwayTeam_Id, model.AwayTeam_Id);
        }
コード例 #7
0
        public async void EditModelStateNotValidTest()
        {
            //Arrange
            var db = MockDb.CreateMockDb();
            var c  = new PlayersController(db);

            var player = new Player {
                Player_Id = 2, FirstName = "Mar", LastName = "dar", Position = "Head", JerseyNumber = 8, TeamId = 2
            };


            //Act
            await c.Create(player);

            c.ModelState.AddModelError("FirstName", "Required");

            var r = await c.Edit(db.Player.Find(2).Player_Id, player);

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

            Assert.Equal(player, model);
        }
コード例 #8
0
        public async void EditModelStateNotValidTest()
        {
            //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
            };


            //Act
            await c.Create(playerStatistic);

            c.ModelState.AddModelError("Rebounds", "Required");

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

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

            Assert.Equal(playerStatistic, model);
        }
コード例 #9
0
ファイル: CoachTest.cs プロジェクト: hookFang/BlueGeeks
        public async void EditModelStateNotValidTest()
        {
            //Arrange
            var db = MockDb.CreateMockDb();
            var c  = new CoachesController(db);

            var coach = new Coaches {
                Coaches_Id = 2, LastName = "Mar", Title = "Head", Team_Id = 2
            };


            //Act
            await c.Create(coach);

            c.ModelState.AddModelError("FirstName", "Required");

            var r = await c.Edit(db.Coaches.Find(2).Coaches_Id, coach);

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

            Assert.Equal(coach, model);
        }
コード例 #10
0
        public async void EditModelStateNotValidTest()
        {
            //Arrange
            var db = MockDb.CreateMockDb();
            var c  = new StadiumsController(db);

            var stadiums = new Stadium {
                Stadium_Id = 2, City = "Everett", Team_Id = 1
            };


            //Act
            await c.Create(stadiums);

            c.ModelState.AddModelError("StadiumName", "Required");

            var r = await c.Edit(db.Stadium.Find(2).Stadium_Id, stadiums);

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

            Assert.Equal(stadiums, model);
        }
コード例 #11
0
        public async void TestAddInvalidMatch()
        {
            //Arrange
            var db = MockDb.CreateMockDb();
            var c  = new MatchesController(db);


            var match = new Matches {
                Matche_Id = 2, AwayTeam_Id = 2, MatchDate = DateTime.Now, Stadium_Id = 1
            };

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

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

            Assert.Equal(match, model);
            Assert.IsType <SelectList>(result.ViewData["AwayTeam_Id"]);
            Assert.IsType <SelectList>(result.ViewData["HomeTeam_Id"]);
            Assert.IsType <SelectList>(result.ViewData["Stadium_Id"]);
        }
コード例 #12
0
        public async void EditModelStateNotValidTest()
        {
            //Arrange
            var db = MockDb.CreateMockDb();
            var c  = new MatchesController(db);

            var match = new Matches {
                Matche_Id = 2, MatchDate = DateTime.Now, Stadium_Id = 1
            };


            //Act
            await c.Create(match);

            c.ModelState.AddModelError("AwayTeam_Id", "Required");

            var r = await c.Edit(db.Matches.Find(2).Matche_Id, match);

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

            Assert.Equal(match, model);
        }