diff options
3 files changed, 55 insertions, 1 deletions
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/DummyTemplateGenerator.cs b/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/DummyTemplateGenerator.cs new file mode 100644 index 0000000000..6ddd9d9a41 --- /dev/null +++ b/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/DummyTemplateGenerator.cs @@ -0,0 +1,44 @@ +// +// DummyTemplateGenerator.cs +// +// Author: +// David Karlaš <david.karlas@xamarin.com> +// +// Copyright (c) 2016 Xamarin, Inc (http://www.xamarin.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.Reflection; + +namespace Mono.TextTemplating.Tests +{ + public class DummyTemplateGenerator : TemplateGenerator + { + protected override string ResolveAssemblyReference (string assemblyReference) + { + var assemblyName = new AssemblyName (assemblyReference).Name; + if (assemblyName == typeof (Uri).Assembly.GetName ().Name) + return typeof (Uri).Assembly.Location;//System.dll + else if (assemblyName == typeof (System.Linq.Enumerable).Assembly.GetName ().Name) + return typeof (System.Linq.Enumerable).Assembly.Location;//System.Core.dll + return base.ResolveAssemblyReference (assemblyReference); + } + } +} + diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/GenerationTests.cs b/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/GenerationTests.cs index 7558e37a13..fb26f8d23d 100644 --- a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/GenerationTests.cs +++ b/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/GenerationTests.cs @@ -40,13 +40,22 @@ namespace Mono.TextTemplating.Tests [Test] public void TemplateGeneratorTest () { - var gen = new TemplateGenerator (); + var gen = new DummyTemplateGenerator (); string tmp = null; gen.ProcessTemplate (null, "<#@ template language=\"C#\" #>", ref tmp, out tmp); Assert.AreEqual (0, gen.Errors.Count, "ProcessTemplate"); } [Test] + public void ImportReferencesTest () + { + var gen = new DummyTemplateGenerator (); + string tmp = null; + gen.ProcessTemplate (null, "<#@ assembly name=\"System.dll\" #>\n<#@ assembly name=\"System.Core.dll\" #>", ref tmp, out tmp); + Assert.AreEqual (0, gen.Errors.Count, "ImportReferencesTest"); + } + + [Test] public void Generate () { string Input = ParsingTests.ParseSample1; diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/Mono.TextTemplating.Tests.csproj b/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/Mono.TextTemplating.Tests.csproj index ed523be4cf..6cf7db406b 100644 --- a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/Mono.TextTemplating.Tests.csproj +++ b/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/Mono.TextTemplating.Tests.csproj @@ -44,6 +44,7 @@ <Compile Include="GenerateIndentedClassCodeTests.cs" /> <Compile Include="TextTemplatingSessionTests.cs" /> <Compile Include="EngineTests.cs" /> + <Compile Include="DummyTemplateGenerator.cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\Mono.TextTemplating\Mono.TextTemplating.csproj"> |