public void CandFindCard()
        {
            var card = new Card { Name = "White Knight", CastingCost = "WW", Type = "Creature - Knight" };
            ICardRepository repository = new CardRepository();
            repository.Add(card);

            var fromDb = repository.FindCard("White");
            Assert.IsNotNull(fromDb);
            Assert.AreNotEqual(fromDb.Count, 0);
        }
        public void CanRemoveExistingCard()
        {
            var card = _cards[0];
            ICardRepository repository = new CardRepository();
            repository.Remove(card);

            using (ISession session = _sessionFactory.OpenSession())
            {
                var fromDb = session.Get<Card>(card.Id);
                Assert.IsNull(fromDb);
            }
        }
        public void CanAddCard()
        {
            var card = new Card {Name = "White Knight", CastingCost = "WW", Type = "Creature - Knight"};

            ICardRepository repository = new CardRepository();
            repository.Add(card);

            // use session to try to load the product);
            using (var session = _sessionFactory.OpenSession())
            {
                var fromDb = session.Get<Card>(card.Id);

                // Test that the color was successfully inserted
                Assert.IsNotNull(fromDb);
                Assert.AreNotSame(card, fromDb);
                Assert.AreEqual(card.Name, fromDb.Name);
                Assert.AreEqual(card.CastingCost, fromDb.CastingCost);
                Assert.AreEqual(card.Type, fromDb.Type);
            }
        }
        public bool PickCard(int draftId, int memberId, int cardId)
        {
            if (!IsMyTurn(draftId, memberId))
            {
                return FuturePickCard(draftId, memberId, cardId);
            }

            IDraftRepository dr = new DraftRepository();
            IMemberRepository mr = new MemberRepository();
            ICardRepository cr = new CardRepository();

            var draft = dr.GetById(draftId);
            var member = mr.GetById(memberId);
            var card = cr.GetById(cardId);

            if (draft.Finished || !draft.Started)
            {
                return false;
            }

            IPickRepository pickRepository = new PickRepository();
            try
            {
                var pick = pickRepository.PickCard(draft, member, card);
            }
            catch (GenericADOException)
            {
                return false;
            }

            var picks = pickRepository.GetPicksByDraft(draft);

            IDraftMemberPositionsRepository dmpr = new DraftMemberPositionsRepository();
            var nextMemberDraftPosition = dmpr.GetDraftMemberPositionByDraftAndPosition(draft,
                                                                                        GetNextPickPosition(picks.Count, draft.DraftSize));

            draft.CurrentTurn = nextMemberDraftPosition.Member;

            IDraftRepository draftRepository = new DraftRepository();
            draftRepository.Update(draft);

            TryFuturePick(draftId);

            return true;
        }
        public bool FuturePickCard(int draftId, int memberId, int cardId)
        {
            IFuturePickRepository fpr = new FuturePickRepository();
            IDraftRepository dr = new DraftRepository();
            IMemberRepository mr = new MemberRepository();
            ICardRepository cr = new CardRepository();

            var draft = dr.GetById(draftId);
            var member = mr.GetById(memberId);
            var card = cr.GetById(cardId);

            try
            {
                fpr.FuturePickCard(draft, member, card);
            }
            catch (GenericADOException)
            {
                return false;
            }

            return true;
        }
Exemple #6
0
 public List<Card> FindCard(string searchText)
 {
     ICardRepository cr = new CardRepository();
     var ret = cr.FindCard(searchText);
     return ret == null ? new List<Card>() : ret.ToList();
 }
Exemple #7
0
        public bool IsCardPicked(int draftId, int cardId)
        {
            IPickRepository pr = new PickRepository();
            IDraftRepository dr = new DraftRepository();
            ICardRepository cr = new CardRepository();

            var draft = dr.GetById(draftId);
            var card = cr.GetById(cardId);

            var picks = pr.GetPicksByCardAndDraft(card, draft);
            return picks.Count > 0;
        }
Exemple #8
0
 public Card GetCard(int cardId)
 {
     ICardRepository cr = new CardRepository();
     return cr.GetById(cardId);
 }
Exemple #9
0
 public Card GetCard(string cardName)
 {
     ICardRepository cr = new CardRepository();
     return cr.GetByName(cardName);
 }
        public void CanUpdateExistingCard()
        {
            var card = _cards[0];
            card.Name = "Törst efter Kunskap";

            ICardRepository repository = new CardRepository();
            repository.Update(card);

            // use session to try to load the product
            using (ISession session = _sessionFactory.OpenSession())
            {
                var fromDb = session.Get<Card>(card.Id);
                Assert.AreEqual(card.Name, fromDb.Name);
            }
        }