internal static void WriteResponse(MethodMetadataResultModel results, [CallerMemberName] string methodname = null) { var test = JsonConvert.SerializeObject(results, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); var args = $@" Assert.Collection(result.InputArguments, "; foreach (var arg in results.InputArguments) { args += $@" arg => {{ Assert.Equal(""{arg.Name}"", arg.Name); Assert.Equal(NodeValueRank.{arg.ValueRank}, arg.ValueRank); Assert.Equal(""{JsonConvert.SerializeObject(arg.ArrayDimensions)}"", JsonConvert.SerializeObject(arg.ArrayDimensions)); Assert.Equal(NodeClass.{arg.Type.NodeClass}, arg.Type.NodeClass); Assert.Equal(""{arg.Type.NodeId}"", arg.Type.Id); Assert.Null(arg.Type.DataType); Assert.Equal(""{arg.Type.DisplayName}"", arg.Type.DisplayName); Assert.Null(arg.DefaultValue); }},"; } args = args.TrimEnd().TrimEnd(','); args += $@"); Assert.Collection(result.OutputArguments, "; foreach (var arg in results.OutputArguments) { args += $@" arg => {{ Assert.Equal(""{arg.Name}"", arg.Name); Assert.Equal(NodeValueRank.{arg.ValueRank}, arg.ValueRank); Assert.Equal(""{JsonConvert.SerializeObject(arg.ArrayDimensions)}"", JsonConvert.SerializeObject(arg.ArrayDimensions)); Assert.Equal(NodeClass.{arg.Type.NodeClass}, arg.Type.NodeClass); Assert.Equal(""{arg.Type.NodeId}"", arg.Type.Id); Assert.Null(arg.Type.DataType); Assert.Equal(""{arg.Type.DisplayName}"", arg.Type.DisplayName); Assert.Null(arg.DefaultValue); }},"; } args = args.TrimEnd().TrimEnd(','); args += ");"; System.Diagnostics.Trace.WriteLine(methodname); System.Diagnostics.Trace.WriteLine(""); System.Diagnostics.Trace.WriteLine(args); System.Diagnostics.Trace.WriteLine(""); }
/// <summary> /// Create from service model /// </summary> /// <param name="model"></param> public MethodMetadataResponseApiModel(MethodMetadataResultModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } ErrorInfo = model.ErrorInfo == null ? null : new ServiceResultApiModel(model.ErrorInfo); ObjectId = model.ObjectId; InputArguments = model.InputArguments? .Select(a => a == null ? null : new MethodMetadataArgumentApiModel(a)) .ToList(); OutputArguments = model.OutputArguments? .Select(a => a == null ? null : new MethodMetadataArgumentApiModel(a)) .ToList(); }
/// <summary> /// Create from service model /// </summary> /// <param name="model"></param> public static MethodMetadataResponseApiModel ToApiModel( this MethodMetadataResultModel model) { if (model == null) { return(null); } return(new MethodMetadataResponseApiModel { ErrorInfo = model.ErrorInfo.ToApiModel(), ObjectId = model.ObjectId, InputArguments = model.InputArguments? .Select(a => a.ToApiModel()) .ToList(), OutputArguments = model.OutputArguments? .Select(a => a.ToApiModel()) .ToList() }); }