public void ToCode_given_TwoPropertiesAndConstructor_should_ReturnCode() { // # Arrange. var sut = new ClassData(); sut.Comment = new CommentData("Simple DTO class."); sut.Name = "Customer"; sut.Properties = new List<PropertyData> { new PropertyData { Name="CustomerID", SystemType=typeof(int), Scope=Common.VisibilityScope.Internal }, new PropertyData { Name="Name", SystemType =typeof(string), Scope=Common.VisibilityScope.Public } }; sut.Methods = new List<MethodData> { new MethodData { Name="Customer", IsConstructor= true, Scope=Common.VisibilityScope.Internal } }; // # Act. var res = sut.ToCode(); // # Assert. Assert.AreEqual(12, res.Count); CollectionAssert.AreEqual( new[] { "/// <summary> Simple DTO class.", "/// </summary>", "public class Customer", "{", "\tinternal System.Int32 CustomerID{ get; set; }", string.Empty, "\tpublic System.String Name{ get; set; }", string.Empty, "\tinternal Customer()", "\t{", "\t}", "}" }, res.ToList()); }
private IList<string> MakeClass(ClassData classData) { var ret = new List<string>(); ret.Add(string.Format( "//\tThis file was generated by St4mpede.Poco {0}.", DateTime.Now.ToString("u"))); ret.Add(string.Empty); ret.AddRange(_pocoSettings.NameSpaceComments.Select(c => string.Format("//\t{0}",c))); ret.Add(string.Format("namespace {0}", _pocoSettings.NameSpace)); ret.Add("{"); ret.AddRange(classData.ToCode(new Indent(1))); ret.Add("}"); return ret; }
private IList<string> MakeClass(ClassData classData) { var ret = new List<string>(); ret.Add($"//\tThis file was generated by St4mpede.Surface {DateTime.Now.ToString("u")}."); ret.Add(string.Empty); // ret.AddRange(_pocoSettings.NameSpaceComments.Select(c => string.Format("//\t{0}", c))); ret.Add($"namespace TheDal.Surface"); ret.Add("{"); ret.Add(" using System;"); ret.Add(" using System.Collections.Generic;"); ret.Add(" using System.Linq;"); ret.Add(" using Dapper;"); ret.Add(string.Empty); ret.AddRange(classData.ToCode(new Indent(1))); ret.Add("}"); return ret; }