public void PlaceBid_WhenBidLessThanMinBid_ThrowError()
        {
            var auction = CreateAuction(10);
            var bid     = new Bid(Money.From(5));

            Action act = () => { auction.PlaceBid(bid); };

            act.Should().ThrowExactly <PlacingBidException>();
        }
        public void PlaceBid_WhenNotActive_ThrowError()
        {
            var auction = CreateAuction(1);

            auction.Close();

            var    bid = new Bid(Money.From(5));
            Action act = () => { auction.PlaceBid(bid); };

            act.Should().ThrowExactly <PlacingBidException>();
        }
        public void PlaceBid_WhenBidLargerThanMinBid_ShouldUpdateBids()
        {
            var auction = CreateAuction(10);

            var bid = new Bid(Money.From(50));

            auction.PlaceBid(bid);


            auction.HighestBid.Should().Be(bid);
            auction.Bids.Count.Should().Be(1);
            auction.Bids.Any(x => x == bid).Should().BeTrue();
        }
        public void WinningBid_WhenIsClosedAndHasWinner_ReturnHighestBid()
        {
            var auction = CreateAuction(1);

            var bid = new Bid(Money.From(70));

            auction.PlaceBid(bid);


            auction.Close();

            auction.WinningBid.Should().Be(bid);
        }
        public void PlaceBid_WhenBidLargerThanHighestBid_ShouldUpdateBids()
        {
            var auction = CreateAuction(10);

            var bids = new List <Bid>
            {
                new Bid(Money.From(50)),
                new Bid(Money.From(70))
            };

            bids.ForEach(bid => auction.PlaceBid(bid));

            auction.HighestBid.Should().Be(bids[1]);
            auction.Bids.Should().BeEquivalentTo(bids, options => options.WithStrictOrdering());
        }
        private static Auction CreateAuction(double minAmount)
        {
            var money = Money.From(minAmount);

            return(new Auction(money));
        }