Skip to content

Instantly share code, notes, and snippets.

@cmellongoempyrean
Created September 9, 2016 23:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmellongoempyrean/bdb3c63a3755d7f27c0751919cbc93ea to your computer and use it in GitHub Desktop.
Save cmellongoempyrean/bdb3c63a3755d7f27c0751919cbc93ea to your computer and use it in GitHub Desktop.
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