Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ExcludingNestedObjects
Run-time exception (line 35): Expected member Nested to be
Obj
{
Nested = <null>
Str = "test"
}, but found <null>.
With configuration:
- Use declared types and members
- Compare enums by value
- Match member by name (or throw)
- Be strict about the order of items in byte arrays
Stack Trace:
[NUnit.Framework.AssertionException: Expected member Nested to be
Obj
{
Nested = <null>
Str = "test"
}, but found <null>.
With configuration:
- Use declared types and members
- Compare enums by value
- Match member by name (or throw)
- Be strict about the order of items in byte arrays
]
at Program.Main(): line 35
using System;
using FluentAssertions;
public class Obj
{
public string Str
{
get;
set;
}
public Obj Nested
{
get;
set;
}
}
public class Program
{
public static void Main()
{
var first = new Obj()
{
Nested = null, Str = "test"
}
;
var second = new Obj()
{
Nested = first, Str = "test"
}
;
first.ShouldBeEquivalentTo(second, o => o.ExcludingNestedObjects());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment