Skip to content

Commit

Permalink
Runtime for Silverlight (using MsTest and the Silverlight Unit Testin…
Browse files Browse the repository at this point in the history
…g Framework) created.
  • Loading branch information
unknown committed Jun 16, 2010
1 parent 7b69438 commit 13e0300
Show file tree
Hide file tree
Showing 38 changed files with 1,147 additions and 84 deletions.
9 changes: 9 additions & 0 deletions Generator/TechTalk.SpecFlow.Generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,18 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Runtime\Configuration\ConfigDefaults.cs">
<Link>Configuration\ConfigDefaults.cs</Link>
</Compile>
<Compile Include="..\Runtime\Configuration\ConfigurationSectionHandler.cs">
<Link>Configuration\ConfigurationSectionHandler.cs</Link>
</Compile>
<Compile Include="..\Runtime\Configuration\ConfigurationServices.cs">
<Link>Configuration\ConfigurationServices.cs</Link>
</Compile>
<Compile Include="..\Runtime\Configuration\MissingOrPendingStepsOutcome.cs">
<Link>Configuration\MissingOrPendingStepsOutcome.cs</Link>
</Compile>
<Compile Include="..\Runtime\StringExtensions.cs">
<Link>StringExtensions.cs</Link>
</Compile>
Expand Down
23 changes: 23 additions & 0 deletions Runtime.Silverlight/Compatibility/ConfigurationErrorsException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Net;
using System.Runtime.Serialization;


namespace System.Configuration
{
public class ConfigurationErrorsException : Exception
{
public ConfigurationErrorsException()
{
}

public ConfigurationErrorsException(string message) : base(message)
{
}

public ConfigurationErrorsException(string message, Exception inner)
: base(message, inner)
{
}
}
}
16 changes: 16 additions & 0 deletions Runtime.Silverlight/Compatibility/CultureInfoHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

namespace TechTalk.SpecFlow.Compatibility
{
internal static class CultureInfoHelper
{
public static CultureInfo GetCultureInfo(string cultureName)
{
return new CultureInfo(cultureName);
}
}
}
33 changes: 33 additions & 0 deletions Runtime.Silverlight/Compatibility/EnumHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

namespace TechTalk.SpecFlow.Compatibility
{
internal static class EnumHelper
{
public static Array GetValues(Type enumType)
{
if (!enumType.IsEnum)
{
throw new ArgumentException("Type '" + enumType.Name + "' is not an enum");
}

var values = new List<object>();

var fields = from field in enumType.GetFields()
where field.IsLiteral
select field;

foreach (FieldInfo field in fields)
{
object value = field.GetValue(enumType);
values.Add(value);
}

return values.ToArray();
}
}
}
113 changes: 113 additions & 0 deletions Runtime.Silverlight/Compatibility/Stopwatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
using System;

namespace System.Diagnostics
{
/// <summary>
/// Stopwatch is used to measure the general performance of Silverlight functionality. Silverlight
/// does not currently provide a high resolution timer as is available in many operating systems,
/// so the resolution of this timer is limited to milliseconds. This class is best used to measure
/// the relative performance of functions over many iterations.
/// </summary>
public sealed class Stopwatch
{
private long _startTick;
private long _elapsed;
private bool _isRunning;

/// <summary>
/// Creates a new instance of the class and starts the watch immediately.
/// </summary>
/// <returns>An instance of Stopwatch, running.</returns>
public static Stopwatch StartNew()
{
Stopwatch sw = new Stopwatch();
sw.Start();
return sw;
}

/// <summary>
/// Creates an instance of the Stopwatch class.
/// </summary>
public Stopwatch() { }

/// <summary>
/// Completely resets and deactivates the timer.
/// </summary>
public void Reset()
{
_elapsed = 0;
_isRunning = false;
_startTick = 0;
}

/// <summary>
/// Begins the timer.
/// </summary>
public void Start()
{
if (!_isRunning)
{
_startTick = GetCurrentTicks();
_isRunning = true;
}
}

/// <summary>
/// Stops the current timer.
/// </summary>
public void Stop()
{
if (_isRunning)
{
_elapsed += GetCurrentTicks() - _startTick;
_isRunning = false;
}
}

/// <summary>
/// Gets a value indicating whether the instance is currently recording.
/// </summary>
public bool IsRunning
{
get { return _isRunning; }
}

/// <summary>
/// Gets the Elapsed time as a Timespan.
/// </summary>
public TimeSpan Elapsed
{
get { return TimeSpan.FromMilliseconds(ElapsedMilliseconds); }
}

/// <summary>
/// Gets the Elapsed time as the total number of milliseconds.
/// </summary>
public long ElapsedMilliseconds
{
get { return GetCurrentElapsedTicks() / TimeSpan.TicksPerMillisecond; }
}

/// <summary>
/// Gets the Elapsed time as the total number of ticks (which is faked
/// as Silverlight doesn't have a way to get at the actual "Ticks")
/// </summary>
public long ElapsedTicks
{
get { return GetCurrentElapsedTicks(); }
}

private long GetCurrentElapsedTicks()
{
return (long)(this._elapsed + (IsRunning ? (GetCurrentTicks() - _startTick) : 0));
}

private long GetCurrentTicks()
{
// TickCount: Gets the number of milliseconds elapsed since the system started.
return Environment.TickCount * TimeSpan.TicksPerMillisecond;
}
}

}

20 changes: 20 additions & 0 deletions Runtime.Silverlight/Configuration/ConfigDefaults.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace TechTalk.SpecFlow.Configuration
{
public static class ConfigDefaults
{
internal const string FeatureLanguage = "en-US";
internal const string ToolLanguage = "";

internal const string UnitTestProviderName = "MSTestSilverlight";

internal const bool DetectAmbiguousMatches = true;
internal const bool StopAtFirstError = false;
internal const MissingOrPendingStepsOutcome MissingOrPendingStepsOutcome = TechTalk.SpecFlow.Configuration.MissingOrPendingStepsOutcome.Inconclusive;

internal const bool TraceSuccessfulSteps = true;
internal const bool TraceTimings = false;
internal const string MinTracedDuration = "0:0:0.1";

internal const bool AllowDebugGeneratedFiles = false;
}
}
35 changes: 35 additions & 0 deletions Runtime.Silverlight/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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("TechTalk.SpecFlow.Silverlight")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("TechTalk.SpecFlow.Silverlight")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
[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("04dec58a-9677-4f58-ae8b-4744bbffb9a9")]

// 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 Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading

0 comments on commit 13e0300

Please sign in to comment.