diff --git a/CodeGeneration.sln b/CodeGeneration.sln index 675e78a..a46232c 100644 --- a/CodeGeneration.sln +++ b/CodeGeneration.sln @@ -17,11 +17,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Files", "Solution Files", "{3E32806A-8707-4D41-9126-57717DC4C1EE}" ProjectSection(SolutionItems) = preProject - .gitignore = .gitignore .gitattributes = .gitattributes + .gitignore = .gitignore README.md = README.md EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Extensions.Test", "Extensions.Test\Extensions.Test.csproj", "{64EAD5E4-5816-4A94-AF47-7D9A640D8B55}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{587DABEF-E1F1-4A53-90E4-C330A3AC4917}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -42,8 +46,15 @@ Global {D29742AE-DCD9-4A34-AD67-E3F39FE4443C}.Debug|Any CPU.Build.0 = Debug|Any CPU {D29742AE-DCD9-4A34-AD67-E3F39FE4443C}.Release|Any CPU.ActiveCfg = Release|Any CPU {D29742AE-DCD9-4A34-AD67-E3F39FE4443C}.Release|Any CPU.Build.0 = Release|Any CPU + {64EAD5E4-5816-4A94-AF47-7D9A640D8B55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {64EAD5E4-5816-4A94-AF47-7D9A640D8B55}.Debug|Any CPU.Build.0 = Debug|Any CPU + {64EAD5E4-5816-4A94-AF47-7D9A640D8B55}.Release|Any CPU.ActiveCfg = Release|Any CPU + {64EAD5E4-5816-4A94-AF47-7D9A640D8B55}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {64EAD5E4-5816-4A94-AF47-7D9A640D8B55} = {587DABEF-E1F1-4A53-90E4-C330A3AC4917} + EndGlobalSection EndGlobal diff --git a/Extensions.Test/Extensions.Test.csproj b/Extensions.Test/Extensions.Test.csproj new file mode 100644 index 0000000..6cdb9c3 --- /dev/null +++ b/Extensions.Test/Extensions.Test.csproj @@ -0,0 +1,90 @@ + + + + Debug + AnyCPU + {64EAD5E4-5816-4A94-AF47-7D9A640D8B55} + Library + Properties + Extensions.Test + Extensions.Test + v4.5 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + {d29742ae-dcd9-4a34-ad67-e3f39fe4443c} + Extensions + + + + + + + False + + + False + + + False + + + False + + + + + + + + \ No newline at end of file diff --git a/Extensions.Test/InflectorBehavior.cs b/Extensions.Test/InflectorBehavior.cs new file mode 100644 index 0000000..bf96bd3 --- /dev/null +++ b/Extensions.Test/InflectorBehavior.cs @@ -0,0 +1,21 @@ +using HedgehogDevelopment.CodeGeneration.Extensions; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Extensions.Test +{ + [TestClass] + public class InflectorBehavior + { + [TestMethod] + public void CapitalizeShouldOnlyCapitalizeFirstCharacter() + { + Assert.AreEqual("Pagetemplates", "pageTemplates".Capitalize()); + } + + [TestMethod] + public void CapitalizeShouldPreserveRemainingCharacters() + { + Assert.AreEqual("PageTemplates", "pageTemplates".Capitalize(true)); + } + } +} \ No newline at end of file diff --git a/Extensions.Test/Properties/AssemblyInfo.cs b/Extensions.Test/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..4de8122 --- /dev/null +++ b/Extensions.Test/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Extensions.Test")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Extensions.Test")] +[assembly: AssemblyCopyright("Copyright © 2013")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("249ef0fa-7b93-4ed7-857d-b80ecb8d057a")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Extensions.Test/StringExtensionsBehavior.cs b/Extensions.Test/StringExtensionsBehavior.cs new file mode 100644 index 0000000..fd5a152 --- /dev/null +++ b/Extensions.Test/StringExtensionsBehavior.cs @@ -0,0 +1,53 @@ +using HedgehogDevelopment.CodeGeneration.Extensions; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Extensions.Test +{ + [TestClass] + public class StringExtensionsBehavior + { + [TestMethod] + public void AsClassNameShouldNotContainUnderscores() + { + Assert.AreEqual("UserDefined", "User Defined".AsClassName()); + Assert.AreEqual("UserDefined", "User_Defined".AsClassName()); + } + + [TestMethod] + public void AsInterfaceShouldNotContainUnderscores() + { + Assert.AreEqual("IBasePage", "Base Page".AsInterfaceName()); + Assert.AreEqual("IBasePage", "Base_Page".AsInterfaceName()); + Assert.AreEqual("IBasePage", "IBasePage".AsInterfaceName()); + } + + [TestMethod] + public void AsNamespaceShouldStripErroneousPeriods() + { + var segments = new string[5] {".My", "Namespace.", "For", "The...Sample..", "Project."}; + string ns = segments.AsNamespace(); + + Assert.AreEqual("My.Namespace.For.The.Sample.Project", ns); + } + + [TestMethod] + public void AsNamespaceShouldReturnPascalCased() + { + var segments = new string[6] + {"MyCompany", "MyProject", "sitecore", "templates", "User Defined", "Page Fragments"}; + string ns = segments.AsNamespace(); + + Assert.AreEqual("MyCompany.MyProject.Sitecore.Templates.UserDefined.PageFragments", ns); + } + + [TestMethod] + public void AsNamespaceShouldNotContainUnderscores() + { + var segments = new string[6] + {"MyCompany", "MyProject", "sitecore", "templates", "User Defined", "Page Fragments"}; + string ns = segments.AsNamespace(""); + + Assert.AreEqual("MyCompany.MyProject.Sitecore.Templates.UserDefined.PageFragments", ns); + } + } +} \ No newline at end of file diff --git a/Extensions/Extensions.csproj b/Extensions/Extensions.csproj index 70e9241..effdfcc 100644 --- a/Extensions/Extensions.csproj +++ b/Extensions/Extensions.csproj @@ -53,7 +53,8 @@ - xcopy "$(TargetDir)*" "%25ProgramFiles%25\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies" /i /d /y /e + xcopy "$(TargetDir)*" "%25ProgramFiles%25\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies" /i /d /y /e +xcopy "$(TargetDir)*" "%25ProgramFiles%25\Microsoft Visual Studio 11.0\Common7\IDE\PublicAssemblies" /i /d /y /e