Ejemplo n.º 1
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());
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
        public void Offers_Cannot_Contain_Money_Added_Offer2()
        {
            var offer1 = new TradeOffer(new Club()
            {
                Money = 100
            });
            var offer2 = new TradeOffer(new Club()
            {
                Money = 100
            });

            offer2.AddMoney(10);

            var rule = new OffersCannotContainMoney(offer1, offer2);

            Assert.AreEqual(false, rule.Validate());
        }
Ejemplo n.º 4
0
        public void Offers_Contains_Money_Offer2()
        {
            var offer1 = new TradeOffer(new Club()
            {
                Money = 100
            });
            var offer2 = new TradeOffer(new Club()
            {
                Money = 100
            });

            offer2.AddMoney(10);

            var rule = new OffersContainAtLeastMoney(offer1, offer2);

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