Fluent assertion can not get excluding property to work

24 Views Asked by At

I can't seem to ignore properties when doing fluent assertions.

 actual.MyItems.Should().BeEquivalentTo(request.MyItems,
                    opt => opt.Excluding(a => a.Usage).Excluding(a=>a.OtherId);

How can I still get an error message like this:

Expected actual.MyItems[0] to be { "Usage": "Test", "Id": "129e149f-efab-4221-a047-eaf263ccb9c9" },
 but found { "Usage": "Test", "Id": "129e149f-efab-4221-a047-eaf263ccb9c9", "OtherId": "21b11434-104d-40ef-9a20-8c7fd38fe61c" }.

I thought I could exclude the Usage and OtherId property and thus ignore it when comparing?

They are properties generated from a protobuf file so for example usage:

 public string Usage {
      get { return usage_; }
      set {
        usage_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
      }
    } 
 
 
0

There are 0 best solutions below