private GraphTypeMethodTemplate CreateMethodTemplate <TObject>(string methodName) { var obj = new Mock <IObjectGraphTypeTemplate>(); obj.Setup(x => x.Route).Returns(new GraphFieldPath("[type]/Item0")); obj.Setup(x => x.InternalFullName).Returns("Item0"); var parent = obj.Object; var methodInfo = typeof(TObject).GetMethod(methodName); var template = new GraphTypeMethodTemplate(parent, methodInfo, TypeKind.OBJECT); template.Parse(); template.ValidateOrThrow(); return(template); }
public void Parse_DefaultValuesCheck() { var obj = new Mock <IObjectGraphTypeTemplate>(); obj.Setup(x => x.Route).Returns(new GraphFieldPath("[type]/Item0")); obj.Setup(x => x.InternalFullName).Returns("Item0"); var parent = obj.Object; var methodInfo = typeof(MethodClass).GetMethod(nameof(MethodClass.SimpleMethodNoAttributes)); var template = new GraphTypeMethodTemplate(parent, methodInfo, TypeKind.OBJECT); template.Parse(); template.ValidateOrThrow(); Assert.AreEqual(nameof(MethodClass.SimpleMethodNoAttributes), template.Name); Assert.AreEqual($"Item0.{nameof(MethodClass.SimpleMethodNoAttributes)}", template.InternalFullName); Assert.AreEqual($"[type]/Item0/{nameof(MethodClass.SimpleMethodNoAttributes)}", template.Route.Path); Assert.AreEqual(parent.Route.Path, template.Route.Parent.Path); Assert.AreEqual(methodInfo, template.Method); Assert.AreEqual(parent, template.Parent); Assert.AreEqual(0, template.TypeExpression.Wrappers.Length); Assert.IsFalse(template.IsDeprecated); }