Esempio n. 1
0
        public void Offers_Max_Player_Exceeded()
        {
            TransferMarket market;
            Club           manchester;
            Club           barcelona;

            SetUpMock(out market, out manchester, out barcelona);

            var aguero = manchester.GetPlayer(2);
            var messi  = barcelona.GetPlayer(1);
            var neymar = barcelona.GetPlayer(3);
            var suarez = barcelona.GetPlayer(5);

            var offer1 = new TradeOffer(barcelona);

            offer1.AddPlayer(messi);
            offer1.AddPlayer(neymar);
            offer1.AddPlayer(suarez);

            var offer2 = new TradeOffer(manchester);

            offer2.AddPlayer(aguero);

            var rule = new OffersMaxPlayer(offer1, offer2, market.MaxPlayerTrade);

            Assert.AreEqual(false, rule.Validate());
        }
Esempio n. 2
0
        public void Exchange_Can_Not_Contans_Money()
        {
            TransferMarket market;
            Club           manchester;
            Club           barcelona;

            SetUpMock(out market, out manchester, out barcelona);

            var messi  = barcelona.GetPlayer(1);
            var aguero = manchester.GetPlayer(2);

            var buyerOffer = new TradeOffer(manchester);

            buyerOffer.AddPlayer(aguero);

            var sellerOffer = new TradeOffer(barcelona);

            sellerOffer.AddPlayer(messi);
            sellerOffer.AddMoney(100);

            var notificacoes = EventTrigger.ContainerResolver.GetService <IEventHandler <DomainNotification> >();

            market.ExchangePlayer(buyerOffer, sellerOffer);

            Assert.AreEqual(true, notificacoes.HasNotifications());
        }
Esempio n. 3
0
        public void Range_Price_Trade_AboveRange()
        {
            TransferMarket market;
            Club           manchester;
            Club           barcelona;

            SetUpMock(out market, out manchester, out barcelona);

            var aguero = manchester.GetPlayer(2);

            aguero.Price = 7000;

            var messi = barcelona.GetPlayer(1);

            messi.Price = 5000;

            var buyer = new TradeOffer(manchester);

            buyer.AddPlayer(aguero);

            var seller = new TradeOffer(barcelona);

            seller.AddPlayer(messi);

            var rule = new RangePriceTrade(buyer, seller, market.TradePercent);

            Assert.AreEqual(false, rule.Validate());
        }
Esempio n. 4
0
        public void TradeOffer_Player_And_Money()
        {
            TransferMarket market;
            Club           manchester;
            Club           barcelona;

            SetUpMock(out market, out manchester, out barcelona);

            var messi  = barcelona.GetPlayer(1);
            var aguero = manchester.GetPlayer(2);

            var buyerOffer = new TradeOffer(manchester);

            buyerOffer.AddMoney(2500);
            buyerOffer.AddPlayer(aguero);

            var sellerOffer = new TradeOffer(barcelona);

            sellerOffer.AddPlayer(messi);

            market.Trade(buyerOffer, sellerOffer);



            Assert.AreEqual(true, manchester.HasPlayer(messi) &&
                            !barcelona.HasPlayer(messi) &&
                            manchester.Money == 2500 &&
                            barcelona.Money == 7500 &&
                            !manchester.HasPlayer(aguero) &&
                            barcelona.HasPlayer(aguero));
        }
Esempio n. 5
0
        public void Offers_Contains_At_Least_One_Player_Offer2()
        {
            TransferMarket market;
            Club           manchester;
            Club           barcelona;

            SetUpMock(out market, out manchester, out barcelona);

            var aguero = manchester.GetPlayer(2);

            var offer1 = new TradeOffer(barcelona);

            var offer2 = new TradeOffer(manchester);

            offer2.AddPlayer(aguero);

            var rule = new OffersContainsAtLeastPlayer(offer1, offer2);

            Assert.AreEqual(true, rule.Validate());
        }
Esempio n. 6
0
        public void Offers_Min_Player_MinNumber()
        {
            TransferMarket market;
            Club           manchester;
            Club           barcelona;

            SetUpMock(out market, out manchester, out barcelona);

            var aguero = manchester.GetPlayer(2);
            var messi  = barcelona.GetPlayer(1);

            var offer1 = new TradeOffer(barcelona);

            offer1.AddPlayer(messi);

            var offer2 = new TradeOffer(manchester);

            offer2.AddPlayer(aguero);

            var rule = new OffersMinPlayer(offer1, offer2, market.MinPlayerTrade);

            Assert.AreEqual(true, rule.Validate());
        }