Following up on this post, today, I got this test working :
public class Spike
{
[Fact]
public void NullIsStringThatSaysNull_When_Something_Is_Null()
{
Person person = null;
var result =
new SomeNullIsNullString<Spike>(this)
.Do(x => person)
.Do(x => x.Adress)
.Do(x => x.Postcode);
Assert.Equal("null", result.ToString());
}
[Fact]
public void NullIsStringThatSaysNull_When_Something_Is_Null_Stops_Execution()
{
Person person = null;
var result =
new SomeNullIsNullString<Spike>(this)
.Do(x => person)
.Do(x => x.TriesToGetAddressButThrows())
.Do(x => x.Postcode);
Assert.Equal("null", result.ToString());
}
[Fact]
public void NullIsStringThatSaysNull_Everyting_Exists()
{
var person =
new Person
{
Adress = new Adress { Postcode = "2000" }
};
var result =
new SomeNullIsNullString<Spike>(this)
.Do(x => person)
.Do(x => x.Adress)
.Do(x => x.Postcode);
Assert.Equal("2000", result.ToString());
}
}
Using this simple model :
public class Person
{
public Adress Adress;
public Adress TriesToGetAddressButThrows()
{
throw new Exception();
}
}
public class Adress
{
public string Postcode;
}