public void StackProductTest() { stack.Push(10); stack.Push(87); Assert.AreEqual(870, Calculator1.Product()); }
public void StackQuotientTest() { stack.Push(2); stack.Push(1024); Assert.AreEqual(512, Calculator1.Quotient()); }
public void StackSumTest() { stack.Push(15); stack.Push(25); Assert.AreEqual(40, Calculator1.Sum()); }
public void StackDifferenceTest() { stack.Push(8); stack.Push(78); Assert.AreEqual(70, Calculator1.Difference()); }
public static bool CopyandInitStockCalculator(Calculator1 calc, ME2Stock newStock) { bool bHasCopy = false; if (calc != null) { if (calc.GetType().Equals(newStock.GetType())) { ME2Stock oldStock = (ME2Stock)calc; if (oldStock != null) { //initiate analyzer objects newStock.InitTotalME2StocksProperties(); //but keep calc props newStock.CopyCalculatorProperties(oldStock); if (oldStock.CalcParameters != null) { newStock.CalcParameters = new CalculatorParameters(oldStock.CalcParameters); } bHasCopy = true; } } } return(bHasCopy); }
public void Calculator1CallIDoubleAverange_ComputeAverangeMethod() { var doubleAverangeComputerMock = new Mock <IDoubleAverangeComputer>(); var calculator1 = new Calculator1(); calculator1.CalculateAverage(_values, doubleAverangeComputerMock.Object); doubleAverangeComputerMock.Verify(computer => computer.ComputeAverange(It.Is <IList <double> >(list => list.SequenceEqual(_values))), Times.Once); }
static void Main(string[] args) { Calculator1 calc = new Calculator1(); calc.add(20, 30); calc.difference(30, 20); calc.division(15, 3); calc.multiplication(2, 2); }
public void Subtract_Test() { var calculator = new Calculator1(); Assert.AreEqual(0, calculator.Subtract(1.5, 1.5)); Assert.AreEqual(1000, calculator.Subtract(1500.25, 500.25)); Assert.AreEqual(20, calculator.Subtract(10, -10)); Assert.AreEqual(-1, calculator.Subtract(0, 1)); }
public void AddNumbers() { var number1 = RandomValue.Int(999); var number2 = RandomValue.Int(999); var sum = Calculator1.Add1(number1, number2); sum.Should().Be(number1 + number2); }
public void Divide_Test() { var calculator = new Calculator1(); Assert.AreEqual(1, calculator.Divide(1.5, 1.5)); Assert.AreEqual(5, calculator.Divide(5, 1)); Assert.AreEqual(-1, calculator.Divide(10, -10)); Assert.AreEqual(10, calculator.Divide(-50, -5)); }
public void Multiply_Test() { var calculator = new Calculator1(); Assert.AreEqual(2.25, calculator.Multiply(1.5, 1.5)); Assert.AreEqual(25, calculator.Multiply(5, 5)); Assert.AreEqual(-100, calculator.Multiply(10, -10)); Assert.AreEqual(0, calculator.Multiply(0, 1)); }
public void Square_Test() { var calculator = new Calculator1(); Assert.AreEqual(4, calculator.Square(-2)); Assert.AreEqual(25, calculator.Square(5)); Assert.AreEqual(110.25, calculator.Square(10.5)); Assert.AreEqual(10000, calculator.Square(100)); }
public void Add_Test() { var calculator = new Calculator1(); Assert.AreEqual(3, calculator.Add(1.5, 1.5)); Assert.AreEqual(1000, calculator.Add(150.25, 849.75)); Assert.AreEqual(0, calculator.Add(10, -10)); Assert.AreEqual(1, calculator.Add(0, 1)); }
public void Cosine_Test() { var calculator = new Calculator1(); Assert.AreEqual(0, calculator.Cosine((Math.PI) / 2.0)); Assert.AreEqual(0, calculator.Cosine((3.0 * Math.PI) / 2.0)); Assert.AreEqual(1, calculator.Cosine(0)); Assert.AreEqual(0.5, calculator.Cosine(Math.PI / 3.0)); Assert.AreEqual(-1, calculator.Cosine(Math.PI)); }
private void SetIds(Calculator1 baseElement, ME2Stock stock) { SetCalculatorId(baseElement, stock); //alt2 is stored with the base element for some elements (ocs and outcomes, tps) if (baseElement.Alternative2 != 0) { //the CalculatorId is used to set the Id (Id is the base element_ stock.Alternative2 = baseElement.Alternative2; } }
public void ValidateInput_Function_Test() { var calculator = new Calculator1(); Assert.AreEqual(-1, calculator.ValidateInput_Function("three")); Assert.AreEqual(-1, calculator.ValidateInput_Function("87654")); Assert.AreEqual(11, calculator.ValidateInput_Function("11")); Assert.AreEqual(-1, calculator.ValidateInput_Function("0")); Assert.AreEqual(-1, calculator.ValidateInput_Function("1.5")); }
public void SquareRoot_Test() { var calculator = new Calculator1(); Assert.AreEqual(5, calculator.Square_Root(25)); Assert.AreEqual(10.5, calculator.Square_Root(110.25)); Assert.AreEqual(4.25, calculator.Square_Root(18.0625)); Assert.AreEqual(1, calculator.Square_Root(1)); Assert.AreEqual(0, calculator.Square_Root(0)); }
public void Cube_Test() { var calculator = new Calculator1(); Assert.AreEqual(-125, calculator.Cube(-5)); Assert.AreEqual(1000, calculator.Cube(10)); Assert.AreEqual(3.375, calculator.Cube(1.5)); Assert.AreEqual(1, calculator.Cube(1)); Assert.AreEqual(0, calculator.Cube(0)); }
public void CubeRoot_Test() { var calculator = new Calculator1(); Assert.AreEqual(5, calculator.Cube_Root(125)); Assert.AreEqual(-1, calculator.Cube_Root(-1)); Assert.AreEqual(4.25, calculator.Cube_Root(76.765625)); Assert.AreEqual(1, calculator.Cube_Root(1)); Assert.AreEqual(0, calculator.Cube_Root(0)); }
public void Test_AverageByMedian1() { var calculator = new Calculator1(); var computer = new DoubleAverangeComputer2(); double expected = 8.0; double actual = calculator.CalculateAverage(_values, computer); Assert.AreEqual(expected, actual, 0.000001); }
private void SetCalculatorId(Calculator1 baseElement, ME2Stock stock) { //the initial collections don't store initial stock calculators //related calculator.Id are stored with the base element if (baseElement.CalculatorId != 0) { //the CalculatorId is used to set the Id (Id is the base element_ stock.CalculatorId = baseElement.CalculatorId; stock.Id = baseElement.CalculatorId; } }
static void TestOneArgs() { Console.WriteLine("Testing 1 args..."); if (Calculator1.Add("1") == "1") { Console.WriteLine("OK!"); } else { Console.WriteLine("NOT OK!"); } }
static void TestLongDelims() { Console.WriteLine("Testing long delimiters..."); if (Calculator1.Add("//[***]\n1***2***3") == "6") { Console.WriteLine("OK!"); } else { Console.WriteLine("NOT OK!"); } }
static void TestUnknownArgs() { Console.WriteLine("Testing unknown args..."); if (Calculator1.Add("2,2,3") == "7") { Console.WriteLine("OK!"); } else { Console.WriteLine("NOT OK!"); } }
static void TestTwoArgs() { Console.WriteLine("Testing 2 args..."); if (Calculator1.Add("2,2") == "4") { Console.WriteLine("OK!"); } else { Console.WriteLine("NOT OK!"); } }
static void TestNewLineDelim() { Console.WriteLine("Testing '\\n' as delimiter..."); if (Calculator1.Add("1,2\n3") == "6") { Console.WriteLine("OK!"); } else { Console.WriteLine("NOT OK!"); } }
static void TestUserDelim() { Console.WriteLine("Testing user delimiter..."); if (Calculator1.Add("//;\n1;2") == "3") { Console.WriteLine("OK!"); } else { Console.WriteLine("NOT OK!"); } }
static void TestNegatives() { Console.WriteLine("Testing negatives..."); if (Calculator1.Add("//;\n-1;2;-3;4;-5;6") == "3") { Console.WriteLine("OK!"); } else { Console.WriteLine("NOT OK!"); } }
static void TestBigNumbers() { Console.WriteLine("Testing big numbers..."); if (Calculator1.Add("//;\n1001;2") == "2") { Console.WriteLine("OK!"); } else { Console.WriteLine("NOT OK!"); } }
static void TestMultDelims() { Console.WriteLine("Testing multiple delimiters..."); if (Calculator1.Add("//[**][%%%]\n1**2%%%3") == "6") { Console.WriteLine("OK!"); } else { Console.WriteLine("NOT OK!"); } }