public void CanGetPickListByDraftAndMember()
        {
            IFuturePickRepository repository = new FuturePickRepository();

            repository.FuturePickCard(_drafts[0], _members[0], _cards[0]);
            repository.FuturePickCard(_drafts[0], _members[0], _cards[1]);
            repository.FuturePickCard(_drafts[0], _members[0], _cards[2]);

            ICollection<FuturePick> picks = repository.GetFuturePicksByDraftAndMember(_drafts[0], _members[0]);

            Assert.AreEqual(3, picks.Count);
        }
        public void CanMakePick()
        {
            IFuturePickRepository repository = new FuturePickRepository();
            var pick = repository.FuturePickCard(_drafts[0], _members[0], _cards[0]);

            // use session to try to load the pick
            using (ISession session = _sessionFactory.OpenSession())
            {
                var fromDb = session.Get<FuturePick>(pick.Id);

                // Test that the pick was successfully inserted
                Assert.IsNotNull(fromDb);
                Assert.AreNotSame(pick, fromDb);
                Assert.AreEqual(pick.Member.FullName, fromDb.Member.FullName);
                Assert.AreEqual(pick.Draft.Name, fromDb.Draft.Name);
                Assert.AreEqual(pick.Card.Name, fromDb.Card.Name);

                Assert.AreEqual(pick.CreatedDate.ToString(),fromDb.CreatedDate.ToString());
            }
        }
        private void TryFuturePick(int draftId)
        {
            IDraftRepository dr = new DraftRepository();
            IFuturePickRepository fpr = new FuturePickRepository();

            var draft = dr.GetById(draftId);

            var futurePick = fpr.GetNextFuturePick(draft, draft.CurrentTurn);
            if (futurePick != null)
            {
                var futurePickCard = futurePick.Card;
                fpr.RemoveFuturePick(futurePick);

                PickCard(draftId, draft.CurrentTurn.Id, futurePickCard.Id);
            }
        }
        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;
        }
Exemplo n.º 5
0
 public void RemoveMyFuturePick(int futurePickId)
 {
     IFuturePickRepository futurePickRepository = new FuturePickRepository();
     futurePickRepository.RemoveFuturePick(new FuturePick { Id = futurePickId });
 }
Exemplo n.º 6
0
        public List<FuturePick> GetMyFuturePicks(int draftId, int memberId)
        {
            IFuturePickRepository fpr = new FuturePickRepository();
            IDraftRepository dr = new DraftRepository();
            IMemberRepository mr = new MemberRepository();

            var draft = dr.GetById(draftId);
            var member = mr.GetById(memberId);
            var ret = fpr.GetFuturePicksByDraftAndMember(draft, member);
            return ret == null ? new List<FuturePick>() : ret.ToList();
        }
        public void CanPickSameCardTwiceDifferentMembers()
        {
            IFuturePickRepository repository = new FuturePickRepository();

            repository.FuturePickCard(_drafts[0], _members[0], _cards[0]);
            try
            {
                repository.FuturePickCard(_drafts[0], _members[1], _cards[0]);
            }
            catch (GenericADOException)
            {
                Assert.Fail("Should be able to add the same card twice with different members.");
            }
        }
        public void CannotPickSameCardTwiceSameMember()
        {
            IFuturePickRepository repository = new FuturePickRepository();

            repository.FuturePickCard(_drafts[0], _members[0], _cards[0]);
            try
            {
                repository.FuturePickCard(_drafts[0], _members[0], _cards[0]);
            }
            catch (GenericADOException)
            {
                return;
            }

            Assert.Fail("Should not be able to pick same card twice");
        }
        public void CanMakePicks()
        {
            IFuturePickRepository repository = new FuturePickRepository();
            var pick1 = repository.FuturePickCard(_drafts[0], _members[0], _cards[0]);
            var pick2 = repository.FuturePickCard(_drafts[0], _members[0], _cards[1]);
            var pick3 = repository.FuturePickCard(_drafts[0], _members[0], _cards[2]);

            // use session to try to load the pick
            using (ISession session = _sessionFactory.OpenSession())
            {
                var fromDb = session.Get<FuturePick>(pick1.Id);

                // Test that the pick was successfully inserted
                Assert.IsNotNull(fromDb);
                Assert.AreNotSame(pick1, fromDb);
                Assert.AreEqual(pick1.Member.FullName, fromDb.Member.FullName);
                Assert.AreEqual(pick1.Draft.Name, fromDb.Draft.Name);
                Assert.AreEqual(pick1.Card.Name, fromDb.Card.Name);

                fromDb = session.Get<FuturePick>(pick2.Id);
                // Test that the pick was successfully inserted
                Assert.IsNotNull(fromDb);
                Assert.AreNotSame(pick2, fromDb);
                Assert.AreEqual(pick2.Member.FullName, fromDb.Member.FullName);
                Assert.AreEqual(pick2.Draft.Name, fromDb.Draft.Name);
                Assert.AreEqual(pick2.Card.Name, fromDb.Card.Name);

                fromDb = session.Get<FuturePick>(pick3.Id);
                // Test that the pick was successfully inserted
                Assert.IsNotNull(fromDb);
                Assert.AreNotSame(pick3, fromDb);
                Assert.AreEqual(pick3.Member.FullName, fromDb.Member.FullName);
                Assert.AreEqual(pick3.Draft.Name, fromDb.Draft.Name);
                Assert.AreEqual(pick3.Card.Name, fromDb.Card.Name);
            }
        }