ronkpunk
ronkpunk
CC#
Created by ronkpunk on 11/14/2022 in #help
Unit Testing, AcionResult Metadata Properties and JsonSerializer.Deserialize [Answered]
Hi all, I'm trying to add Unit Test to my WebAPI. I choose to call my endpoints with an httpclient and make my asserts on deserialized response. Now, it'm almost my first Unit Test experience so I don't know if I'm right or not so my first question is. Should it is an approach? After that, when I try to deserialize my reponse, all content contains metadata properties that, in Array cases, change completely the type of property (object with { "$id": "1", "$values": [<the-array>]), so deserialize not work if I specify the response type. Is there a way to avoid/ignore metadata properties and just return my plain model? Now I'm trying to remove them through Regex Replace but (and here it is the third question), Regex found correctly my pattern with groups, I try to return Group[1].Value from my MatchEvaluator but Regex.Replace return exactly the input variable, without changes, any help? Thank you in advance
117 replies