public static void Assert <TModel, TProperty>(IJsonValue input, Func <TModel, TProperty> toProperty, TProperty shouldBe) { var response = new RestResponse(); if (input is NotPresent) { response.Content = "{}"; } else { response.Content = $@"{{ ""{input.PropertyName}"": {input.GetJsonRepresentation()} }}"; } var deserializer = new CustomJsonCodec(new Configuration()); var output = deserializer.Deserialize <TModel>(response); Xunit.Assert.Equal(shouldBe, toProperty(output)); }