public void AppendInstanceComplexGetterTest() { Type target = typeof(TestType1); DotNetEmitter emitter = new DotNetEmitter(target); string expected = "public async Task<object> Get_Child(object _referenceId)" + Environment.NewLine + "{" + Environment.NewLine + " long _refId = _referenceId is long ? (long)_referenceId : (long)(int)_referenceId;" + Environment.NewLine + Environment.NewLine + " DotNetTest.TestType1 _parent = " + "(DotNetTest.TestType1)" + "ReferenceManager.Instance.PullReference(_refId);" + Environment.NewLine + " DotNetTest.TestType2 _result = _parent.Child;" + Environment.NewLine + " return ReferenceManager.Instance.EnsureReference(_result);" + Environment.NewLine + "}" + Environment.NewLine; PropertyInfo info = target.GetProperty("Child"); emitter.AppendGetter(info, false); Assert.AreEqual( expected, emitter.ToString()); }
public void AppendStaticSimpleGetterTest() { Type target = typeof(TestType1); DotNetEmitter emitter = new DotNetEmitter(target); string expected = "public async Task<object> Get_SharedData(object unused)" + Environment.NewLine + "{" + Environment.NewLine + " System.String _result = DotNetTest.TestType1.SharedData;" + Environment.NewLine + " return _result;" + Environment.NewLine + "}" + Environment.NewLine; PropertyInfo info = target.GetProperty("SharedData"); emitter.AppendGetter(info, true); Assert.AreEqual( expected, emitter.ToString()); }