Quantcast
Channel: Fluent Assertions
Viewing all articles
Browse latest Browse all 1402

Commented Feature: Support property comparison of objects in collections [11447]

$
0
0
If a property is of a collection type of another object, and recursive comparison is enabled, it should compare the individual objects as well.
Comments: ** Comment from web user: bjarke **

The following example shows the problem.

==============================================================
namespace FluentAssertions.specs
{
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
public class IncludingNestedObjects
{
[TestMethod]
public void Test()
{
var f1 = new Foo {Bars = new List<Bar> {new Bar()}};
var f2 = new Foo {Bars = new List<Bar> {new Bar()}};

f1.ShouldHave().AllProperties().IncludingNestedObjects().EqualTo(f2);
}

public class Bar
{
}

public class Foo
{
public List<Bar> Bars { get; set; }
}
}
}
==============================================================

The test fails with the message:

==============================================================
Expected property Bars to be equal to {

FluentAssertions.specs.IncludingNestedObjects+Bar
{
}}, but {

FluentAssertions.specs.IncludingNestedObjects+Bar
{
}} differs at index 0.
==============================================================


Viewing all articles
Browse latest Browse all 1402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>