I have a method to concatenate strings provided by int?
.
public string ConcatenateNumber(IEnumerable<int?> myList)
{
return myList
.Distinct()
.Aggregate(
new StringBuilder(),
(current, next) => current.Append("'").Append(next))
.ToString()
.Substring(1);
}
Now I want to do unit test.
[TestMethod]
public void InputIntegers_Should_Be_Concatenated_When_Consider_Distinct()
{
var myList = CreateEnumerable(1, 2, 2, 3);
var logic = new MainLogic();
var result = logic.ConcatenateNumber(myList);
Assert.AreEqual("1'2'3", result);
}
public IEnumerable<T> CreateEnumerable<T>(params T[] items)
{
if (items == null)
yield break;
foreach (T mitem in items)
yield return mitem;
}
However I have the compile error.
C#: Unknown method ConcatenateNumber(System.Collections.Generic.IEnumerable) of ....
I think it is caused by nullable integer int?
. But I am not sure how to fix it.