G
G
Georgy Kuznetsov2022-03-21 13:37:41
C++ / C#
Georgy Kuznetsov, 2022-03-21 13:37:41

What are the tests (analogues of Assert) for .NET for reference data types?

Suppose two identical objects are created by field values, the usual Assert.AreEquals for MSTest will return an error as expected, since it compares references to objects and not the values ​​of the objects themselves

. How to compare two objects by their field values?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2022-03-21
@JoeSmith3100

The easiest option is to serialize to Json and compare. You can
also use the Verify library: https://github.com/VerifyTests/Verify
Or something for deep comparison: https://github.com/GregFinzer/Compare-Net-Objects

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question