public void CreateClass() { var actual = RestartableAddInGenerator.CreateCompileUnit(); var ns = RestartableAddInGenerator.CreateNamespace(actual, NamespaceName); RestartableAddInGenerator.CreateClass(ns, ClassName, HostViewFullName); const string expected = @"//------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:4.0.30319.34209 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ namespace Solink.Sample { public sealed class RestartableThing : Solink.AddIn.Helpers.RestartableAddIn<Solink.HostViews.IThing>, Solink.HostViews.IThing { } } "; AssertGeneratedCode(expected, actual); }
private static CodeTypeDeclaration CreateClassWithConstructor(CodeCompileUnit actual) { var ns = RestartableAddInGenerator.CreateNamespace(actual, NamespaceName); var @class = RestartableAddInGenerator.CreateClass(ns, ClassName, HostViewFullName); RestartableAddInGenerator.CreateConstructor(@class); return(@class); }
public void CreateProperty() { var actual = RestartableAddInGenerator.CreateCompileUnit(); var ns = RestartableAddInGenerator.CreateNamespace(actual, NamespaceName); var @class = RestartableAddInGenerator.CreateClass(ns, ClassName, HostViewFullName); RestartableAddInGenerator.CreateProperty(@class, "Id", typeof(int), true); const string expected = @"//------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:4.0.30319.34209 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ namespace Solink.Sample { public sealed class RestartableThing : Solink.AddIn.Helpers.RestartableAddIn<Solink.HostViews.IThing>, Solink.HostViews.IThing { public int Id { get { return base.Func(_ => _.Id); } set { base.Action(_ => _.Id = value); } } } } "; AssertGeneratedCode(expected, actual); }
public void CreateFuncMethodForVoid() { var actual = RestartableAddInGenerator.CreateCompileUnit(); var ns = RestartableAddInGenerator.CreateNamespace(actual, NamespaceName); var @class = RestartableAddInGenerator.CreateClass(ns, ClassName, HostViewFullName); var methodParameters = new[] { Tuple.Create(typeof(IList <string>), "strings"), }; RestartableAddInGenerator.CreateFuncMethod(@class, "AddToList", methodParameters, typeof(void)); const string expected = @"//------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:4.0.30319.34209 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ namespace Solink.Sample { public sealed class RestartableThing : Solink.AddIn.Helpers.RestartableAddIn<Solink.HostViews.IThing>, Solink.HostViews.IThing { public void AddToList(System.Collections.Generic.IList<string> strings) { base.Action(_ => _.AddToList(strings)); } } } "; AssertGeneratedCode(expected, actual); }
public void CreateFuncMethod() { var actual = RestartableAddInGenerator.CreateCompileUnit(); var ns = RestartableAddInGenerator.CreateNamespace(actual, NamespaceName); var @class = RestartableAddInGenerator.CreateClass(ns, ClassName, HostViewFullName); var methodParameters = new Tuple <Type, string>[] { }; RestartableAddInGenerator.CreateFuncMethod(@class, "ComputeAnswerToLifeAndUniverseEverything", methodParameters, typeof(int)); const string expected = @"//------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:4.0.30319.34209 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ namespace Solink.Sample { public sealed class RestartableThing : Solink.AddIn.Helpers.RestartableAddIn<Solink.HostViews.IThing>, Solink.HostViews.IThing { public int ComputeAnswerToLifeAndUniverseEverything() { return base.Func(_ => _.ComputeAnswerToLifeAndUniverseEverything()); } } } "; AssertGeneratedCode(expected, actual); }
public void CreateNamespace() { var actual = RestartableAddInGenerator.CreateCompileUnit(); RestartableAddInGenerator.CreateNamespace(actual, NamespaceName); const string expected = @"//------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:4.0.30319.34209 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ namespace Solink.Sample { } "; AssertGeneratedCode(expected, actual); }