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

New Post: Exception in Excluding from nested property.

$
0
0
dennisdoomen wrote:
I think using an Expression with an indexer only works if the collection is an array. You should use the overload that takes a Func<ISubjectInfo, bool>() to compare the property path against "Products[0].Status".
Big Thanks!!!

Yes
I wrote:
public class Order
    {
        public Int32 Id { get; set; }
        public Product[] Products { get; set; }
    }

~~~~~~~
[Test]
~~~
order2.ShouldBeEquivalentTo(order1, options => options.Excluding(o => o.Products[0].Status).Excluding(o => o.Products[1].Status));
And test is success.
With List<Product> don't working :( May can used List<T> ?
private List<Product> _product;
public Product[] Products 
{
   get{ return _product.ToArray(); }
}
is bad option.

And second question:
How can exclude property Status from class Product for all elements of array?
Thanks.

Viewing all articles
Browse latest Browse all 1402

Trending Articles



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