public void DoesntAllowNewBidsAfterAuctionIsFinished(int quantityExpected, double[] offers)
        {
            //Arranje
            IEvaluationType evaluationType = new HigherValue();
            var             auction        = new Auction("Van Gogh", evaluationType);
            var             john           = new Interested("Jhon", auction);
            var             mike           = new Interested("Mike", auction);

            auction.StartAuction();
            for (int i = 0; i < offers.Length; i++)
            {
                var value = offers[i];
                if ((i % 2) == 0)
                {
                    auction.ReceiveBid(john, value);
                }
                else
                {
                    auction.ReceiveBid(mike, value);
                }
            }

            auction.FinishAuction();

            //Act
            auction.ReceiveBid(john, 1000);

            //Assert
            var quantityGot = auction.Bids.Count();

            Assert.Equal(quantityExpected, quantityGot);
        }
Пример #2
0
        public void ReturnHigherValueForAuctionWithAtLeastOneAuction(
            double expectedValue,
            double[] offers)
        {
            //Arranje
            IEvaluationType evaluationType = new HigherValue();
            var             auction        = new Auction("Van Gogh", evaluationType);
            var             john           = new Interested("Jhon", auction);
            var             mike           = new Interested("Mike", auction);

            auction.StartAuction();

            for (int i = 0; i < offers.Length; i++)
            {
                var valor = offers[i];
                if ((i % 2) == 0)
                {
                    auction.ReceiveBid(john, valor);
                }
                else
                {
                    auction.ReceiveBid(mike, valor);
                }
            }

            //Act
            auction.FinishAuction();

            //Assert
            var valueGot = auction.BidWinner.Value;

            Assert.Equal(expectedValue, valueGot);
        }
Пример #3
0
        public override string ToString()
        {
            LowerValue.UpdateWhenValueChanged();
            HigherValue.UpdateWhenValueChanged();

            var value = GetShownValue();


            return($"{value} {this.Unit}");
        }
Пример #4
0
        public void ReturnInvalidOperationExceptionForAuctionNotStarted()
        {
            //Arranje
            IEvaluationType evaluationType = new HigherValue();
            var             auction        = new Auction("Van Gogh", evaluationType);

            //Act
            Action act = () => auction.FinishAuction();

            //assert
            Assert.Equal("Is not possible to finish the auction before it has started.",
                         Assert.Throws <InvalidOperationException>(act).Message);
        }
Пример #5
0
        public void ReturnZeroForAuctionsWithoutBids()
        {
            //Arranje
            IEvaluationType evaluationType = new HigherValue();
            var             auction        = new Auction("Van Gogh", evaluationType);

            auction.StartAuction();

            //Act
            auction.FinishAuction();

            //Assert
            var expectedValue = 0;
            var valueGot      = auction.BidWinner.Value;

            Assert.Equal(expectedValue, valueGot);
        }
        public void DoesntAcceptBidFromTheLastClientWhoMadeBid()
        {
            //Arranje
            IEvaluationType evaluationType = new HigherValue();
            var             auction        = new Auction("Van Gogh", evaluationType);
            var             john           = new Interested("John", auction);

            auction.StartAuction();
            auction.ReceiveBid(john, 800);

            //Act
            auction.ReceiveBid(john, 1000);

            //Assert
            var quantityExpected = 1;
            var quantityGot      = auction.Bids.Count();

            Assert.Equal(quantityExpected, quantityGot);
        }