# 开始XUnit 最简单的就是 ``` public void PlayerService_GetAllPlayers_InvalidLeage() { //Arrange var mockLeageRepo = new MockLeagueRepository().MockIsValid(false); var playerService = new PlayerService(new MockPlayerRepository().Object, new MockTeamRepository().Object, mockLeagueRepo.Object); //Act var allPlayers = playerService.GetForLeague(1); //Assert Assert.Empty(allPlayers); mockLeagueRepo.VerifyIsValid(Times.Once()); } ``` 测试数据源 ``` --InlineData特性 --ClassData特性 --MemberData特性 --来自外部json文件 --来自TheoryData<>泛型 ``` 案例源码:F:\demos\UnitTest\ThirdDemo