public void IgnoreValuesGreaterThan1000ReturnsSum() { //Arrange Calculator calc = new Calculator(); string input = "10,20,\n30,1000,1001"; //Act double answer = calc.Sum(input); //Assert Assert.AreEqual(1060.0, answer, 0.0001); }
public void DivideNumbersReturnSum() { //Arrange Calculator calc = new Calculator(); //Act double sum = calc.Div(10.0, 2.0); //Assert Assert.AreEqual(5.0, sum, 0.01); }
public void EmptyStringReturnsSumZero() { //Arrange Calculator calc = new Calculator(); string input = ""; //Act double answer = calc.Sum(input); //Assert Assert.AreEqual(0.0, answer,0.0001); }
public void AddArrayOfNumbersReturnSum() { //Arrange Calculator calc = new Calculator(); double[] numbers = new double[5] { 1, 2, 3, 4, 5 }; //Act double sum = calc.Add(numbers); //Assert Assert.AreEqual(15.0, sum, 0.01); }
public void AddNumbersReturnSum() { //Arrange Calculator calc = new Calculator(); //Act double sum = calc.Add(10.0, 10.0); //Assert Assert.AreEqual(20.0, sum, 0.01); //3:e parameter är Deltavärde då man inte kan jämföra för exakt lika med noll med flyttal. }
public void NegativeNumbersCastsException() { //Arrange Calculator calc = new Calculator(); string input = "10\n-20,30"; //Act double answer = calc.Sum(input); }
public void MultiplyNumbersReturnSum() { //Arrange Calculator calc = new Calculator(); //Act double sum = calc.Mul(10.0, 10.0); //Assert Assert.AreEqual(100.0, sum, 0.01); }
public void TwoValuesWithNewLineStringReturnsSum() { //Arrange Calculator calc = new Calculator(); string input = "10\n20"; //Act double answer = calc.Sum(input); //Assert Assert.AreEqual(30.0, answer, 0.0001); }
public void TryDivideByZeroCastsException() { //Arrange Calculator calc = new Calculator(); //Act double sum = calc.Div(10.0, 0.0); }
public void TestNumIsPositiveReturnsTrue() { //Arrange Calculator calc = new Calculator(); //Act bool answer = calc.IsPositive(0.0); //Assert Assert.AreEqual(true, answer); }
public void TestNumIsNegativeReturnsFalse() { //Arrange Calculator calc = new Calculator(); //Act bool answer = calc.IsPositive(-1.0); //Assert Assert.AreEqual(false, answer); }
public void SingleValueStringReturnsValue() { //Arrange Calculator calc = new Calculator(); string input = "10"; //Act double answer = calc.Sum(input); //Assert Assert.AreEqual(10.0, answer, 0.0001); }