Пример #1
0
        public void GivenRunningCompetitonAndSession_WhenDuelIsDecided_ThenCompetitionIsUpdated()
        {
            this.session = SessionFactory.Create(this.competition.Id, this.competitionRepository.Object);
            var duel = this.session.NextDuel();

            var stateService = new OperationChecker(this.competitionRepository.Object);
            var transferService = new DecisionGateway(this.competitionRepository.Object, stateService);
            this.session.MakeDecision(duel, duel.Option1, transferService);

            Assert.AreEqual(1, this.competition.GetWinCount(duel.Option1));
            Assert.AreEqual(1, this.competition.GetLossCount(duel.Option2));
        }
Пример #2
0
        public bool MakeDecision(Guid sessionId, Decision decision)
        {
            var session = Get(sessionId);
            if (session == null) return false;
            if (session.IsClosed) return false;

            var operationChecker = new OperationChecker(this.competitionRepository);
            var gateway = new DecisionGateway(this.competitionRepository, operationChecker);
            session.RegisterDecision(decision, gateway);

            this.unitOfWork.Commit();
            return true;
        }