I have the following situation and any help would be appreciated.
public class Poco
{
public string SomeData { get;set; }
public string SomeMoreData { get;set; }
}
public class Worker
{
public Poco DoWork()
{
// do stuff
}
}
TESTING METHOD A.......
[Test]
public static void TestPocoIsPopulated()
{
var objUt = new Worker();
var actual = objUt.DoWork();
var expected = new Poco { SomeData = "reusltOne", SomeMoreData = "resultTwo" };
actual.ShouldBeEquivalentTo(expected);
}
This works fine. However, with larger tests of nested classes, using ShouldBeEquivalentTo() becomes cumbersome, and I'd like to be able to do this as follows...
EDIT: Also with Method A you cant do this.... var expected = new Poco { SomeData = [NOT_NULL] , SomeMoreData = "resultTwo" };
TESTING METHOD B.......
[Test]
public static void TestPocoIsPopulated()
{
var objUt = new Worker();
var actual = objUt.DoWork();
actual.SomeData.Should().Be("resultOne");
actual.SomeMoreData.Should().Be("resultTwo");
}
However, if I add a new property to Poco, then Testing Method B does not complain, and the property may not get tested. Using Method A however, the test will fail as ShouldBeEquivalentTo() will note that the new property is null
So, my question is, is there a method C as follows.
TESTING METHOD C.........
[Test]
public static void TestPocoIsPopulated()
{
var objUt = new Worker();
var actual = objUt.DoWork();
actual.SomeData.Should().Be("resultOne");
actual.SomeMoreData.Should().Be("resultTwo");
actual.Should().HaveAllPropertiesBeenTested().EqualTo(true); // <-------- is this possible?
}