snapshooter icon indicating copy to clipboard operation
snapshooter copied to clipboard

Multiple asserts in one assert context do not work

Open michaelstaib opened this issue 4 years ago • 2 comments

results.MatchSnapshot(matchOptions =>
            {
                return matchOptions.Assert(fieldOption =>
                {
                    Assert.Equal(sessionId, fieldOption.Field<string>("[0].Data.onPublishSchema.sessionId"));
                    Assert.Equal(sessionId, fieldOption.Field<string>("[1].Data.onPublishSchema.sessionId"));

                    /*
                    Assert.Collection(
                        fieldOption.Fields<string>("[*].Data.onPublishSchema.sessionId"),
                        t => Assert.Equal(sessionId, t),
                        t => Assert.Equal(sessionId, t));*/
                });
            });

michaelstaib avatar Feb 06 '20 10:02 michaelstaib

@michaelstaib is this already completed - I took the latest master pull and tried to reproduce the error but test case is passing. I've tried the following in MatchSnapshot_PlainExtension_CorrectSnapshot method inside SnapshotExtensionTests.cs

testPerson.MatchSnapshot(matchOption => matchOption.Assert(fieldOption =>
{
   Assert.Equal("Hanna", fieldOption.Field<string>("Children[2].Name"));
   Assert.Collection(fieldOption.Fields<string>("Children[*].Name"),
         a1 => { },
         a2 => { },
         a3 => "Hanna".Should().BeEquivalentTo(a3);
   );
}));

KoditkarVedant avatar Aug 05 '20 17:08 KoditkarVedant

Should be fixed with the last version.

michaelstaib avatar Aug 05 '20 17:08 michaelstaib