Beispiel #1
0
        public void RegisterBid_ShouldThrowExceptionDueBidder()
        {
            BiddingBroker broker = new BiddingBroker(InitMockedDb());

            Person  goodPerson  = GetGoodPerson(broker);
            Auction goodAuction = GetGoodAuction(broker);

            Auction registeredAuction = broker.RegisterAuction(goodPerson, goodAuction);

            Assert.NotNull(registeredAuction);
            Assert.NotEqual(0, registeredAuction.IdAuction);

            Person bidder = new Person()
            {
                Name = "bad"
            };
            double value = goodAuction.StartValue + 1;

            Bid bid = new Bid()
            {
                Currency = goodAuction.Currency,
                Date     = DateTime.Now,
                Value    = value,
                Auction  = goodAuction,
            };

            Assert.ThrowsAny <Exception>(() => broker.RegisterBid(bidder, bid, goodAuction));
        }
Beispiel #2
0
        public void RegisterBid_ShouldThrowExceptionDueCurrency()
        {
            BiddingBroker broker = new BiddingBroker(InitMockedDb());

            Person  goodPerson  = GetGoodPerson(broker);
            Auction goodAuction = GetGoodAuction(broker);

            Auction registeredAuction = broker.RegisterAuction(goodPerson, goodAuction);

            Assert.NotNull(registeredAuction);
            Assert.NotEqual(0, registeredAuction.IdAuction);

            Person bidder    = GetGoodPerson2(broker);
            double bad_value = goodAuction.StartValue - 1;

            Bid bid = new Bid()
            {
                Currency = broker.GetCurrencyByName("eur"),
                Date     = DateTime.Now,
                Value    = bad_value,
                Auction  = goodAuction,
            };

            Assert.ThrowsAny <Exception>(() => broker.RegisterBid(bidder, bid, goodAuction));
        }
Beispiel #3
0
        public void RegisterBid_ShouldRegisterBid()
        {
            BiddingBroker broker = new BiddingBroker(InitMockedDb());

            Person  goodPerson  = GetGoodPerson(broker);
            Auction goodAuction = GetGoodAuction(broker);

            Auction registeredAuction = broker.RegisterAuction(goodPerson, goodAuction);

            Assert.NotNull(registeredAuction);
            Assert.NotEqual(0, registeredAuction.IdAuction);

            Person bidder = GetGoodPerson2(broker);
            double value  = goodAuction.StartValue + 1;

            Bid bid = new Bid()
            {
                Currency = goodAuction.Currency,
                Date     = DateTime.Now,
                Value    = value,
                Auction  = goodAuction,
            };

            //SHOULD NOT THROW
            bool throwed = false;

            try
            {
                broker.RegisterBid(bidder, bid, goodAuction);
            } catch (Exception)
            {
                throwed = true;
            }

            Assert.False(throwed);
        }