1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-23 01:28:48 +00:00

Move text-based char extensions to Text namespace (#7)

This commit is contained in:
Oliver Booth 2022-04-23 12:37:49 +01:00
parent 76191cb43a
commit 346fc72d5e
No known key found for this signature in database
GPG Key ID: 32A00B35503AF634
3 changed files with 38 additions and 24 deletions

View File

@ -1,23 +0,0 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace X10D.Tests.Core;
/// <summary>
/// Tests for <see cref="CharExtensions" />.
/// </summary>
[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<ArgumentOutOfRangeException>(() => character.Repeat(-1));
}
}

View File

@ -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<ArgumentOutOfRangeException>(() => 'a'.Repeat(-1));
}
}

View File

@ -1,4 +1,4 @@
namespace X10D;
namespace X10D.Text;
/// <summary>
/// Extension methods for <see cref="char" />.