Код: Выделить всё
public class Entity
{
public string Id {get; set;}
public string Name {get; set;}
}
public class Derived : Entity, ICollection
{
private List m_Children = new List();
public string Description { get; set; }
public int Count => ((ICollection)m_Children).Count;
public bool IsReadOnly => ((ICollection)m_Children).IsReadOnly;
public void Add(Entity item)
{
((ICollection)m_Children).Add(item);
}
public void Clear()
{
((ICollection)m_Children).Clear();
}
public bool Contains(Entity item)
{
return ((ICollection)m_Children).Contains(item);
}
public void CopyTo(Entity[] array, int arrayIndex)
{
((ICollection)m_Children).CopyTo(array, arrayIndex);
}
public IEnumerator GetEnumerator()
{
return ((ICollection)m_Children).GetEnumerator();
}
public bool Remove(Entity item)
{
return ((ICollection)m_Children).Remove(item);
}
IEnumerator IEnumerable.GetEnumerator()
{
return ((ICollection)m_Children).GetEnumerator();
}
}
Код: Выделить всё
[TestMethod]
public void EquivalenceTest()
{
var expected = new Derived
{
Id = "123",
Name = "abc",
Description = "def"
};
var actual = new Derived
{
Id = "121",
Name = "xyz",
Description = "def"
};
actual.Should().BeEquivalentTo(expected); // This succeeds, but should fail
}
Как заставить платформу проверять свойства и содержимое коллекции?
Изменить
Кажется, это известная проблема
Кто-нибудь знает обходной путь?
Подробнее здесь: https://stackoverflow.com/questions/603 ... tto-when-u
Мобильная версия