diff --git a/test/Microsoft.Framework.WebEncoders.Tests/CommonTestEncoder.cs b/test/Microsoft.Framework.WebEncoders.Tests/CommonTestEncoder.cs deleted file mode 100644 index 0d38957303..0000000000 --- a/test/Microsoft.Framework.WebEncoders.Tests/CommonTestEncoder.cs +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Globalization; -using System.IO; -using System.Runtime.CompilerServices; - -namespace Microsoft.Framework.WebEncoders -{ - /// - /// Dummy encoder used for unit testing. - /// - public sealed class CommonTestEncoder : IHtmlEncoder, IJavaScriptStringEncoder, IUrlEncoder - { - /// - /// Returns "HtmlEncode[[value]]". - /// - public string HtmlEncode(string value) - { - return EncodeCore(value); - } - - /// - /// Writes "HtmlEncode[[value]]". - /// - public void HtmlEncode(string value, int startIndex, int charCount, TextWriter output) - { - EncodeCore(value, startIndex, charCount, output); - } - - /// - /// Writes "HtmlEncode[[value]]". - /// - public void HtmlEncode(char[] value, int startIndex, int charCount, TextWriter output) - { - EncodeCore(value, startIndex, charCount, output); - } - - /// - /// Returns "JavaScriptStringEncode[[value]]". - /// - public string JavaScriptStringEncode(string value) - { - return EncodeCore(value); - } - - /// - /// Writes "JavaScriptStringEncode[[value]]". - /// - public void JavaScriptStringEncode(string value, int startIndex, int charCount, TextWriter output) - { - EncodeCore(value, startIndex, charCount, output); - } - - /// - /// Writes "JavaScriptStringEncode[[value]]". - /// - public void JavaScriptStringEncode(char[] value, int startIndex, int charCount, TextWriter output) - { - EncodeCore(value, startIndex, charCount, output); - } - - /// - /// Returns "UrlEncode[[value]]". - /// - public string UrlEncode(string value) - { - return EncodeCore(value); - } - - /// - /// Writes "UrlEncode[[value]]". - /// - public void UrlEncode(string value, int startIndex, int charCount, TextWriter output) - { - EncodeCore(value, startIndex, charCount, output); - } - - /// - /// Writes "UrlEncode[[value]]". - /// - public void UrlEncode(char[] value, int startIndex, int charCount, TextWriter output) - { - EncodeCore(value, startIndex, charCount, output); - } - - private static string EncodeCore(string value, [CallerMemberName] string encodeType = null) - { - return String.Format(CultureInfo.InvariantCulture, "{0}[[{1}]]", encodeType, value); - } - - private static void EncodeCore(string value, int startIndex, int charCount, TextWriter output, [CallerMemberName] string encodeType = null) - { - output.Write(EncodeCore(value.Substring(startIndex, charCount), encodeType)); - } - - private static void EncodeCore(char[] value, int startIndex, int charCount, TextWriter output, [CallerMemberName] string encodeType = null) - { - output.Write(EncodeCore(new string(value, startIndex, charCount), encodeType)); - } - } -} diff --git a/test/Microsoft.Framework.WebEncoders.Tests/EncoderServiceCollectionExtensionsTests.cs b/test/Microsoft.Framework.WebEncoders.Tests/EncoderServiceCollectionExtensionsTests.cs index d629184281..b8ddbef391 100644 --- a/test/Microsoft.Framework.WebEncoders.Tests/EncoderServiceCollectionExtensionsTests.cs +++ b/test/Microsoft.Framework.WebEncoders.Tests/EncoderServiceCollectionExtensionsTests.cs @@ -4,6 +4,7 @@ using System; using Xunit; using Microsoft.Framework.DependencyInjection; +using Microsoft.Framework.WebEncoders.Testing; namespace Microsoft.Framework.WebEncoders { diff --git a/test/Microsoft.Framework.WebEncoders.Tests/project.json b/test/Microsoft.Framework.WebEncoders.Tests/project.json index b24bd45764..4acf0c6ad2 100644 --- a/test/Microsoft.Framework.WebEncoders.Tests/project.json +++ b/test/Microsoft.Framework.WebEncoders.Tests/project.json @@ -2,6 +2,7 @@ "dependencies": { "Microsoft.Framework.DependencyInjection": "1.0.0-*", "Microsoft.Framework.WebEncoders": "1.0.0-*", + "Microsoft.Framework.WebEncoders.Testing": "1.0.0-*", "Moq": "4.2.1312.1622", "Newtonsoft.Json": "6.0.6", "xunit.runner.aspnet": "2.0.0-aspnet-*"