コード例 #1
0
        public void TestAddNumbers(int x, int y, int expectedResult)
        {
            var cs     = new CalcService();
            var result = cs.AddNumbers(x, y);

            Assert.Equal(expectedResult, result);
        }
コード例 #2
0
        public ActionResult Add(CalcViewModel model)
        {
            var cs     = new CalcService();
            var result = cs.AddNumbers(model.Number1, model.Number2);

            model.Result = result;
            return(View("Process", model));
        }
コード例 #3
0
        public void TestAddNumbers(int x, int y, int expectedResult)
        {
            // 1. Arrange
            var cs = new CalcService();

            // 2. Act
            var result = cs.AddNumbers(x, y);

            // 3. Assert
            Assert.Equal(expectedResult, result);
        }
コード例 #4
0
        public ActionResult ProcessWithService(CalcViewModel model)
        {
            bool isSuccess = ExternalService.DoGreatThings();

            if (isSuccess)
            {
                var cs     = new CalcService();
                var result = cs.AddNumbers(model.Number1, model.Number2);
                model.Result = result;
                return(View(model));
            }
            {
                throw new Exception();
            }
        }