From 346fc72d5e9e8af4e488e9db13368cee01c14a56 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Sat, 23 Apr 2022 12:37:49 +0100 Subject: [PATCH] Move text-based char extensions to Text namespace (#7) --- X10D.Tests/src/Core/CharTests.cs | 23 ------------ X10D.Tests/src/Text/CharTests.cs | 37 +++++++++++++++++++ .../CharExtensions.cs | 2 +- 3 files changed, 38 insertions(+), 24 deletions(-) delete mode 100644 X10D.Tests/src/Core/CharTests.cs create mode 100644 X10D.Tests/src/Text/CharTests.cs rename X10D/src/{CharExtensions => Text}/CharExtensions.cs (97%) diff --git a/X10D.Tests/src/Core/CharTests.cs b/X10D.Tests/src/Core/CharTests.cs deleted file mode 100644 index 45ef057..0000000 --- a/X10D.Tests/src/Core/CharTests.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace X10D.Tests.Core; - -/// -/// Tests for . -/// -[TestClass] -public class CharTests -{ - [TestMethod] - public void Repeat() - { - const char character = 'a'; - const int repeatCount = 10; - - const string repeated = "aaaaaaaaaa"; - string result = character.Repeat(repeatCount); - - Assert.AreEqual(repeated, result); - Assert.ThrowsException(() => character.Repeat(-1)); - } -} \ No newline at end of file diff --git a/X10D.Tests/src/Text/CharTests.cs b/X10D.Tests/src/Text/CharTests.cs new file mode 100644 index 0000000..cea0606 --- /dev/null +++ b/X10D.Tests/src/Text/CharTests.cs @@ -0,0 +1,37 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using X10D.Text; + +namespace X10D.Tests.Text; + +[TestClass] +public class CharTests +{ + [TestMethod] + public void RepeatShouldBeCorrect() + { + const string expected = "aaaaaaaaaa"; + string actual = 'a'.Repeat(10); + + Assert.AreEqual(expected, actual); + } + + [TestMethod] + public void RepeatOneCountShouldBeLength1String() + { + string repeated = 'a'.Repeat(1); + Assert.AreEqual(1, repeated.Length); + Assert.AreEqual("a", repeated); + } + + [TestMethod] + public void RepeatZeroCountShouldBeEmpty() + { + Assert.AreEqual(string.Empty, 'a'.Repeat(0)); + } + + [TestMethod] + public void RepeatNegativeCountShouldThrow() + { + Assert.ThrowsException(() => 'a'.Repeat(-1)); + } +} diff --git a/X10D/src/CharExtensions/CharExtensions.cs b/X10D/src/Text/CharExtensions.cs similarity index 97% rename from X10D/src/CharExtensions/CharExtensions.cs rename to X10D/src/Text/CharExtensions.cs index bd3e663..3c2b23f 100644 --- a/X10D/src/CharExtensions/CharExtensions.cs +++ b/X10D/src/Text/CharExtensions.cs @@ -1,4 +1,4 @@ -namespace X10D; +namespace X10D.Text; /// /// Extension methods for .