mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-23 00:58:48 +00:00
Move text-based char extensions to Text namespace (#7)
This commit is contained in:
parent
76191cb43a
commit
346fc72d5e
@ -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));
|
|
||||||
}
|
|
||||||
}
|
|
37
X10D.Tests/src/Text/CharTests.cs
Normal file
37
X10D.Tests/src/Text/CharTests.cs
Normal 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));
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
namespace X10D;
|
namespace X10D.Text;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Extension methods for <see cref="char" />.
|
/// Extension methods for <see cref="char" />.
|
Loading…
Reference in New Issue
Block a user