コード例 #1
0
        public void Setup()
        {
            messageWriter = new Mock<IMessageWriter>();
            logger = new Mock<ILogger>();
            var drinkFactory = new DrinkFactory();
            var drinkPreperationFactory = new DrinkPreperationFactory();

            var newCafe = new NewAcuCafe(logger.Object, messageWriter.Object, drinkFactory,drinkPreperationFactory);

            newCafe.OrderDrink("", true, false);
        }
コード例 #2
0
        public static Drink OrderDrink(string type, bool hasMilk, bool hasSugar)
        {
            var logger = new FileLogger();
            var messageWriter = new ConsoleWriter();
            var drinkFactory = new DrinkFactory();
            var drinkPreperationFactory = new DrinkPreperationFactory();

            //should not break any dependancies the clients could be having on this class 
            return new NewAcuCafe(logger, messageWriter, 
                                        drinkFactory, drinkPreperationFactory).OrderDrink(type, hasMilk, hasSugar);
        }
コード例 #3
0
        public void WriteMessageIsCalledWithErrorMessage()
        {
            var messageWriter = new Mock<IMessageWriter>();
            var logger = new Mock<ILogger>();
            var drinkFactory = new DrinkFactory();
            var drinkPreperationFactory = new DrinkPreperationFactory();
            var newCafe = new NewAcuCafe(logger.Object, messageWriter.Object, drinkFactory, drinkPreperationFactory);

            newCafe.OrderDrink("IceTea", true, false);

            messageWriter.Verify(m => m.WriteMesage("Cannot make ice tea with milk"));

        }
コード例 #4
0
        public void WriteMessageIsCalled(string type)
        {
            var messageWriter = new Mock<IMessageWriter>();
            var logger = new Mock<ILogger>();
            var drinkFactory = new DrinkFactory();
            var drinkPreperationFactory = new DrinkPreperationFactory();
            var newCafe = new NewAcuCafe(logger.Object, messageWriter.Object,drinkFactory,drinkPreperationFactory);

            newCafe.OrderDrink(type, true, false);

            messageWriter.Verify(m => m.WriteMesage(It.IsAny<string>()));
             
        }