Files
mono/mcs/class/System.ComponentModel.Composition/Tests/UnitTestFramework/System/UnitTesting/TestServices.cs
T
Miguel de Icaza e3f39fb13c Add MEF for .NET 4
svn path=/trunk/mcs/; revision=145695
2009-11-09 01:39:41 +00:00

30 lines
967 B
C#

// -----------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// -----------------------------------------------------------------------
using System;
using System.Reflection;
using System.Collections.Generic;
namespace System.UnitTesting
{
public static class TestServices
{
public static string GenerateRandomString()
{
return Guid.NewGuid().ToString().Replace('-', '_');
}
public static IEnumerable<TEnum> GetEnumValues<TEnum>() where TEnum : struct
{ // Silverlight 2.0 does not have Enum.GetValues()
// so we need to write our own
foreach (FieldInfo field in typeof(TEnum).GetFields())
{
if (!field.IsLiteral)
continue;
yield return (TEnum)field.GetRawConstantValue();
}
}
}
}