summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Test/TestUtilities.cs
blob: a52cde948730e25b22a907cd45f7f4c44c31621d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//-----------------------------------------------------------------------
// <copyright file="TestUtilities.cs" company="Outercurve Foundation">
//     Copyright (c) Outercurve Foundation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOpenAuth.Test {
	using System.Collections.Specialized;

	using DotNetOpenAuth.Logging;

	using Validation;

	/// <summary>
	/// An assortment of methods useful for testing.
	/// </summary>
	internal static class TestUtilities {
		/// <summary>
		/// The logger that tests should use.
		/// </summary>
		internal static readonly ILog TestLogger = LogProvider.GetLogger("DotNetOpenAuth.Test");

		internal static void ApplyTo(this NameValueCollection source, NameValueCollection target) {
			Requires.NotNull(source, "source");
			Requires.NotNull(target, "target");

			foreach (string header in source) {
				target[header] = source[header];
			}
		}

		internal static T Clone<T>(this T source) where T : NameValueCollection, new() {
			Requires.NotNull(source, "source");

			var result = new T();
			ApplyTo(source, result);
			return result;
		}
	}
}