private static (Mock <IMathManager> mock, MathController controller) CreateControllerAndManagerMock() { var mock = new Mock <IMathManager>(); var controller = new MathController(mock.Object); return(mock, controller); }
public void DivideByZeroTest() { var controller = new MathController(new MathDbRepository()); var id = controller.Divide(value1, 0); Assert.AreEqual(id, null); }
void Start() { rigidBody = GetComponent <Rigidbody>(); GameObject mathControllerObject = GameObject.FindWithTag("MathController"); GameObject touchControllerObject = GameObject.FindWithTag("TouchController"); GameObject quizControllerObject = GameObject.FindWithTag("QuizController"); if (mathControllerObject != null) { mathController = mathControllerObject.GetComponent <MathController>(); } if (mathControllerObject == null) { Debug.Log("Cannot find 'MathController' script"); } if (touchControllerObject != null) { touchController = touchControllerObject.GetComponent <TouchController>(); } if (touchControllerObject == null) { Debug.Log("Cannot find 'TouchController' script"); } if (quizControllerObject != null) { quizController = quizControllerObject.GetComponent <QuizController>(); } if (quizControllerObject == null) { Debug.Log("Cannot find 'QuizController' script"); } StartCoroutine(BallCalculating()); }
public void ControllerErrorPayloadTooLargeOrSmall(int itemsToCreate) { // arrange var numbersToCalc = new List <double>(); for (var i = 0; i < itemsToCreate; i++) { numbersToCalc.Add(i + 1); } var mockCalc = new Mock <ICalculation>(); var mockLog = new Mock <ILogger <MathController> >(); var mockMap = new Mock <IMap>(); var mockFactory = new Mock <ICalculationFactory>(); mockFactory.Setup(x => x.Build(It.IsAny <CalculationType>())).Returns(mockCalc.Object); var mathController = new MathController(mockFactory.Object, mockMap.Object, mockLog.Object); // act var result = mathController.Post(new CalculationRequest { CalculationType = CalculationType.Add, Numbers = numbersToCalc }); var objectResult = (ObjectResult)result.Result; // assert objectResult.StatusCode.Should().Be(400); // additional asserts to check text... }
public void InputValueMoreThanOneToDiminishingExponential_NegativeValue_OutputOne() { var inputValue = -999f; var expectedValue = -1f; var mathController = new MathController(); Assert.AreEqual(expectedValue, mathController.DiminishingExponentialFunction(inputValue)); }
public void MultiplyTest() { var controller = new MathController(new MathDbRepository()); var id = controller.Multiply(value1, value2); var result = controller.GetResultById((int)id); Assert.AreEqual(result, 18); }
public void PowTest() { var controller = new MathController(new MathDbRepository()); var id = controller.Pow(value1, value2); var result = controller.GetResultById((int)id); Assert.AreEqual(result, 216); }
public void SubstractTest() { var controller = new MathController(new MathDbRepository()); var id = controller.Substract(value1, value2); var result = controller.GetResultById((int)id); Assert.AreEqual(result, 3); }
public void InputHalfToDiminishingExponential_05Value_OutputLessThan05() { var mathController = new MathController(); var inputValue = 0.5f; var outputValue = mathController.DiminishingExponentialFunction(inputValue); var expectedValue = Mathf.Pow(0.5f, 4); Assert.AreEqual(expectedValue, outputValue); }
public void InputOneToDiminishingExponential_PositiveValue_OutputOne() { var mathController = new MathController(); var inputValue = 1f; var outputValue = mathController.DiminishingExponentialFunction(inputValue); var expectedValue = 1f; Assert.AreEqual(expectedValue, outputValue); }
public void InputZeroToDiminishingExponential_ZeroValue_OutputZero() { var mathController = new MathController(); var inputValue = 0f; var outputValue = mathController.DiminishingExponentialFunction(inputValue); var expectedValue = 0f; Assert.AreEqual(expectedValue, outputValue); }
void Calculate() { if (!FindUnselected()) { timerStop = true; MathController.SetTimer(Math.Round(timer, 0)); int score = MathController.CalculateResult(); MathInsertScore(score); SceneManager.LoadScene("MathResult"); } }
public void MathControllerUIFieldOneContainsSpaces_Pass() { //Arrange MathController controller = new MathController(); string x = " ", y = "5.5"; //Act bool answer = controller.ValidateInput(ref x, ref y); //Assert - expected, actual Assert.AreEqual(false, answer); }
public void MathControllerUIFieldTwoContainLetters_Pass() { //Arrange MathController controller = new MathController(); string x = "543", y = "AAA"; //Act bool answer = controller.ValidateInput(ref x, ref y); //Assert - expected, actual Assert.AreEqual(false, answer); }
public void MathControllerUIFieldTwo_Fail() { //Arrange MathController controller = new MathController(); string x = "3.2", y = ""; //Act bool answer = controller.ValidateInput(ref x, ref y); //Assert - expected, actual Assert.AreEqual(false, answer); }
public void MathControllerUIInputFields() { //Arrange MathController controller = new MathController(); string x = "4.4", y = "9.9"; //Act bool answer = controller.ValidateInput(ref x, ref y); //Assert - expected, actual Assert.AreEqual(true, answer); }
public void Division_14_9_Returns1() { // Arrange MathController controller = new MathController(); int x = 14, y = 9; // Act int result = controller.Divide(x, y); // Assert Assert.Equal(1, result); }
public void Product_9_14_Returns126() { // Arrange MathController controller = new MathController(); int x = 9, y = 14; // Act int result = controller.Multiply(x, y); // Assert Assert.Equal(126, result); }
public void Difference_9_14_ReturnsNegative5() { // Arrange MathController controller = new MathController(); int x = 9, y = 14; // Act int result = controller.Difference(x, y); // Assert Assert.Equal(-5, result); }
public void Sum_9_14_Returns23() { // Arrange MathController controller = new MathController(); int x = 9, y = 14; // Act int result = controller.Sum(x, y); // Assert Assert.Equal(23, result); }
public void Division_126_14_Returns9() { // Arrange MathController controller = new MathController(); int x = 126, y = 14; // Act int result = controller.Divide(x, y); // Assert Assert.Equal(9, result); }
public void ChangeState() { MathController.NewMove(); if (selected) { UnselectButton(); } else { SelectButton(); } GetComponentInParent <BoardController>().ChangeState(i, j); }
public ConceptualPostTransComponent(BuildAssembler assembler, XPathNavigator configuration) : base(assembler, configuration) { try { MathController mathFormatters = MathController.GetInstance("conceptual"); if (mathFormatters != null) { _mathApply = true; _mathNumber = mathFormatters.ShowNumber; _mathNumFormat = mathFormatters.NumberFormat; _mathNumIncludePage = mathFormatters.NumberIncludesPage; _mathSelector = XPathExpression.Compile( "//artLink[starts-with(@target, 'Equation|')]"); if (String.IsNullOrEmpty(_mathNumFormat)) { if (_mathNumIncludePage) { _mathNumFormat = "({0}.{1})"; } else { _mathNumFormat = "({0})"; } } } CodeController codeController = CodeController.GetInstance("conceptual"); if (codeController != null) { _codeApply = true; // This works for Vs2005... _codeSelector = XPathExpression.Compile( "//pre/span[@name='SandAssist' and @class='tgtSentence']"); _spanSelector = XPathExpression.Compile( "span[@name='SandAssist' and @class='tgtSentence']"); } _tokensSelector = XPathExpression.Compile( "//span[@name='SandTokens' and @class='tgtSentence']"); } catch (Exception ex) { this.WriteMessage(MessageLevel.Error, ex); } }
// Helpers private MathController GetMathController(string apiRoute) { var route = new HttpRouteCollection(apiRoute); var controller = new MathController { Request = new HttpRequestMessage(), Configuration = new HttpConfiguration(route) }; controller.Request.Headers.Add("SecretKey", "SecretPassword"); return(controller); }
public void TestFibo() { //Arrange string res = ""; MathController ctrl = new MathController(); ctrl.Request = new HttpRequestMessage(); ctrl.Configuration = new HttpConfiguration(); //Act HttpResponseMessage httpResponseMessage = ctrl.Fibonacci(10); httpResponseMessage.TryGetContentValue <string>(out res); //Assert Assert.AreEqual("55", res); }
private void Start() { currentMoveSpeed = baseThrust; myBody = GetComponent <Rigidbody2D>(); mathController = new MathController(); playerForceControl = new PlayerForceControl(baseThrust); if (MovementService == null) { MovementService = new MovementService(); } }
void Initialize() { MathController.ClearNumberOfMoves(); board = MathController.GetBoard_5x5_2(); for (int i = 0; i < board_rows.Length; i++) { for (int j = 0; j < board_rows[i].cols.Length; j++) { int num = board.numbers[i, j].number; GameObject obj = board_rows[i].cols[j]; ButtonBoxController(obj).SetNumberAndCoordinates(num, i, j); } } SetColumns(board.col_numbers); SetRows(board.row_numbers); }
private string GetResult() { switch (Game) { case Game.Memory: return(MemoryController.GetResult()); case Game.Dexterity: return(DexterityController.GetResult()); case Game.Math: return(MathController.GetResult()); default: return(""); } }
void Start() { originalScale = this.gameObject.transform.localScale; changeScale = new Vector3(originalScale.x, originalScale.y / 2, originalScale.z); GameObject mathControllerObject = GameObject.FindWithTag("MathController"); if (mathControllerObject != null) { mathController = mathControllerObject.GetComponent <MathController>(); } if (mathControllerObject == null) { Debug.Log("Cannot find 'MathController' script"); } normalBall = GameObject.FindGameObjectsWithTag("SorobanBall"); oddBall = GameObject.FindGameObjectsWithTag("SorobanBallOdd"); Reset(); }
public void ControllerUsesMathService() { //Arrange var service = new SpyMathService { Add_Result = 42 }; // The answer to life, the universe, and everything. var controller = new MathController(service); //Now we can pass our fake in! int left = 4; int right = 12; //Act var result = controller.Add(left, right); //Assert Assert.AreEqual(service.Add_Result, result.ViewBag.TotalCount); Assert.AreEqual(service.Add_Left, left); Assert.AreEqual(service.Add_Right, right); }