Example #1
0
        public void Run()
        {
            MathematicModel model  = _userInterface.ReadModel();
            int             result = Calculate(model);

            _userInterface.WriteResult(result);
        }
 private int Calculate(MathematicModel model)
 {
     switch (model.Operation)
     {
         case Operations.Add:
             return _mathematics.Add(model.First, model.Second);
         case Operations.Subtract:
             return _mathematics.Subtract(model.First, model.Second);
         default:
             throw new NotSupportedException();
     }
 }
Example #3
0
        private int Calculate(MathematicModel model)
        {
            switch (model.Operation)
            {
            case Operations.Add:
                return(_mathematics.Add(model.First, model.Second));

            case Operations.Subtract:
                return(_mathematics.Subtract(model.First, model.Second));

            default:
                throw new NotSupportedException();
            }
        }
        public void Calculate()
        {
            // Arrange
            HomeController controller = new HomeController();
            var input = new MathematicModel
            {
                First = 5,
                Second = 2
            };

            // Act
            ViewResult result = controller.Calculate(input) as ViewResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOf(typeof(int), result.Model);
        }
Example #5
0
 public ActionResult Calculate(MathematicModel input)
 {
     var ui = new Models.Calculator(_mathematics, input);
     return View(ui.Calculate());
 }