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)); }
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); }
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); }
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); }