First example of unit test when inserting the first row after the second one
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestClass] | |
public class ChampionshipBetViewModel_DragAndDrop_Tests | |
{ | |
private readonly ChampionshipBetViewModel _championshipBetViewModel; | |
private readonly Mock<IChampionship> _championShip; | |
private readonly IFootballClub _club1; | |
private readonly IFootballClub _club2; | |
private readonly IFootballClub _club3; | |
private readonly IFootballClub _club4; | |
private IFootballClub GetMockClub(int i) | |
{ | |
var club1 = new Mock<IFootballClub>(); | |
club1.Setup(m => m.FullName).Returns("Club"+i); | |
return club1.Object; | |
} | |
public ChampionshipBetViewModel_DragAndDrop_Tests() | |
{ | |
_club1 = GetMockClub(1); | |
_club2 = GetMockClub(2); | |
_club3 = GetMockClub(3); | |
_club4 = GetMockClub(4); | |
_championShip = new Mock<IChampionship>(); | |
_championShip.SetupGet(c => c.UserBet).Returns(new List<IFootballClub>(new[] { _club1, _club2, _club3, _club4})); | |
_championshipBetViewModel = new ChampionshipBetViewModel(_championShip.Object); | |
} | |
[TestMethod] | |
public void When_Source_Is_FirstRow_And_Target_Second_Then_Drop_Should_Reorder() | |
{ | |
var dropInfo = new Mock<IDropInfo>(); | |
dropInfo.SetupGet(m => m.Data).Returns(new[] { _club1 }); | |
dropInfo.SetupGet(m => m.InsertIndex).Returns(2); | |
_championshipBetViewModel.Drop(dropInfo.Object); | |
var resultClubs = _championshipBetViewModel.FootballClubs.Select(x=>x.FullName).ToArray(); | |
CollectionAssert.AreEqual(new[] { "Club2", "Club1", "Club3", "Club4" }, resultClubs); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment