public void CalcTest2()
        {
            var requiredCalcModel = new RequiredCalcModel();
            var controller        = new CalcController(calcRepository);

            Assert.Throws <NotValidOperatorExeption>(() => controller.ControllerOperation(requiredCalcModel));
        }
        public void Setup()
        {
            _helper = new SymbolMapHelper();

            _mockRepo       = new Mock <IScoreRepository>();
            _calcController = new CalcController(_mockRepo.Object);
        }
示例#3
0
            public void EqualsRequiredCalcModelTestFour()
            {
                var act        = new RequiredCalcModel(2, 0, '/');
                var controller = new CalcController(calcRepository);

                Assert.Throws <DevideByZeroExeption>(() => controller.ControllerOperation(act));
            }
示例#4
0
            public void EqualsRequiredCalcModelTestThree()
            {
                var act        = new RequiredCalcModel(2, 2, '=');
                var controller = new CalcController(calcRepository);

                Assert.Throws <NotValidOperatorExeption>(() => controller.ControllerOperation(act));
            }
示例#5
0
        public void GetShowMetheCode()
        {
            CalcController controller = new CalcController();
            string         result     = controller.GetShowMetheCode();

            Assert.AreEqual("www.google.com.br", result);
        }
        public void ShowsCorrectIndexView()
        {
            var cc     = new CalcController();
            var result = cc.Index() as ViewResult;

            Assert.Equal("Index", result.ViewName);
        }
 private void Button_Click_Decimal(object sender, RoutedEventArgs e)
 {
     if (!InputBox.Text.Contains("."))
     {
         CalcController.AddTextToInput(".");
     }
 }
        public void TestMethodSub()
        {
            var controller = new CalcController();

            var result = controller.GetSub(1.5, 1.5);

            Assert.AreEqual(0, result.Result);
        }
 private void Button_Click_Exponent(object sender, RoutedEventArgs e)
 {
     if (CalcController.CanPlaceOperator())
     {
         CalcController.AddTextOperatorBox("^", InputBox.Text);
         CalcController.ClearInputBox();
     }
 }
 private void Button_Click_SquareRoot(object sender, RoutedEventArgs e)
 {
     if (CalcController.CanPlaceOperator())
     {
         CalcController.AddTextOperatorBox("", $"√({InputBox.Text})");
         CalcController.ClearInputBox();
     }
 }
示例#11
0
        public void TestMethodMult()
        {
            var controller = new CalcController();

            var result = controller.GetMult(2, 2);

            Assert.AreEqual(4, result.Result);
        }
示例#12
0
        public void TestMethodDiv()
        {
            var controller = new CalcController();

            var result = controller.GetDiv(10, 2);

            Assert.AreEqual(5, result.Result);
        }
 private void Button_Click_Backspace(object sender, RoutedEventArgs e)
 {
     if (InputBox.Text.Length > 0)
     {
         CalcController.OverwriteInput(
             InputBox.Text.Remove(InputBox.Text.Length - 1)
             );
     }
 }
示例#14
0
        public void Setup()
        {
            _calcMock    = new Mock <ICalcService>();
            _sessionMock = new Mock <ISessionService>();
            _mapperMock  = new Mock <IMapper>();
            _controller  = new CalcController(_calcMock.Object, _sessionMock.Object, _mapperMock.Object);

            //HttpContext.Current = MockHelpers.FakeHttpContext();
        }
        public void TestMethodCalculate6()
        {
            //Arrange
            var controller = new CalcController();
            //Act
            var result = controller.Calculate("22,4", "43,3", "Add") as ViewResult;

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("65.7", result.ViewBag.Message);
        }
        public void TestMethodCalculate4()
        {
            //Arrange
            var controller = new CalcController();
            //Act
            var result = controller.Calculate("22 5", "43", "Mul") as ViewResult;

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("Incorrect first parameter", result.ViewBag.Message);
        }
        public void TestMethodCalculate2()
        {
            //Arrange
            var controller = new CalcController();
            //Act
            var result = controller.Calculate("22", "f", "Add") as ViewResult;

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("Incorrect second parameter", result.ViewBag.Message);
        }
        public void TestMethodCalculate5()
        {
            //Arrange
            var controller = new CalcController();
            //Act
            var result = controller.Calculate("25", "5", "Sub") as ViewResult;

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("20", result.ViewBag.Message);
        }
 private void Button_Click_Plus(object sender, RoutedEventArgs e)
 {
     // Take what ever number is in the inputbox
     // place a "+" after it
     // add that stuff to the OperatorBox
     // Clear InputBox
     if (CalcController.CanPlaceOperator())
     {
         CalcController.AddTextOperatorBox("+", InputBox.Text);
         CalcController.ClearInputBox();
     }
 }
 private void Button_Click_Negate(object sender, RoutedEventArgs e)
 {
     // Check if negative exists, if so, remove it, else, add it.
     if (InputBox.Text.Contains("-"))
     {
         InputBox.Text = InputBox.Text.TrimStart('-');
     }
     else
     {
         CalcController.AddTextToInput("-", 0);
     }
 }
