示例#1
0
        public void FailsGivenInvalidCommandCode()
        {
            var          drinkMaker         = new DrinkMaker(_dummyMoneyModule, _dummyEmailNotifier, _dummyBeverageQuantityChecker);
            const string invalidCommand     = "Z";
            var          wasCommandExecuted = drinkMaker.TryExecuteCommand(invalidCommand);
            var          drink = drinkMaker.Drink;

            Assert.False(wasCommandExecuted);
            Assert.Null(drink);
        }
示例#2
0
        public void SendMessageToConsoleIfDrinkShortage()
        {
            var mockBeverageQuantityChecker =
                Mock.Of <IBeverageQuantityChecker>(b => b.IsEmpty(It.IsAny <DrinkType>()));

            var drinkMaker = new DrinkMaker(_dummyMoneyModule, _dummyEmailNotifier, mockBeverageQuantityChecker);

            drinkMaker.TryExecuteCommand("C::");

            Mock.Get(_dummyEmailNotifier).Verify(e => e.NotifyMissingDrink(It.IsAny <DrinkType>()), Times.Once);
            Assert.Equal("There is not enough water or milk", drinkMaker.Message);
        }
示例#3
0
        public void RequestPaymentIfMoneyModuleUsed()
        {
            var mockMoneyModule = Mock.Of <IMoneyModule>(m =>
                                                         m.GetOrderTotalMessage() == "M:Order Total: $0.60" &&
                                                         m.AmountPaid == 0.60m);
            var drinkMaker = new DrinkMaker(mockMoneyModule, _dummyEmailNotifier, _dummyBeverageQuantityChecker);

            const string drinkCommand = "C:2:0";

            drinkMaker.TryExecuteCommand(drinkCommand);

            Mock.Get(mockMoneyModule).Verify(m =>
                                             m.GetOrderTotalMessage(), Times.Once);
        }
示例#4
0
        public void ForwardMessageReceived()
        {
            var drinkMaker = new DrinkMaker(_dummyMoneyModule, _dummyEmailNotifier, _dummyBeverageQuantityChecker);

            const string messageCommand  = "M:message-content";
            const string expectedMessage = "message-content";

            var wasCommandExecuted = drinkMaker.TryExecuteCommand(messageCommand);
            var drink   = drinkMaker.Drink;
            var message = drinkMaker.Message;

            Assert.True(wasCommandExecuted);
            Assert.Null(drink);
            Assert.Equal(expectedMessage, message);
        }
示例#5
0
        public void CreateDifferentDrinksGivenDrinkCommand(string drinkCommand, DrinkType expectedDrinkType, int expectedSugars, bool expectedStick)
        {
            var stubMoneyModule = Mock.Of <IMoneyModule>(m =>
                                                         m.GetOrderTotalMessage() == "M:" &&
                                                         m.IsOrderPaid());

            var drinkMaker         = new DrinkMaker(stubMoneyModule, _dummyEmailNotifier, _dummyBeverageQuantityChecker);
            var wasCommandExecuted = drinkMaker.TryExecuteCommand(drinkCommand);
            var drink = drinkMaker.Drink;

            Assert.True(wasCommandExecuted);
            Assert.Equal(expectedDrinkType, drink.DrinkType);
            Assert.Equal(expectedSugars, drink.Sugars);
            Assert.Equal(expectedStick, drink.HasStick());
        }