aboutsummaryrefslogtreecommitdiff
path: root/Oscilloscope
diff options
context:
space:
mode:
Diffstat (limited to 'Oscilloscope')
-rw-r--r--Oscilloscope/Oscilloscope/Wave.cs4
-rw-r--r--Oscilloscope/OscilloscopeTests/WaveTests.cs24
2 files changed, 25 insertions, 3 deletions
diff --git a/Oscilloscope/Oscilloscope/Wave.cs b/Oscilloscope/Oscilloscope/Wave.cs
index 6ca5b6f..1f5e915 100644
--- a/Oscilloscope/Oscilloscope/Wave.cs
+++ b/Oscilloscope/Oscilloscope/Wave.cs
@@ -41,8 +41,8 @@ namespace Oscilloscope
public string Name {
get { return this.name; }
set {
- if (name == "") {
- throw new ArgumentException("Name cannot be emty string!");
+ if (value == "") {
+ throw new ArgumentException("Name cannot be empty string!");
}
name = value;
diff --git a/Oscilloscope/OscilloscopeTests/WaveTests.cs b/Oscilloscope/OscilloscopeTests/WaveTests.cs
index aae4f17..f75634d 100644
--- a/Oscilloscope/OscilloscopeTests/WaveTests.cs
+++ b/Oscilloscope/OscilloscopeTests/WaveTests.cs
@@ -7,6 +7,28 @@ using System.Collections.Generic;
namespace OscilloscopeTests {
[TestFixture]
public class WaveTests {
-
+
+ [Test]
+ public static void InitialisationOverloadsNameCreaton() {
+ Wave wave1 = new Wave();
+ Wave wave2 = new Wave("My wave");
+
+ Assert.AreEqual("Wave1", wave1.Name, "Automatic wave name isn't working properly.");
+ Assert.AreEqual("My wave", wave2.Name, "Custom wave name from overload doesn't work correctly.");
+
+ var testException = Assert.Throws<ArgumentException>(() => new Wave(""));
+ Assert.AreEqual("Name cannot be empty string!", testException.Message, "There is no eception if you input an empty string as a name");
+ }
+
+ [Test]
+ public static void InitialisationWithAListOfValues() {
+ var testValues = new List<int>() { int.MinValue, int.MinValue + 1, 0, int.MaxValue - 1, int.MaxValue };
+ Wave testWave = new Wave(new List<int>() { int.MinValue, int.MinValue + 1, 0, int.MaxValue - 1, int.MaxValue});
+
+ for (int i = 0; i < 5; i++) {
+ Assert.AreEqual(testValues[i], testWave.GetValue(), $"Wave doesn't return right value (failed on value No {i})");
+ }
+ Assert.AreEqual(testValues[0], testWave.GetValue(), "Wave doesn't reset return index variable correctly.");
+ }
}
}