示例#21
0
        public void GetCalculaJuros()
        {
            CalcController controller = new CalcController();
            CalcData       _data      = new CalcData();

            _data.initialValue = 100;
            _data.time         = 5;

            string result = controller.GetCalculaJuros(_data);

            Assert.AreEqual("105,10", result);
        }
 private void Button_Click_Factorial(object sender, RoutedEventArgs e)
 {
     // Also factorial max out at 3500... Because anything higher breaks stuff (I.e. that loop down their loops many many many times. Also overflows so)
     if (CalcController.InputBoxIsNotEmpty(InputBox) && int.Parse(InputBox.Text) > 3500)
     {
         CalcController.OverwriteInput("NaN");
     }
     else if (CalcController.CanPlaceOperator())
     {
         CalcController.AddTextOperatorBox("", $"!({InputBox.Text})");
         CalcController.ClearInputBox();
     }
 }
示例#23
0
        public void CalcTest1()
        {
            var requiredCalcModel = new RequiredCalcModel();

            requiredCalcModel.FirstOperand  = 15;
            requiredCalcModel.SecondOperand = 10;
            requiredCalcModel.Operation     = '/';
            calcRepository.Operations(requiredCalcModel);
            var controller = new CalcController(calcRepository);
            var act        = controller.ControllerOperation(requiredCalcModel);

            Assert.IsType <OkObjectResult>(act);
        }
        public void ShowsCorrectProcessView(int x, int y, int expectedResult)
        {
            var cc        = new CalcController();
            var calcModel = new CalcViewModel()
            {
                Number1 = x,
                Number2 = y
            };


            var result = cc.Process(calcModel) as ViewResult;

            Assert.Equal(expectedResult, calcModel.Result);
        }
示例#25
0
        public void DivideTestCase()
        {
            double leftOp   = 2;
            double rightOp  = 2;
            var    testData = new {
                operation = "divide",
                arguments = new List <double> {
                    leftOp, rightOp
                },
                result = leftOp / rightOp
            };
            var controller = new CalcController();
            var result     = controller.GetDiv(leftOp, rightOp);

            Assert.AreEqual(result.ToString(), testData.ToString());
        }
        private void Button_Click_Equals(object sender, RoutedEventArgs e)
        {
            var equation = OperationBox.Text + InputBox.Text;

            var result = CalcController.CalculateResult(equation);

            if (result != null)
            {
                CalcController.OverwriteInput(result);
                CalcController.ClearOperationBox();
            }
            else
            {
                CalcController.ClearAll();
            }
        }
示例#27
0
        public void Soma()
        {
            CalcController.ClickButtonCinco();

            CalcController.ClickButtonNove();

            CalcController.ClickButtonSoma();

            CalcController.ClickButtonDois();

            CalcController.ClickButtonUm();

            CalcController.ClickButtonNove();

            CalcController.ClickButtonIgual();
        }
示例#28
0
        static void Main(string[] args)
        {
            var computations = new List <IComputation>
            {
                new Computation <SimpleModel, DoubleModel>("Арифметические расчёты", typeof(SimpleCalculator), typeof(SimpleView)),
                new Computation <DoubleModel, DoubleModel>("Расчёт квадратного корня", typeof(SquareRootCalculator), typeof(SquareRootView)),
                new Computation <ListModel, ListStatisticModel>("Статистика списка чисел", typeof(ListStatisticCalculator), typeof(ListStatisticView)),
            };

            var  calcController = new CalcController(new CommonView(), computations);
            bool again;

            do
            {
                again = calcController.Run();
            } while (again);
        }
示例#29
0
        public void TestInit()
        {
            context = new Mock <ControllerContext>();
            //context = MockRepository.GenerateMock<ControllerContext>();
            controller = new CalcController();
            controller.ControllerContext = context.Object;

            model = new CalcModel();

            var statemanager = new Mock <SessionStateManager <CalcModel> >();

            statemanager.Setup(l => l.load("model")).Returns(model);
            statemanager.Setup(s => s.save("model", model));

            controller.setStateManager(statemanager.Object);

            controller.Index();
        }
示例#30
0
 public CommonView()
 {
     _calcController = new CalcController(this, Computations);
 }