ListMapper
ListMapper is used to transform a collection used as an actual argument
producing another collection to be used in the assertion.
using NUnit.Compatibility;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
namespace NUnit.Framework
{
public class ListMapper
{
private ICollection original;
public ListMapper(ICollection original)
{
this.original = original;
}
public ICollection Property(string name)
{
List<object> list = new List<object>();
foreach (object item in original) {
PropertyInfo property = TypeExtensions.GetProperty(item.GetType(), name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if ((object)property == null)
throw new ArgumentException($"{item}""{name}""");
list.Add(property.GetValue(item, null));
}
return list;
}
}
}