/* Przekazuje dzialanie do obliczenia */ public void ExecuteCalculations() { string tempTODELETE = CurrentEquationState; if (NumberBaseSystem.Decimal != CurrentNumberBaseSystem) { string[] parsedEquation = CurrentEquationState.ParseEquation(); AnalyzeParsedEquation(parsedEquation); } ONP myONP = new ONP(CurrentEquationState); CurrentEquationState = myONP.ONPCalculationResult(); /* W przypadku bledu we wprowadzonym dzialaniu wyslij eventa (GUI go odbiera i wyswietla) */ if (CurrentEquationState == "ERROR") { ErrorOccurred(this, new MyEventArgs("Blad we wprowadzonym dzialaniu!")); CurrentEquationState = "0"; } else { CutDecimalPortion(); // ewentualne skrocenie liczby gdyby byla za duza dla danego rozmiaru slowa TrimOutcomeNumber(); ChangeNumberBaseSystem(CurrentEquationState, NumberBaseSystem.Decimal, CurrentNumberBaseSystem); } ChangeWordButton(this, new MyEventArgs("true")); UpdateDisplay(this, eUpdateArgs); }
public void TestEquation1() { string equation = " 2 + 3 * 6 - 8 / 4 "; ONP OnpMock = new ONP(equation); Decimal expected = new Decimal(18); Assert.AreEqual(expected, Decimal.Parse(OnpMock.ONPCalculationResult())); }
public void TestEquationNawiasPotega() { string equation = " ( 2 + 2 ) ^ 2 "; ONP OnpMock = new ONP(equation); Decimal expected = new Decimal(16); Assert.AreEqual(expected, Decimal.Parse(OnpMock.ONPCalculationResult())); }
public void TestEquationDzielenie() { string equation = " 8 / 2 "; ONP OnpMock = new ONP(equation); Decimal expected = new Decimal(4); Assert.AreEqual(expected, Decimal.Parse(OnpMock.ONPCalculationResult())); }
public void TestEquation3() { string equation = " ( 8 + 8 ) * (2 + 2) * 6 - 6 / 2 ^ 2 "; ONP OnpMock = new ONP(equation); Decimal expected = new Decimal(382.5); Assert.AreEqual(expected, Decimal.Parse(OnpMock.ONPCalculationResult())); }
public void TestEquation2() { string equation = " ( 8 + 9 ) / (2 + 2) * (2 + 3) * 6 - 8 / 4 "; ONP OnpMock = new ONP(equation); Decimal expected = new Decimal(125.5); Assert.AreEqual(expected, Decimal.Parse(OnpMock.ONPCalculationResult())); }
public void TestModuloAlone() { string equation = " 2 % 8 "; ONP OnpMock = new ONP(equation); Decimal expected = new Decimal(2); string onpResult = OnpMock.ONPCalculationResult(); Assert.AreEqual(expected, Decimal.Parse(onpResult)); }
public void TestModuloAlone2() { Console.WriteLine("2 mod 2 = " + 2 % 2 + " expected = 1"); string equation = " 2 % 2 "; ONP OnpMock = new ONP(equation); Decimal expected = new Decimal(0); string onpResult = OnpMock.ONPCalculationResult(); Assert.AreEqual(expected, Decimal.Parse(onpResult)); }