public void ShouldParseExpressionAndEvaluateResult() { _helper.Expect(c => c.ParseExpression("2/3 + 4/5")).Return("22/15"); _model = new ExpressionModel { Expression = "2/3 + 4/5" }; var actionResult = _controller.Index(_model) as ViewResult; _helper.VerifyAllExpectations(); Assert.IsNotNull(actionResult); var model = actionResult.Model as ExpressionModel; Assert.IsNotNull(model); Assert.AreEqual("22/15", model.Result); }
public void ShouldParseExpressionAndThrowException() { _helper.Expect(c => c.ParseExpression("2/3 ~ 4/5")).Throw(new Exception("Invalid Expression Syntax!")); _model = new ExpressionModel { Expression = "2/3 ~ 4/5" }; var actionResult = _controller.Index(_model) as ViewResult; _helper.VerifyAllExpectations(); Assert.IsNotNull(actionResult); var model = actionResult.Model as ExpressionModel; Assert.IsNotNull(model); Assert.AreEqual("Invalid Expression Syntax!", model.Result); }
public ActionResult Index() { ViewBag.Title = "Home Page"; ExpressionModel model = new ExpressionModel(); return View(model); }