У меня есть эта иерархия классов
public class Order
{
private Client _client;
public virtual Client { get => _client; }
private OrderNumber _orderNumber;
public virtual OrderNumber OrderNumber { get => _orderNumber; }
private ShippingDetails _shippingDetails;
public virtual ShippingDetails ShippingDetails { get => _shippingDetails; }
private IList<Product> _products;
protected internal virtual IEnumerable<Product> Products { get => _products; }
public Order() { }
public virtual void CreateDraftForClient(int id)
{
/// => business rule validation of value
_client= new Client(id);
/// => event
}
}
public class Client
{
private int _id;
public virtual int Id { get => _id; }
private Client() { }
protected internal Client(int id)
{
SetId(id);
}
private void SetId(int id)
{
_id = id;
}
}
И я хочу создать полностью инициализированный макет порядка
clientMock = new Mock<Client>();
clientMock.SetupGet(prop => prop.Client).Returns(1);
orderMock = new Mock<Order>();
orderMock.SetupGet(prop => prop.Client).Returns(orderMock.Object);
Исключение:
Message: System.AggregateException : One or more errors occurred. (Can not instantiate proxy of class: Client. Could not find a parameterless constructor.) (The following constructor parameters did not have matching fixture data: eRxTestSetup testSetup)
---- Castle.DynamicProxy.InvalidProxyConstructorArgumentsException : Can not instantiate proxy of class: Client. Could not find a parameterless constructor.
---- The following constructor parameters did not have matching fixture data: eRxTestSetup testSetup
Есть лиКак я могу сделать это без необходимости изменения структуры клиента?Или, если нет, какие еще варианты у меня есть?