예제 #1
0
        public void ThrowException_WhenInvalidListIsPassed()
        {
            //Arrange
            Mock <IBroker> brockerMock = new Mock <IBroker>();
            BuyCommand     buyCommand  = new BuyCommand(brockerMock.Object);
            Mock <IUser>   userMock    = new Mock <IUser>();

            IList <string> input = new List <string>();

            //Act & Assert
            Assert.ThrowsException <Exception>(() => buyCommand.Execute(input));
        }
예제 #2
0
        public void CorrectlyExecute_WhenValidDataIsPassed()
        {
            //Arrange
            Mock <IBroker> brockerMock = new Mock <IBroker>();
            Mock <IUser>   userMock    = new Mock <IUser>();

            brockerMock.Setup(brocker => brocker.Buy("name", 10)).Returns("invoked");
            BuyCommand buyCommand = new BuyCommand(brockerMock.Object);

            IList <string> input = new List <string>();

            input.Add("name");
            input.Add("10");

            //Act
            string result = buyCommand.Execute(input);

            //Assert
            Assert.AreEqual("invoked", result);
        }
예제 #3
0
        public void TestTshirt()
        {
            // Given
            IProduct           tshirt     = new Tshirt();
            PurchaseController controller = new PurchaseController();
            ICommand           order      = new OrderCommand(tshirt);

            controller.InsertCommand(order);
            ICommand buy = new BuyCommand(tshirt);

            controller.InsertCommand(buy);

            // When
            var order_t = order.Execute();
            var buy_t   = buy.Execute();

            // Then
            Assert.AreEqual("T-shirt", order_t);
            Assert.AreEqual("19.99", buy_t);
        }
예제 #4
0
        public void TestShoes()
        {
            // Given
            IProduct           shoes      = new Shoes();
            PurchaseController controller = new PurchaseController();
            ICommand           order      = new OrderCommand(shoes);

            controller.InsertCommand(order);
            ICommand buy = new BuyCommand(shoes);

            controller.InsertCommand(buy);

            // When
            var order_t = order.Execute();
            var buy_t   = buy.Execute();

            // Then
            Assert.AreEqual("Shoes", order_t);
            Assert.AreEqual("39.99", buy_t);
        }