コード例 #1
0
 public void TestInitialize()
 {
     //this runs before each individual test
     //create a new mock data oject to hold a fake list of players
     mock = new Mock <IPlayersMock>();
     //populate mock list
     players = new List <player>
     {
         new player {
             player_id        = 50, first_name = "Rudy", last_name = "Gay",
             salary           = 8000000, position = "Forward", points_per_game = 13,
             rebonds_per_game = 10, injury = "no", team_id = 1
         },
         new player {
             player_id        = 51, first_name = "Patty", last_name = "Mills",
             salary           = 9000000, position = "Guard", points_per_game = 10,
             rebonds_per_game = 3, injury = "no", team_id = 1
         },
         new player {
             player_id        = 52, first_name = "Bryn", last_name = "Forbes",
             salary           = 2000000, position = "Guard", points_per_game = 11,
             rebonds_per_game = 4, injury = "no", team_id = 1
         }
     };
     //put the list to mock object and pass it to player controller
     mock.Setup(m => m.players).Returns(players.AsQueryable());
     controller = new playersController(mock.Object);
 }
コード例 #2
0
        public PlayerStatsUnitTest()
        {
            allPlayers = new List <Player>();
            allPlayers = new DataPlayers().GetData();
            controller = new playersController();
            controller.Configuration = new HttpConfiguration();
            controller.Request       = new HttpRequestMessage();

            controller.Configuration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "{controller}/{id}",
                defaults: new { id = RouteParameter.Optional });
        }