Exemplo n.º 1
0
        public async Task Close2PlayersDrawTest()
        {
            var mock = new Mock<IUnityContainer>();
            var matchBP = new MatchBP(_matchStoreMock.Object, _playerStoreMock.Object, _teamStoreMock.Object, _sportStoreMock.Object);

            var rank1 = new Rank {Level = 1000, SportKey = "sport"};
            var rank2 = new Rank {Level = 1000, SportKey = "sport"};

            var match = new BO.Match
            {
                Id = 1,
                CreatorId = "creator",
                SportKey = "sport",
                Scores = "1-2;1-1;2-1",
                Teams = new List<Team>
                {
                    new Team {Players = new List<Player> {new Player {Matricule = "S123456", Ranks = new Collection<Rank> {rank1}}}, Id = 1},
                    new Team {Players = new List<Player> {new Player {Matricule = "S123457", Ranks = new Collection<Rank> {rank2}}}, Id = 2}
                }
            };

            _matchStoreMock.Setup(m => m.GetWithPlayersAndRanks(1)).ReturnsAsync(match);
            _matchStoreMock.Setup(m => m.SaveChangesAsync()).Returns(() => Task.FromResult(default(Task)));
            var result = await matchBP.Close(match,"creator");

            _matchStoreMock.VerifyAll();
            Assert.AreEqual(match, result);
            Assert.AreEqual(rank1.Level, 1000);
            Assert.AreEqual(rank2.Level, 1000);
        }
Exemplo n.º 2
0
        public static RankModel From(Rank rank)
        {
            if (rank == null)
                return null;

            return new RankModel
            {
                PlayerId = rank.PlayerId,
                Player = new PlayerModel
                {
                    Firstname = rank.Player.Firstname,
                    Lastname = rank.Player.Lastname,
                    Matricule = rank.Player.Matricule,
                    Picture = rank.Player.Picture,
                },
                SportKey = rank.SportKey,
                Level = rank.Level
            };
        }