summaryrefslogtreecommitdiff
path: root/dsa/NUnitTestProject1/Auxiliary/Calculator
diff options
context:
space:
mode:
Diffstat (limited to 'dsa/NUnitTestProject1/Auxiliary/Calculator')
-rw-r--r--dsa/NUnitTestProject1/Auxiliary/Calculator/ArgumentTests.cs39
-rw-r--r--dsa/NUnitTestProject1/Auxiliary/Calculator/StringSolverTests.cs79
2 files changed, 47 insertions, 71 deletions
diff --git a/dsa/NUnitTestProject1/Auxiliary/Calculator/ArgumentTests.cs b/dsa/NUnitTestProject1/Auxiliary/Calculator/ArgumentTests.cs
index 3e8dbeb..cf2c1b4 100644
--- a/dsa/NUnitTestProject1/Auxiliary/Calculator/ArgumentTests.cs
+++ b/dsa/NUnitTestProject1/Auxiliary/Calculator/ArgumentTests.cs
@@ -2,39 +2,29 @@ using DSALib.Auxiliary.Calculator;
using Moq;
using NUnit.Framework;
-namespace NUnitTest.Auxiliary.Calculator
-{
+namespace NUnitTest.Auxiliary.Calculator {
[TestFixture]
- public class ArgumentTests
- {
- private MockRepository mockRepository;
-
-
-
+ public class ArgumentTests {
[SetUp]
- public void SetUp()
- {
- this.mockRepository = new MockRepository(MockBehavior.Strict);
-
-
+ public void SetUp() {
+ mockRepository = new MockRepository(MockBehavior.Strict);
}
[TearDown]
- public void TearDown()
- {
- this.mockRepository.VerifyAll();
+ public void TearDown() {
+ mockRepository.VerifyAll();
}
- private Argument CreateArgument()
- {
+ private MockRepository mockRepository;
+
+ private Argument CreateArgument() {
return new Argument("3");
}
[Test]
- public void Solve_StateUnderTest_ExpectedBehavior()
- {
+ public void Solve_StateUnderTest_ExpectedBehavior() {
// Arrange
- var unitUnderTest = this.CreateArgument();
+ var unitUnderTest = CreateArgument();
// Act
var result = unitUnderTest.Solve();
@@ -44,10 +34,9 @@ namespace NUnitTest.Auxiliary.Calculator
}
[Test]
- public void ToString_StateUnderTest_ExpectedBehavior()
- {
+ public void ToString_StateUnderTest_ExpectedBehavior() {
// Arrange
- var unitUnderTest = this.CreateArgument();
+ var unitUnderTest = CreateArgument();
// Act
var result = unitUnderTest.ToString();
@@ -56,4 +45,4 @@ namespace NUnitTest.Auxiliary.Calculator
Assert.AreEqual("3", result);
}
}
-}
+} \ No newline at end of file
diff --git a/dsa/NUnitTestProject1/Auxiliary/Calculator/StringSolverTests.cs b/dsa/NUnitTestProject1/Auxiliary/Calculator/StringSolverTests.cs
index 998a78b..877d871 100644
--- a/dsa/NUnitTestProject1/Auxiliary/Calculator/StringSolverTests.cs
+++ b/dsa/NUnitTestProject1/Auxiliary/Calculator/StringSolverTests.cs
@@ -1,99 +1,86 @@
+using System;
using DSALib.Auxiliary.Calculator;
using Moq;
using NUnit.Framework;
-namespace NUnitTest.Auxiliary.Calculator
-{
+namespace NUnitTest.Auxiliary.Calculator {
[TestFixture]
- public class StringSolverTests
- {
- private MockRepository mockRepository;
-
-
-
+ public class StringSolverTests {
[SetUp]
- public void SetUp()
- {
- this.mockRepository = new MockRepository(MockBehavior.Strict);
-
-
+ public void SetUp() {
+ mockRepository = new MockRepository(MockBehavior.Strict);
}
[TearDown]
- public void TearDown()
- {
- this.mockRepository.VerifyAll();
+ public void TearDown() {
+ mockRepository.VerifyAll();
}
- private StringSolver CreateStringSolver(string input)
- {
+ private MockRepository mockRepository;
+
+ private StringSolver CreateStringSolver(string input) {
return new StringSolver(input);
}
[Test]
- public void Solve_StateUnderTest_ExpectedBehavior()
- {
+ public void Solve_braces() {
// Arrange
- var unitUnderTest = this.CreateStringSolver("1+1");
+ var unitUnderTest = CreateStringSolver("1+(1-4)*6+2");
// Act
var result = unitUnderTest.Solve();
// Assert
- Assert.AreEqual(2,result);
+ Assert.AreEqual(-15, result);
}
[Test]
- public void Solve_mult()
- {
+ [MaxTime(200)]
+ public void Solve_braces_timeout() {
// Arrange
- var unitUnderTest = this.CreateStringSolver("1+1-4*6+2");
+ var unitUnderTest = CreateStringSolver("1+(1-(4)*6+2");
// Act
- var result = unitUnderTest.Solve();
-
- // Assert
- Assert.AreEqual(-20, result);
+ Assert.Throws<ArgumentException>(() => unitUnderTest.Solve(), "Invalid brace sequence");
}
[Test]
- public void Solve_braces()
- {
+ public void Solve_mult() {
// Arrange
- var unitUnderTest = this.CreateStringSolver("1+(1-4)*6+2");
+ var unitUnderTest = CreateStringSolver("1+1-4*6+2");
// Act
var result = unitUnderTest.Solve();
// Assert
- Assert.AreEqual(-15, result);
+ Assert.AreEqual(-20, result);
}
[Test]
- public void Solve_wrong_braces()
- {
+ public void Solve_StateUnderTest_ExpectedBehavior() {
// Arrange
- var unitUnderTest = this.CreateStringSolver("1+)(1-4)*6+2");
+ var unitUnderTest = CreateStringSolver("1+1");
// Act
- Assert.Throws<System.ArgumentException>(() =>unitUnderTest.Solve(), "Invalid brace sequence");
+ var result = unitUnderTest.Solve();
+
+ // Assert
+ Assert.AreEqual(2, result);
}
- [Test, MaxTime(200)]
- public void Solve_braces_timeout()
- {
+ [Test]
+ public void Solve_wrong_braces() {
// Arrange
- var unitUnderTest = this.CreateStringSolver("1+(1-(4)*6+2");
+ var unitUnderTest = CreateStringSolver("1+)(1-4)*6+2");
// Act
- Assert.Throws<System.ArgumentException>(() => unitUnderTest.Solve(), "Invalid brace sequence");
+ Assert.Throws<ArgumentException>(() => unitUnderTest.Solve(), "Invalid brace sequence");
}
[Test]
- public void ToString_StateUnderTest_ExpectedBehavior()
- {
+ public void ToString_StateUnderTest_ExpectedBehavior() {
// Arrange
- var unitUnderTest = this.CreateStringSolver("3+-4");
+ var unitUnderTest = CreateStringSolver("3+-4");
// Act
var result = unitUnderTest.ToString();
@@ -102,4 +89,4 @@ namespace NUnitTest.Auxiliary.Calculator
Assert.AreEqual("(0+3+-4)", result);
}
}
-}
+} \ No newline at end of file