Exemplo n.º 1
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));
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
0
        public void RegisterAuction_ShouldThrowExceptionDueOfferor()
        {
            BiddingBroker broker = new BiddingBroker(InitMockedDb());

            Person badPerson3 = new Person()
            {
                Name = "gigica", Phone = null
            };

            Auction goodAuction = GetGoodAuction(broker);

            Assert.ThrowsAny <Exception>(() => broker.RegisterAuction(badPerson3, goodAuction));
        }
Exemplo n.º 4
0
        public void RegisterAuction_ShouldRegisterOrReturnAlreadyRegistered()
        {
            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);
        }
Exemplo n.º 5
0
        void EndAuction_ShouldThrowException()
        {
            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 good2 = GetGoodPerson2(broker);

            Assert.ThrowsAny <Exception>(() => broker.EndAuction(good2, goodAuction));
        }
Exemplo n.º 6
0
        public void RegisterAuction_ShouldThrowExceptionDueProduct()
        {
            BiddingBroker broker = new BiddingBroker(InitMockedDb());

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

            Product badProduct = new Product()
            {
                Name = "bad"
            };

            goodAuction.Product = badProduct;

            Assert.ThrowsAny <Exception>(() => broker.RegisterAuction(goodPerson, goodAuction));
        }
Exemplo n.º 7
0
        [Fact] void EndAuction_ShouldEndAuction()
        {
            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);

            bool didThrow = false;

            try
            {
                broker.EndAuction(goodPerson, goodAuction);
            } catch (Exception)
            {
                didThrow = true;
            }

            Assert.False(didThrow);
        }
Exemplo n.º 8
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);
        }