public string TestClearLastSymbol(string displayValue) { //Arrange var displayNumber = DisplayNumberFactory.Create(displayValue); //Act displayNumber.ClearLastSymbol(); //Assert return(displayNumber.ToString()); }
public void TestCreate(bool isNegative, string integerPart, bool hasComma, string fractionalPart, string exponent, string displayValue) { //Act var displayNumber = DisplayNumberFactory.Create(displayValue); //Assert Assert.That(displayNumber.IsNegative, Is.EqualTo(isNegative)); Assert.That(displayNumber.IntegerPart, Is.EqualTo(integerPart)); Assert.That(displayNumber.HasComma, Is.EqualTo(hasComma)); Assert.That(displayNumber.FractionalPart, Is.EqualTo(fractionalPart)); Assert.That(displayNumber.Exponent, Is.EqualTo(exponent)); }
public void Cancel_WhenCancel_ThenDisplayValueIsZero() { //Arrange var displayNumber = DisplayNumberFactory.Create("123"); var calculatorState = new CalculatorState.Builder().DisplayNumber(displayNumber) .Build(); var calculator = new Calculator(calculatorState); //Act calculator.Cancel(); //Assert Assert.That(calculator.DisplayValue, Is.EqualTo("0")); }
public void Clear_WhenAnyDisplayValue_ThenDisplayValueWillBeReset(string displayValue) { //Arrange var displayNumber = DisplayNumberFactory.Create(displayValue); var calculatorState = new CalculatorState.Builder().DisplayNumber(displayNumber) .Build(); var calculator = new Calculator(calculatorState); //Act calculator.Clear(); //Assert Assert.That(calculator.DisplayValue, Is.EqualTo("0")); }
public string TestClearLastSymbol(string displayValue, bool isLastActionAnBinaryOperation) { //Arrange var displayNumber = DisplayNumberFactory.Create(displayValue); var calculatorState = new CalculatorState.Builder().DisplayNumber(displayNumber) .IsLastActionAnBinaryOperation(isLastActionAnBinaryOperation) .Build(); var calculator = new Calculator(calculatorState); //Act calculator.ClearLastSymbol(); //Assert return(calculator.DisplayValue); }
public void ApplyDivision_WhenWasNotAnyOperationBefore_ThenDisplayValueWillNotBeChanged(double previousValue, string displayValue) { //Arrange var displayNumber = DisplayNumberFactory.Create(displayValue); var calculatorState = new CalculatorState.Builder().PreviousValue(previousValue) .DisplayNumber(displayNumber) .Build(); var calculator = new Calculator(calculatorState); var initialDisplayValue = calculator.DisplayValue; //Act calculator.ApplyDivision(); //Assert Assert.That(calculator.DisplayValue, Is.EqualTo(initialDisplayValue)); }
public string TestApplyZero(double previousValue, string displayValue, bool isLastActionAnBinaryOperation) { //Arrange var displayNumber = DisplayNumberFactory.Create(displayValue); var calculatorState = new CalculatorState.Builder().PreviousValue(previousValue) .DisplayNumber(displayNumber) .IsLastActionAnBinaryOperation(isLastActionAnBinaryOperation) .Build(); var calculator = new Calculator(calculatorState); //Act calculator.ApplyZero(); //Assert return(calculator.DisplayValue); }
public void Cancel_WhenAnyNumberAndOperationWereAppliedAndThenApplyEquality_ThenDisplayValueIsZero() { //Arrange var displayNumber = DisplayNumberFactory.Create("123"); var calculatorState = new CalculatorState.Builder().PreviousValue(456) .DisplayNumber(displayNumber) .Build(); var calculator = new Calculator(calculatorState); //Act calculator.Cancel(); calculator.ApplyEquality(); //Assert Assert.That(calculator.DisplayValue, Is.EqualTo("0")); }