public void CalculateAndDisplayE_GivenAllNeededVariables(bool advance, double m, double n, double p, double k0, double kn, double expectedE) { // Arrange var mockObjects = MockFactories.GetMockObjects(); var vm = MockFactories.FinCalcViewModelWithCalculatorImplementationFactory(mockObjects); // Since I am sharing the test data with the plain calculation tests I have to manually adjust this value: expectedE *= -1; // Act if (advance) { FinCalcViewModelHelper.ExecuteDummyAction(vm, Ca.ToggleAdv); } FinCalcViewModelHelper.SetFinancialValue(vm, m, CommandWord.SetRatesPerAnnum); FinCalcViewModelHelper.SetFinancialValue(vm, n, CommandWord.SetYears); FinCalcViewModelHelper.SetFinancialValue(vm, p, CommandWord.SetNominalInterestRate); FinCalcViewModelHelper.SetFinancialValue(vm, k0, CommandWord.SetStart); FinCalcViewModelHelper.SetFinancialValue(vm, kn, CommandWord.SetEnd); vm.RatePressedCommand.Execute(false); // Assert vm.DisplayNumber.Should().BeApproximately(expectedE, this.Tolerance); }
public void CalculateAndDisplayN_GivenAllNeededVariables(double m, double p, double k0, double e, double kn, double expectedN) { // Arrange var mockObjects = MockFactories.GetMockObjects(); var vm = MockFactories.FinCalcViewModelWithCalculatorImplementationFactory(mockObjects); // Act FinCalcViewModelHelper.SetFinancialValue(vm, m, CommandWord.SetRatesPerAnnum); FinCalcViewModelHelper.SetFinancialValue(vm, p, CommandWord.SetNominalInterestRate); FinCalcViewModelHelper.SetFinancialValue(vm, k0, CommandWord.SetStart); FinCalcViewModelHelper.SetFinancialValue(vm, e, CommandWord.SetRate); FinCalcViewModelHelper.SetFinancialValue(vm, kn, CommandWord.SetEnd); vm.YearsPressedCommand.Execute(false); // Assert vm.DisplayNumber.Should().BeApproximately(expectedN, this.Tolerance); }
public void ResetInputState_WhenPressedAfterSpecialFunction(Ca[] preOperations, Ca mainOperation, Ca[] postOperations, string expectedOutputTextAfterAllOperations) { // Arrange var mockObjects = MockFactories.GetMockObjects(); var vm = MockFactories.FinCalcViewModelWithCalculatorImplementationFactory(mockObjects); if (preOperations == null) { preOperations = System.Array.Empty <Ca>(); } if (postOperations == null) { postOperations = System.Array.Empty <Ca>(); } // Act FinCalcViewModelHelper.ExecuteDummyActions(vm, preOperations.Concat(new[] { mainOperation }).Concat(postOperations).ToArray()); // Assert vm.DisplayText.Should().Be(expectedOutputTextAfterAllOperations); }
public void ShowExpectedOutputText_WhenBasicArithmeticIsPerformed(string expectedOutputTextAfterAllOperations, double expectedNumberAfterAllOperations, Ca[] actions) => FinCalcViewModelHelper.ExecuteDummyActionsAndCheckOutput(actions, expectedOutputTextAfterAllOperations, expectedNumberAfterAllOperations, this.Tolerance);
public void TriggerPercentCalculation_WhenAllConditionsAreMet(string expectedOutputTextAfterAllOperations, Ca[] actions) => FinCalcViewModelHelper.ExecuteDummyActionsAndCheckOutput(actions, expectedOutputTextAfterAllOperations);