Exemplo n.º 1
0
        public void Buyer_attempts_to_buy_maximum_amount_available()
        {
            Buyer buyer = CreateJoiningBuyer(maximumPrice: 50, numberToBuy: 10);

            StockCommand command = buyer.Process(StockEvent.Price(10, 5));

            command.ShouldEqual(StockCommand.Buy(10, 5));
            buyer.SnapshotShouldEqual(BuyerState.Buying, 10, 5, 0);
        }
Exemplo n.º 2
0
        public void Buyer_buys_when_price_event_with_appropriate_price_arrives()
        {
            Buyer buyer = CreateJoiningBuyer(maximumPrice: 50);

            StockCommand command = buyer.Process(StockEvent.Price(10, 5));

            command.ShouldEqual(StockCommand.Buy(10, 1));
            buyer.SnapshotShouldEqual(BuyerState.Buying, 10, 5, 0);
        }
Exemplo n.º 3
0
        public void Two_commands_are_equal_if_their_contents_match()
        {
            StockCommand command1 = StockCommand.Buy(123, 10);
            StockCommand command2 = StockCommand.Buy(123, 10);

            bool areEqual1 = command1.Equals(command2);
            bool areEqual2 = command1 == command2;
            bool areEqual3 = command1.GetHashCode() == command2.GetHashCode();

            areEqual1.ShouldBeTrue();
            areEqual2.ShouldBeTrue();
            areEqual3.ShouldBeTrue();
        }
Exemplo n.º 4
0
        public void Buy_command_is_of_appropriate_content()
        {
            StockCommand command = StockCommand.Buy(123, 10);

            command.ToString().ShouldEqual("Command: BUY; Price: 123; Number: 10");
        }