当前位置: 首页>>代码示例>>C#>>正文


C# MethodData.ToCode方法代码示例

本文整理汇总了C#中MethodData.ToCode方法的典型用法代码示例。如果您正苦于以下问题:C# MethodData.ToCode方法的具体用法?C# MethodData.ToCode怎么用?C# MethodData.ToCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MethodData的用法示例。


在下文中一共展示了MethodData.ToCode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToCode_given_ConstructorDataWithoutParameters_should_ReturnDefaultConstructorCode

        public void ToCode_given_ConstructorDataWithoutParameters_should_ReturnDefaultConstructorCode()
        {
            //	#	Arrange.
            var sut = new MethodData();
            sut.Comment = new CommentData("Default constructor.");
            sut.IsConstructor = true;
            sut.Scope = Common.VisibilityScope.Public;
            sut.Name = "MyClassName";

            //	#	Act.
            var res = sut.ToCode();

            //	#	Assert.
            Assert.AreEqual(5, res.Count);
            CollectionAssert.AreEqual(
                new[]
                {
                    "/// <summary> Default constructor.",
                    "/// </summary>",
                    "public MyClassName()",
                    "{",
                    "}",
                },
                res.ToList());
        }
开发者ID:LosManos,项目名称:St4mpede,代码行数:25,代码来源:MethodDataTest.cs

示例2: ToCode_given_ConstructorDataWithBody_should_ReturnProper

        public void ToCode_given_ConstructorDataWithBody_should_ReturnProper()
        {
            //	#	Arrange.
            const string ClassName = "Customer";

            var sut = new MethodData
            {
                IsConstructor = true,
                Scope = Common.VisibilityScope.Internal,
                Name = ClassName,
                Parameters = new List<ParameterData>
                {
                    new ParameterData
                    {
                        Name=ClassName,
                        SystemTypeString = ClassName
                    }
                },
                Body = new BodyData
                {
                    Lines= new List<string>
                    {
                        "this.CustomerId = customer.CustomerId;",
                        "this.CustomerName = customer.CustomerName;"
                    }
                }
            };

            //	#	Act.
            var res = sut.ToCode();

            //	#	Assert.
            CollectionAssert.AreEqual(
                new[]
                {
                    "internal Customer( Customer customer )",
                    "{",
                    "\tthis.CustomerId = customer.CustomerId;",
                    "\tthis.CustomerName = customer.CustomerName;",
                    "}"
                },
                res.ToList());
        }
开发者ID:LosManos,项目名称:St4mpede,代码行数:43,代码来源:MethodDataTest.cs

示例3: ToCode_given_ConstructorDataWithParameters_should_ReturnProperConstrutor

        public void ToCode_given_ConstructorDataWithParameters_should_ReturnProperConstrutor()
        {
            //	#	Arrange.
            var sut = new MethodData
            {
                IsConstructor = true,
                Scope = Common.VisibilityScope.Internal,
                Name = "Customer",
                Parameters = new List<ParameterData>
                {
                    new ParameterData
                    {
                        Name="CustomerId",
                        SystemTypeString = typeof(int).ToString()
                    },
                    new ParameterData
                    {
                        Name="CustomerName",
                        SystemTypeString = typeof(string).ToString()
                    }
                }
            };

            //	#	Act.
            var res = sut.ToCode();

            //	#	Assert.
            CollectionAssert.AreEqual(
                new[]
                {
                    "internal Customer( System.Int32 customerId, System.String customerName )",
                    "{",
                    "\tthis.CustomerId = customerId;",
                    "\tthis.CustomerName = customerName;",
                    "}"
                },
                res.ToList());
        }
开发者ID:LosManos,项目名称:St4mpede,代码行数:38,代码来源:MethodDataTest.cs


注:本文中的MethodData.ToCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。