added ModerationParser Tests
This commit is contained in:
parent
4b0fe65776
commit
2d61ae9ae3
2 changed files with 123 additions and 1 deletions
|
@ -13,7 +13,8 @@ namespace BirdsiteLive.Domain.Tools
|
|||
|
||||
var splitEntries = entry
|
||||
.Split(new[] {separationChar}, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(x => x.ToLowerInvariant());
|
||||
.Where(x => !string.IsNullOrWhiteSpace(x))
|
||||
.Select(x => x.ToLowerInvariant().Trim());
|
||||
return splitEntries.ToArray();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
using System.Linq;
|
||||
using BirdsiteLive.Domain.Tools;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace BirdsiteLive.Domain.Tests.Tools
|
||||
{
|
||||
[TestClass]
|
||||
public class ModerationParserTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void Parse_Simple_Test()
|
||||
{
|
||||
#region Stubs
|
||||
var entry = "test";
|
||||
#endregion
|
||||
|
||||
var result = ModerationParser.Parse(entry);
|
||||
|
||||
#region Validations
|
||||
Assert.AreEqual(1, result.Length);
|
||||
Assert.AreEqual("test", result.First());
|
||||
#endregion
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Parse_PipeSeparator_Test()
|
||||
{
|
||||
#region Stubs
|
||||
var entry = "test|test2";
|
||||
#endregion
|
||||
|
||||
var result = ModerationParser.Parse(entry);
|
||||
|
||||
#region Validations
|
||||
Assert.AreEqual(2, result.Length);
|
||||
Assert.AreEqual("test", result[0]);
|
||||
Assert.AreEqual("test2", result[1]);
|
||||
#endregion
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Parse_SemicolonSeparator_Test()
|
||||
{
|
||||
#region Stubs
|
||||
var entry = "test;test2";
|
||||
#endregion
|
||||
|
||||
var result = ModerationParser.Parse(entry);
|
||||
|
||||
#region Validations
|
||||
Assert.AreEqual(2, result.Length);
|
||||
Assert.AreEqual("test", result[0]);
|
||||
Assert.AreEqual("test2", result[1]);
|
||||
#endregion
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Parse_CommaSeparator_Test()
|
||||
{
|
||||
#region Stubs
|
||||
var entry = "test,test2";
|
||||
#endregion
|
||||
|
||||
var result = ModerationParser.Parse(entry);
|
||||
|
||||
#region Validations
|
||||
Assert.AreEqual(2, result.Length);
|
||||
Assert.AreEqual("test", result[0]);
|
||||
Assert.AreEqual("test2", result[1]);
|
||||
#endregion
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Parse_SemicolonSeparator_EmptyEntry_Test()
|
||||
{
|
||||
#region Stubs
|
||||
var entry = "test;test2;";
|
||||
#endregion
|
||||
|
||||
var result = ModerationParser.Parse(entry);
|
||||
|
||||
#region Validations
|
||||
Assert.AreEqual(2, result.Length);
|
||||
Assert.AreEqual("test", result[0]);
|
||||
Assert.AreEqual("test2", result[1]);
|
||||
#endregion
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Parse_SemicolonSeparator_WhiteSpace_Test()
|
||||
{
|
||||
#region Stubs
|
||||
var entry = "test; test2";
|
||||
#endregion
|
||||
|
||||
var result = ModerationParser.Parse(entry);
|
||||
|
||||
#region Validations
|
||||
Assert.AreEqual(2, result.Length);
|
||||
Assert.AreEqual("test", result[0]);
|
||||
Assert.AreEqual("test2", result[1]);
|
||||
#endregion
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Parse_SemicolonSeparator_EmptyEntry_WhiteSpace_Test()
|
||||
{
|
||||
#region Stubs
|
||||
var entry = "test; test2; ";
|
||||
#endregion
|
||||
|
||||
var result = ModerationParser.Parse(entry);
|
||||
|
||||
#region Validations
|
||||
Assert.AreEqual(2, result.Length);
|
||||
Assert.AreEqual("test", result[0]);
|
||||
Assert.AreEqual("test2", result[1]);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
Reference in a new issue