Commits

Johannes Rudolph committed f32ebc1

final slides, minimalistic build scripts

Comments (0)

Files changed (38)

 syntax: glob
 bin/**
 obj/**
+tools/xunit/**

Acceptance Testing mit SubSpec.pdf

Binary file added.

Acceptance Testing mit SubSpec.pptx

Binary file added.

SubSpecAcceptanceSample.6.5.TeamCity.user

-<Configuration>
-  <SettingsComponent>
-    <string>
-      <setting name="TeamCity.Toolbar.Shown">-TeamCity;</setting>
-    </string>
-    <integer />
-    <boolean>
-      <setting name="TeamCity.ServerChangesView.Visible">False</setting>
-    </boolean>
-  </SettingsComponent>
-</Configuration>

SubSpecAcceptanceSample.Tests/Demo.cs

+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Xunit;
+using System.IO;
+using System.Drawing;
+using SubSpec;
+
+namespace SubSpecAcceptanceSample.Tests
+{
+    public class Demo
+    {
+        [Fact]
+        public void TestMethod()
+        {
+            var sut = new Stack<int>();
+
+            sut.Push( 42 );
+
+            Assert.Equal( 42, sut.Pop() );
+        }
+
+        [Fact]
+        public void UserStoryScaleAndHost()
+        {
+            using (var directoryFixture = new TemporaryDirectoryFixture())
+            {
+                // -> Arrange
+                ImageScalingService sut = sut = new ImageScalingService( directoryFixture.DirectoryPath );
+                Customer customer = new Customer();
+
+                var desiredScalesPercent = new [] { 25, 10, 35 };
+                var sourceImage = Resource1.World_TLD_Map;
+
+                ScaleJob job = new ScaleJob( customer, sourceImage, desiredScalesPercent );
+                
+                // -> Act
+                sut.ProcessScaleJob( job );
+
+                // -> Assert
+                // 1. Observable effect: 3 images generated
+                Assert.Equal( 3, Directory.GetFiles( directoryFixture.DirectoryPath ).Count() );
+            }
+        }
+
+        [Fact]
+        public void UserStoryScaleAndCharge()
+        {
+            using (var directoryFixture = new TemporaryDirectoryFixture())
+            {
+                // -> Arrange
+                ImageScalingService sut = sut = new ImageScalingService( directoryFixture.DirectoryPath );
+                Customer customer = new Customer();
+
+                var desiredScalesPercent = new[] { 25, 10, 35 };
+                var sourceImage = Resource1.World_TLD_Map;
+
+                ScaleJob job = new ScaleJob( customer, sourceImage, desiredScalesPercent );
+
+                // -> Act
+                sut.ProcessScaleJob( job );
+
+                // -> Assert
+                // 2. Observable effect: Customer charged
+                Assert.Equal( -ImageScalingService.CostPerScale * desiredScalesPercent.Length, customer.Balance );
+            }
+        }
+
+        [Specification]
+        public static void ImageScalingServiceSpecification()
+        {
+            ImageScalingService sut = default( ImageScalingService );
+            TemporaryDirectoryFixture directoryFixture = default( TemporaryDirectoryFixture );
+
+            ScaleJob job = default( ScaleJob );
+
+            "Given an Image Generator outputting to a fixed directory and a scale job"
+                .ContextFixture( () =>
+                {
+                    directoryFixture = new TemporaryDirectoryFixture();
+
+                    sut = new ImageScalingService( directoryFixture.DirectoryPath );
+
+                    job = new ScaleJob( new Customer(), Resource1.World_TLD_Map, new int[] { 25, 50, 75, 100 } );
+
+                    return directoryFixture;
+                } );
+
+            "when we ask the service to scale all images"
+                .Do( () =>
+                    sut.ProcessScaleJob( job ) );
+
+            "We expect 4 size variations of this image have been generated"
+                .Observation( () =>
+                    Assert.Equal( 4, Directory.GetFiles( directoryFixture.DirectoryPath ).Count() ) );
+
+            // Implement as Observation so we do not need to do the scaling again
+            "we expect the customer has been charged"
+                .Observation( () =>
+                    Assert.Equal( -ImageScalingService.CostPerScale * job.DesiredScalesPercent.Length, job.Customer.Balance ) );
+        }
+    }
+}

SubSpecAcceptanceSample.Tests/Final/SpecificationIntroduction.cs

+using System;
+using System.Collections.Generic;
+using System.Linq;
+using SubSpec;
+using Xunit;
+using Xunit.Extensions;
+
+namespace SubSpecAcceptanceSample
+{
+    public class SpecificationIntroduction
+    {
+        [Specification]
+        public void SimpleSpecification()
+        {
+            // variable captured in closure. default value necessary to mitigate warnings
+            var sut = default(Stack<int>);
+
+            "Given a new stack"
+                .Context(() =>
+                    sut = new Stack<int>());
+
+            "with an element pushed onto it"
+                .Do(() =>
+                    sut.Push(11));
+
+            // Let one of these fail to see the full test name in the log
+            "expect the stack is not empty"
+                .Assert(() =>
+                    Assert.True(sut.Any()));
+
+            "expect the stacks Top is the pushed element"
+                .Assert(() =>
+                {
+                    var top = sut.Peek();
+                    Assert.Equal(11, top);
+                });
+        }
+
+		[Theory]
+		[InlineData( 1 )]
+		[InlineData( 2 )]
+		public void Theory(int n)
+		{
+			Console.WriteLine(n);
+		}
+    }
+}

SubSpecAcceptanceSample.Tests/Final/Specifications.cs

+using System;
+using System.Collections.Generic;
+using System.Linq;
+using SubSpec;
+using System.IO;
+using Xunit;
+using System.Drawing;
+using Xunit.Extensions;
+
+namespace SubSpecAcceptanceSample
+{
+	public class Specifications
+	{
+		// Start with a simple fact
+		[Fact]
+        public void ImageGeneratorFact()
+        {
+            using (var directoryFixture = new TemporaryDirectoryFixture())
+            {
+                ImageScalingService sut = sut = new ImageScalingService( directoryFixture.DirectoryPath );
+                Customer customer = new Customer();
+
+                int[] desiredScalesPercent = new int[] { 25, 10, 35 };
+                Bitmap sourceImage = Resources.World_TLD_Map;
+
+                ScaleJob job = new ScaleJob( customer, sourceImage, desiredScalesPercent );
+                
+                sut.ProcessScaleJob( job );
+
+                // 1. Observable effect: 4 images generated
+                Assert.Equal( 4, Directory.GetFiles( directoryFixture.DirectoryPath ).Count() );
+
+                // 2. Observable effect: Customer charged
+                Assert.Equal( -ImageScalingService.CostPerScale * desiredScalesPercent.Length, customer.Balance );
+            }
+        }
+
+		[Specification]
+		public static void ImageScalingServiceSpecification()
+		{
+			ImageScalingService sut = default( ImageScalingService );
+			TemporaryDirectoryFixture directoryFixture = default( TemporaryDirectoryFixture );
+
+			ScaleJob job = default( ScaleJob );
+
+			"Given an Image Generator outputting to a fixed directory and a scale job"
+				.ContextFixture( () =>
+				{
+					directoryFixture = new TemporaryDirectoryFixture();
+
+					sut = new ImageScalingService( directoryFixture.DirectoryPath );
+
+					job = new ScaleJob( new Customer(), Resources.World_TLD_Map, new int[] { 25, 50, 75, 100 } );
+
+					return directoryFixture;
+				} );
+
+			"when we ask the service to scale all images"
+				.Do( () =>
+					sut.ProcessScaleJob( job ) );
+
+			"We expect 4 size variations of this image have been generated"
+				.Observation( () =>
+					Assert.Equal( 4, Directory.GetFiles( directoryFixture.DirectoryPath ).Count() ) );
+
+			// Implement as Observation so we do not need to do the scaling again
+			"we expect the customer has been charged"
+				.Observation( () =>
+					Assert.Equal( -ImageScalingService.CostPerScale * job.DesiredScalesPercent.Length, job.Customer.Balance ) );
+		}
+
+		[Thesis]
+		[InlineData( new int[] { 10 } )]
+		[InlineData( new int[] { 10, 25 } )]
+		public static void ImageScalerThesis( int[] scales )
+		{
+			ImageScalingService sut = default( ImageScalingService );
+			TemporaryDirectoryFixture directoryFixture = default( TemporaryDirectoryFixture );
+
+			ScaleJob job = default( ScaleJob );
+
+			string.Format( "Given an Image Generator outputting to a fixed directory and a scale job of {0} scales", scales.Length )
+				.ContextFixture( () =>
+				{
+					directoryFixture = new TemporaryDirectoryFixture();
+
+					sut = new ImageScalingService( directoryFixture.DirectoryPath );
+
+					job = new ScaleJob( new Customer(), Resources.World_TLD_Map, scales );
+
+					return directoryFixture;
+				} );
+
+			"when we ask the service to scale all images"
+				.Do( () =>
+					sut.ProcessScaleJob( job ) );
+
+			string.Format( "we expect {0} images have been generated", scales.Length )
+				.Observation( () =>
+					Assert.Equal( scales.Length, Directory.GetFiles( directoryFixture.DirectoryPath ).Count() ) );
+
+			string.Format( "we expect the customer has been charged for {0} scales", scales.Length )
+				.Observation( () =>
+					Assert.Equal( -ImageScalingService.CostPerScale * job.DesiredScalesPercent.Length, job.Customer.Balance ) );
+		}
+	}
+}

SubSpecAcceptanceSample.Tests/Properties/AssemblyInfo.cs

+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( "SubSpecAcceptanceSample.Tests" )]
+[assembly: AssemblyDescription( "" )]
+[assembly: AssemblyConfiguration( "" )]
+[assembly: AssemblyCompany( "" )]
+[assembly: AssemblyProduct( "SubSpecAcceptanceSample.Tests" )]
+[assembly: AssemblyCopyright( "Copyright ©  2011" )]
+[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( "9fe0ec9f-b325-4144-a504-c685fd3dc874" )]
+
+// 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 Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion( "1.0.0.0" )]
+[assembly: AssemblyFileVersion( "1.0.0.0" )]

SubSpecAcceptanceSample.Tests/Resource1.Designer.cs

+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.235
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace SubSpecAcceptanceSample.Tests {
+    using System;
+    
+    
+    /// <summary>
+    ///   A strongly-typed resource class, for looking up localized strings, etc.
+    /// </summary>
+    // This class was auto-generated by the StronglyTypedResourceBuilder
+    // class via a tool like ResGen or Visual Studio.
+    // To add or remove a member, edit your .ResX file then rerun ResGen
+    // with the /str option, or rebuild your VS project.
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    internal class Resource1 {
+        
+        private static global::System.Resources.ResourceManager resourceMan;
+        
+        private static global::System.Globalization.CultureInfo resourceCulture;
+        
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal Resource1() {
+        }
+        
+        /// <summary>
+        ///   Returns the cached ResourceManager instance used by this class.
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Resources.ResourceManager ResourceManager {
+            get {
+                if (object.ReferenceEquals(resourceMan, null)) {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SubSpecAcceptanceSample.Tests.Resource1", typeof(Resource1).Assembly);
+                    resourceMan = temp;
+                }
+                return resourceMan;
+            }
+        }
+        
+        /// <summary>
+        ///   Overrides the current thread's CurrentUICulture property for all
+        ///   resource lookups using this strongly typed resource class.
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Globalization.CultureInfo Culture {
+            get {
+                return resourceCulture;
+            }
+            set {
+                resourceCulture = value;
+            }
+        }
+        
+        internal static System.Drawing.Bitmap World_TLD_Map {
+            get {
+                object obj = ResourceManager.GetObject("World_TLD_Map", resourceCulture);
+                return ((System.Drawing.Bitmap)(obj));
+            }
+        }
+    }
+}

SubSpecAcceptanceSample.Tests/Resource1.resx

+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+  <data name="World_TLD_Map" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>Resources\World_TLD_Map.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+  </data>
+</root>

SubSpecAcceptanceSample.Tests/Resources/World_TLD_Map.jpg

Added
New image

SubSpecAcceptanceSample.Tests/SubSpec/LICENSE.txt

+This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.
+
+1. Definitions
+
+The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.
+
+A "contribution" is the original software, or any additions or changes to the software.
+
+A "contributor" is any person that distributes its contribution under this license.
+
+"Licensed patents" are a contributor's patent claims that read directly on its contribution.
+
+2. Grant of Rights
+
+(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
+
+(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
+
+3. Conditions and Limitations
+
+(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
+
+(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.
+
+(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.
+
+(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.
+
+(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.

SubSpecAcceptanceSample.Tests/SubSpec/SubSpec.Thesis.cs

+using System;
+using System.Collections.Generic;
+using Xunit.Sdk;
+using Xunit.Extensions;
+
+namespace SubSpec
+{
+    [AttributeUsage( AttributeTargets.Method, AllowMultiple = false, Inherited = true )]
+    public class ThesisAttribute : TheoryAttribute
+    {
+        protected override IEnumerable<ITestCommand> EnumerateTestCommands( IMethodInfo method )
+        {
+            // prepare specification invocations  
+            var theoryTestCommands = base.EnumerateTestCommands( method );
+
+            var commands = new List<ITestCommand>();
+
+            foreach (var item in theoryTestCommands)
+            {
+                if (item is TheoryCommand)
+                {
+                    commands.AddRange( SubSpec.Core.SpecificationContext.SafelyEnumerateTestCommands( method,
+                        m =>
+                        {
+                            // Create a new test class instance
+                            object obj = item.ShouldCreateInstance ? Activator.CreateInstance( method.MethodInfo.ReflectedType ) : null;
+                            
+                            // create method
+                            item.Execute( obj );
+                        } ) );
+
+                }
+                else
+                {
+                    commands.Clear();
+                    commands.Add( item );
+                    break;
+                }
+            }
+
+            return commands;
+        }
+    }
+}

SubSpecAcceptanceSample.Tests/SubSpec/SubSpec.cs

+using System;
+using System.Collections.Generic;
+using System.Text;
+using Xunit;
+using Xunit.Sdk;
+using System.Xml;
+using System.Diagnostics;
+using System.Reflection;
+using System.Linq;
+
+namespace SubSpec
+{
+    /// <remarks>
+    /// We declare our own delegate instead of using Func 
+    /// because we can't use implicit covariance on the generic type parameter in .net 3.5"/>
+    /// </remarks>
+    public delegate IDisposable ContextDelegate();
+
+    public class DisposableAction : IDisposable
+    {
+        public static readonly DisposableAction None = new DisposableAction( () => { } );
+
+        private readonly Action _action;
+
+        public DisposableAction( Action action )
+        {
+            if (action == null)
+                throw new ArgumentNullException( "action" );
+
+            _action = action;
+        }
+
+        public void Dispose()
+        {
+            _action();
+        }
+    }
+
+    public interface ISpecificationPrimitive
+    {
+        /// <summary>
+        /// Indicate that execution of this delegate should be canceled after a specified timeout.
+        /// </summary>
+        /// <param name="timeoutMs">The timeout in milliseconds.</param>
+        ISpecificationPrimitive WithTimeout( int timeoutMs );
+    }
+
+    internal static class Core
+    {
+        private class SpecificationPrimitive<T> : ISpecificationPrimitive
+        {
+            private readonly string _message;
+            private readonly T _action;
+            private int _timeoutMs;
+
+            /// <summary>
+            /// Initializes a new instance of the Context class.
+            /// </summary>
+            /// <param name="message"></param>
+            /// <param name="action"></param>
+            public SpecificationPrimitive( string message, T action )
+            {
+                if (message == null)
+                    throw new ArgumentNullException( "message" );
+                if (action == null)
+                    throw new ArgumentNullException( "action" );
+
+                _message = message;
+                _action = action;
+            }
+
+            public string Message
+            {
+                get { return _message; }
+            }
+            public T ActionDelegate
+            {
+                get { return _action; }
+            }
+            public int TimeoutMs
+            {
+                get { return _timeoutMs; }
+            }
+
+            public ISpecificationPrimitive WithTimeout( int timeoutMs )
+            {
+                _timeoutMs = timeoutMs;
+                return this;
+            }
+        }
+
+        private static class SpecificationPrimitiveExecutor
+        {
+            public static void Execute( SpecificationPrimitive<Action> primitive )
+            {
+                Debug.Assert( primitive.ActionDelegate != null );
+
+                if (primitive.TimeoutMs > 0)
+                {
+#if SILVERLIGHT
+                IAsyncResult asyncResult = AsyncDelegatesCompatibility.WorkingBeginInvoke( primitive.ActionDelegate, null, null );
+#else
+                    IAsyncResult asyncResult = primitive.ActionDelegate.BeginInvoke( null, null );
+#endif
+
+                    if (!asyncResult.AsyncWaitHandle.WaitOne( primitive.TimeoutMs ))
+                        throw new Xunit.Sdk.TimeoutException( primitive.TimeoutMs );
+                    else
+                    {
+#if SILVERLIGHT
+                    primitive.ActionDelegate.WorkingEndInvoke( asyncResult );
+#else
+                        primitive.ActionDelegate.EndInvoke( asyncResult );
+#endif
+
+                    }
+                }
+                else
+                    primitive.ActionDelegate();
+            }
+
+            public static IDisposable Execute( SpecificationPrimitive<ContextDelegate> primitive )
+            {
+                Debug.Assert( primitive.ActionDelegate != null );
+
+                if (primitive.TimeoutMs > 0)
+                {
+#if SILVERLIGHT
+                IAsyncResult asyncResult = AsyncDelegatesCompatibility.WorkingBeginInvoke( primitive.ActionDelegate, null, null );
+#else
+                    IAsyncResult asyncResult = primitive.ActionDelegate.BeginInvoke( null, null );
+#endif
+
+                    if (!asyncResult.AsyncWaitHandle.WaitOne( primitive.TimeoutMs ))
+                        throw new Xunit.Sdk.TimeoutException( primitive.TimeoutMs );
+                    else
+                    {
+#if SILVERLIGHT
+                    return (IDisposable)primitive.ActionDelegate.WorkingEndInvoke( asyncResult );
+#else
+                        return primitive.ActionDelegate.EndInvoke( asyncResult );
+#endif
+
+                    }
+                }
+                else
+                    return primitive.ActionDelegate();
+            }
+        }
+
+        private class ActionTestCommand : TestCommand, ITestCommand
+        {
+            private readonly Action _action;
+
+            public ActionTestCommand( IMethodInfo method, string name, int timeout, Action action )
+                : base( method, name, timeout )
+            {
+                _action = action;
+            }
+
+            public override MethodResult Execute( object testClass )
+            {
+                try
+                {
+                    _action();
+                    return new PassedResult( testMethod, DisplayName );
+                }
+                catch (Exception ex)
+                {
+                    return new FailedResult( testMethod, ex, DisplayName );
+                }
+            }
+        }
+
+        private class ExceptionTestCommand : ActionTestCommand
+        {
+            public ExceptionTestCommand( IMethodInfo method, Xunit.Assert.ThrowsDelegate action )
+                : base( method, null, 0, () => action() )
+            {
+            }
+
+            public override bool ShouldCreateInstance
+            {
+                get { return false; }
+            }
+        }
+
+        private class AssertExecutor
+        {
+            private readonly List<SpecificationPrimitive<Action>> _asserts;
+            private readonly SpecificationPrimitive<ContextDelegate> _context;
+            private readonly SpecificationPrimitive<Action> _do;
+
+            public AssertExecutor( SpecificationPrimitive<ContextDelegate> context, SpecificationPrimitive<Action> @do, List<SpecificationPrimitive<Action>> asserts )
+            {
+                _asserts = asserts;
+                _context = context;
+                _do = @do;
+            }
+
+            public IEnumerable<ITestCommand> AssertCommands( string name, IMethodInfo method )
+            {
+                foreach (var assertion in _asserts)
+                {
+                    // do not capture the iteration variable because 
+                    // all tests would point to the same assertion
+                    var capturableAssertion = assertion;
+                    Action test =
+                        () =>
+                        {
+                            using (SpecificationPrimitiveExecutor.Execute( _context ))
+                            {
+                                if (_do != null)
+                                    SpecificationPrimitiveExecutor.Execute( _do );
+
+                                SpecificationPrimitiveExecutor.Execute( capturableAssertion );
+                            }
+                        };
+
+                    string testDescription = String.Format( "{0}, {1}", name, assertion.Message );
+
+                    yield return new ActionTestCommand( method, testDescription, MethodUtility.GetTimeoutParameter( method ), test );
+                }
+            }
+        }
+
+        private class ObservationExecutor
+        {
+            private readonly IEnumerable<SpecificationPrimitive<Action>> _observations;
+            private readonly SpecificationPrimitive<ContextDelegate> _context;
+            private readonly SpecificationPrimitive<Action> _do;
+
+            public ObservationExecutor( SpecificationPrimitive<ContextDelegate> context, SpecificationPrimitive<Action> @do, IEnumerable<SpecificationPrimitive<Action>> observations )
+            {
+                _observations = observations;
+                _context = context;
+                _do = @do;
+            }
+
+            public IEnumerable<ITestCommand> ObservationCommands( string name, IMethodInfo method )
+            {
+                if (_observations.Count() == 0)
+                    yield break;
+
+                bool setupExceptionOccurred = false;
+                IDisposable systemUnderTest = default( IDisposable );
+
+                Action setupAction = () =>
+                {
+                    try
+                    {
+                        systemUnderTest = SpecificationPrimitiveExecutor.Execute( _context );
+
+                        if (_do != null)
+                            SpecificationPrimitiveExecutor.Execute( _do );
+                    }
+                    catch (Exception)
+                    {
+                        setupExceptionOccurred = true;
+                        throw;
+                    }
+                };
+
+                yield return new ActionTestCommand( method, "{ " + name, 0, setupAction );
+
+                foreach (var observation in _observations)
+                {
+                    // do not capture the iteration variable because 
+                    // all tests would point to the same observation
+                    var capturableObservation = observation;
+                    Action perform = () =>
+                    {
+                        if (setupExceptionOccurred)
+                            throw new ContextSetupFailedException( "Setting up Context failed" );
+
+                        SpecificationPrimitiveExecutor.Execute( capturableObservation );
+                    };
+
+                    yield return new ActionTestCommand( method, "\t- " + capturableObservation.Message, 0, perform );
+                }
+
+                Action tearDownAction = () =>
+                {
+                    if (systemUnderTest != null)
+                        systemUnderTest.Dispose();
+
+                    if (setupExceptionOccurred)
+                        throw new ContextSetupFailedException( "Setting up Context failed, but Fixtures were disposed." );
+                };
+
+                yield return new ActionTestCommand( method, "} " + name, 0, tearDownAction );
+            }
+        }
+
+        /// <summary>
+        /// An exception that is thrown from Observations or their teardown whenever the corresponding setup failed.
+        /// </summary>
+        private class ContextSetupFailedException : Exception
+        {
+            public ContextSetupFailedException( string message ) : base( message ) { }
+        }
+
+        internal static class SpecificationContext
+        {
+            [ThreadStatic]
+            private static bool _threadStaticInitialized;
+            [ThreadStatic]
+            private static SpecificationPrimitive<ContextDelegate> _context;
+            [ThreadStatic]
+            private static SpecificationPrimitive<Action> _do;
+            [ThreadStatic]
+            private static List<SpecificationPrimitive<Action>> _asserts;
+            [ThreadStatic]
+            private static List<SpecificationPrimitive<Action>> _observations;
+            [ThreadStatic]
+            private static List<SpecificationPrimitive<Action>> _skips;
+            [ThreadStatic]
+            private static List<Action> _exceptions;
+
+            private static void Reset()
+            {
+                _exceptions = new List<Action>();
+                _context = null;
+                _do = null;
+                _asserts = new List<SpecificationPrimitive<Action>>();
+                _observations = new List<SpecificationPrimitive<Action>>();
+                _skips = new List<SpecificationPrimitive<Action>>();
+            }
+
+            private static void EnsureThreadStaticInitialized()
+            {
+                if (_threadStaticInitialized)
+                    return;
+
+                Reset();
+                _threadStaticInitialized = true;
+            }
+
+            public static ISpecificationPrimitive Context( string message, ContextDelegate arrange )
+            {
+                EnsureThreadStaticInitialized();
+
+                if (_context == null)
+                    _context = new SpecificationPrimitive<ContextDelegate>( message, arrange );
+                else
+                    _exceptions.Add( () => { throw new InvalidOperationException( "Cannot have more than one Context statement in a specification" ); } );
+
+                return _context;
+            }
+
+            public static ISpecificationPrimitive Do( string message, Action doAction )
+            {
+                EnsureThreadStaticInitialized();
+
+                if (_do == null)
+                    _do = new SpecificationPrimitive<Action>( message, doAction );
+                else
+                    _exceptions.Add( () => { throw new InvalidOperationException( "Cannot have more than one Do statement in a specification" ); } );
+
+                return _do;
+            }
+
+            public static ISpecificationPrimitive Assert( string message, Action assertAction )
+            {
+                EnsureThreadStaticInitialized();
+
+                SpecificationPrimitive<Action> assert = new SpecificationPrimitive<Action>( message, assertAction );
+                _asserts.Add( assert );
+
+                return assert;
+            }
+
+            public static ISpecificationPrimitive Observation( string message, Action observationAction )
+            {
+                EnsureThreadStaticInitialized();
+
+                var observation = new SpecificationPrimitive<Action>( message, observationAction );
+                _observations.Add( observation );
+
+                return observation;
+            }
+
+            public static ISpecificationPrimitive Todo( string message, Action skippedAction )
+            {
+                EnsureThreadStaticInitialized();
+
+                SpecificationPrimitive<Action> skip = new SpecificationPrimitive<Action>( message, skippedAction );
+                _skips.Add( skip );
+
+                return skip;
+            }
+
+            private static string PrepareSetupDescription()
+            {
+                string name = _context.Message;
+
+                if (_do != null)
+                    name += " " + _do.Message;
+                return name;
+            }
+
+            public static IEnumerable<ITestCommand> SafelyEnumerateTestCommands( IMethodInfo method, Action<IMethodInfo> registerPrimitives )
+            {
+                try
+                {
+                    registerPrimitives( method );
+
+                    IEnumerable<ITestCommand> testCommands = SpecificationContext.BuildCommandsFromRegisteredPrimitives( method );
+
+                    return testCommands;
+                }
+                catch (Exception ex)
+                {
+                    return new ITestCommand[] {
+                        new SubSpec.Core.ExceptionTestCommand(method, () =>
+                          {
+                                              		throw new InvalidOperationException(string.Format("An exception was thrown while building tests from Specification {0}.{1}:\r\n" + ex.ToString(), 
+                                                                                            method.TypeName, 
+                                                                                            method.Name));
+                                              })};
+                }
+            }
+
+            private static IEnumerable<ITestCommand> BuildCommandsFromRegisteredPrimitives( IMethodInfo method )
+            {
+                EnsureThreadStaticInitialized();
+
+                try
+                {
+                    var validationException = ValidateSpecification( method );
+                    if (validationException != null)
+                    {
+                        yield return validationException;
+                        yield break;
+                    }
+
+                    int testsReturned = 0;
+                    string name = PrepareSetupDescription();
+
+                    var ax = new AssertExecutor( _context, _do, _asserts );
+                    foreach (var item in ax.AssertCommands( name, method ))
+                    {
+                        yield return item;
+                        testsReturned++;
+                    }
+
+                    var ox = new ObservationExecutor( _context, _do, _observations );
+                    foreach (var item in ox.ObservationCommands( name, method ))
+                    {
+                        yield return item;
+                        testsReturned++;
+                    }
+                                                                                                                                     
+                    foreach (var item in SkipCommands( name, method ))
+                    {
+                        yield return item;
+                        testsReturned++;
+                    }
+
+                    if (testsReturned == 0)
+                        yield return new ExceptionTestCommand( method, () => { throw new InvalidOperationException( "Must have at least one Assert or Observation in each specification" ); } );
+                }
+                finally
+                {
+                    Reset();
+                }
+            }
+
+            private static ExceptionTestCommand ValidateSpecification( IMethodInfo method )
+            {
+                if (_context == null)
+                    _exceptions.Add( () => { throw new InvalidOperationException( "Must have a Context in each specification" ); } );
+
+                // check if we have any recorded exceptions
+                if (_exceptions.Count > 0)
+                {
+                    // throw the first recorded exception, preserves stacktraces nicely.
+                    return new ExceptionTestCommand( method, () => _exceptions[0]() );
+                }
+
+                return null;
+            }
+
+            private static IEnumerable<ITestCommand> SkipCommands( string name, IMethodInfo method )
+            {
+                foreach (var kvp in _skips)
+                    yield return new SkipCommand( method, name + ", " + kvp.Message, "Action is Todo (instead of Observation or Assert)" );
+            }
+        }
+    }
+
+    [AttributeUsage( AttributeTargets.Method, AllowMultiple = false, Inherited = true )]
+    public class SpecificationAttribute : FactAttribute
+    {
+        protected override IEnumerable<ITestCommand> EnumerateTestCommands( IMethodInfo method )
+        {
+            return SubSpec.Core.SpecificationContext.SafelyEnumerateTestCommands( method, RegisterSpecificationPrimitives);
+        }
+
+        public static IEnumerable<ITestCommand> FtoEnumerateTestCommands( IMethodInfo method )
+        {
+            return SubSpec.Core.SpecificationContext.SafelyEnumerateTestCommands( method, RegisterSpecificationPrimitives );
+        }
+
+        private static void RegisterSpecificationPrimitives( IMethodInfo method )
+        {
+            if (method.IsStatic)
+                method.Invoke( null, null );
+            else
+            {
+                ConstructorInfo defaultConstructor = method.MethodInfo.ReflectedType.GetConstructor( Type.EmptyTypes );
+
+                if (defaultConstructor == null)
+                    throw new InvalidOperationException( "Specification class does not have a default constructor" );
+
+                object instance = defaultConstructor.Invoke( null );
+                method.Invoke( instance, null );
+            }
+        }
+    }
+
+    /// <summary>
+    /// Provides extensions for a fluent specification syntax
+    /// </summary>
+    public static class SpecificationExtensions
+    {
+        private const string IDisposableHintMessaage = "Your context implements IDisposable. Use ContextFixture() to have its lifecycle managed by SubSpec.";
+
+        /// <summary>
+        /// Records a context setup for this specification.
+        /// </summary>
+        /// <param name="message">A message describing the established context.</param>
+        /// <param name="arrange">The action that will establish the context.</param>
+        public static ISpecificationPrimitive Context( this string message, Action arrange )
+        {
+            return SubSpec.Core.SpecificationContext.Context( message,
+                                          () =>
+                                          {
+                                              arrange();
+                                              return DisposableAction.None;
+                                          } );
+        }
+
+        /// <summary>
+        /// Trap for using contexts implementing IDisposable with the wrong overload.
+        /// </summary>
+        /// <param name="message">A message describing the established context.</param>
+        /// <param name="arrange">The action that will establish and return the context for this test.</param>
+        [Obsolete( IDisposableHintMessaage )]
+        public static void Context( this string message, ContextDelegate arrange )
+        {
+            throw new InvalidOperationException( IDisposableHintMessaage );
+        }
+
+        /// <summary>
+        /// Records a disposable context for this specification. The context lifecycle will be managed by SubSpec.
+        /// </summary>
+        /// <param name="message">A message describing the established context.</param>
+        /// <param name="arrange">The action that will establish and return the context for this test.</param>
+        public static ISpecificationPrimitive ContextFixture( this string message, ContextDelegate arrange )
+        {
+            return SubSpec.Core.SpecificationContext.Context( message, arrange );
+        }
+
+        /// <summary>
+        /// Records an action to be performed on the context for this specification.
+        /// </summary>
+        /// <param name="message">A message describing the action.</param>
+        /// <param name="arrange">The action to perform.</param>
+        public static ISpecificationPrimitive Do( this string message, Action act )
+        {
+            return SubSpec.Core.SpecificationContext.Do( message, act );
+        }
+
+        /// <summary>
+        /// Records an assertion for this specification.
+        /// Each assertion is executed on an isolated context.
+        /// </summary>
+        /// <param name="message">A message describing the expected result.</param>
+        /// <param name="assert">The action that will verify the expectation.</param>
+        public static ISpecificationPrimitive Assert( this string message, Action assert )
+        {
+            return SubSpec.Core.SpecificationContext.Assert( message, assert );
+        }
+
+        /// <summary>
+        /// Records an observation for this specification.
+        /// All observations are executed on the same context.
+        /// </summary>
+        /// <param name="message">A message describing the expected result.</param>
+        /// <param name="observation">The action that will verify the expectation.</param>
+        public static ISpecificationPrimitive Observation( this string message, Action observation )
+        {
+            return SubSpec.Core.SpecificationContext.Observation( message, observation );
+        }
+
+        /// <summary>
+        /// Records a skipped assertion for this specification.
+        /// </summary>
+        /// <param name="message">A message describing the expected result.</param>
+        /// <param name="skippedAction">The action that will verify the expectation.</param>
+        public static ISpecificationPrimitive Todo( this string message, Action skippedAction )
+        {
+            return SubSpec.Core.SpecificationContext.Todo( message, skippedAction );
+        }
+    }
+}

SubSpecAcceptanceSample.Tests/SubSpec/SubSpecUtils.cs

+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Collections;
+using System.Collections.ObjectModel;
+
+namespace SubSpec
+{
+    internal abstract class TheoryDataProvider : IEnumerable<object[]>
+    {
+        public IEnumerator<object[]> GetEnumerator()
+        {
+            return DataSource().GetEnumerator();
+        }
+
+        IEnumerator IEnumerable.GetEnumerator()
+        {
+            return DataSource().GetEnumerator();
+        }
+
+        protected abstract IEnumerable<object[]> DataSource();
+    }
+
+    internal abstract class SingleItemTheoryDataProvider : TheoryDataProvider
+    {
+        protected override sealed IEnumerable<object[]> DataSource()
+        {
+            return SingleItemDataSource().Select( x => new[] { x } );
+        }
+
+        protected abstract IEnumerable<object> SingleItemDataSource();
+    }
+
+    /// <summary>
+    /// Use this class in conjunction with ContextFixture() method to return a disposable object containing a list of all 
+    /// objects that need to be disposed that were created within your ContextFixture. 
+    /// </summary>
+    internal class CompositeFixture : List<IDisposable>, IDisposable
+    {
+        /// <summary>
+        /// Disposes all registered items in reversed order than items have been added.
+        /// </summary>
+        public void Dispose()
+        {
+            var _exceptions = new List<Exception>();
+            foreach (var disposable in Enumerable.Reverse( this ))
+                try
+                {
+                    disposable.Dispose();
+                }
+                catch (Exception exception)
+                {
+                    _exceptions.Add( exception );
+                }
+
+            // Always throw AggregateException, prevents stack trace loss without us having
+            // to resort on reflection hacks to preserve stack traces.
+            if (_exceptions.Count > 0)
+                throw new AggregateException( _exceptions );
+        }
+
+        // Nested as want to use one in TPL when on FX4
+        internal class AggregateException : Exception
+        {
+            public AggregateException( IEnumerable<Exception> exceptions )
+            {
+                InnerExceptions = new ReadOnlyCollection<Exception>( exceptions.ToList() );
+            }
+
+            public ReadOnlyCollection<Exception> InnerExceptions { get; private set; }
+
+            public override string ToString()
+            {
+                string splitter = Environment.NewLine + "\t";
+                return "AggregateException:" + splitter + string.Join( splitter, InnerExceptions.Select( _ => _.ToString() ).ToArray() );
+            }
+        }
+    }
+}

SubSpecAcceptanceSample.Tests/SubSpecAcceptanceSample.Tests.csproj

+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{57725236-30F3-4AB1-A760-03D09EE146D4}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>SubSpecAcceptanceSample.Tests</RootNamespace>
+    <AssemblyName>SubSpecAcceptanceSample.Tests</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+    <Reference Include="xunit">
+      <HintPath>..\packages\xunit.1.8.0.1545\lib\xunit.dll</HintPath>
+    </Reference>
+    <Reference Include="xunit.extensions">
+      <HintPath>..\packages\xunit.extensions.1.8.0.1545\lib\xunit.extensions.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Demo.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Resource1.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+      <DependentUpon>Resource1.resx</DependentUpon>
+    </Compile>
+    <Compile Include="SubSpec\SubSpec.cs" />
+    <Compile Include="SubSpec\SubSpec.Thesis.cs" />
+    <Compile Include="SubSpec\SubSpecUtils.cs" />
+    <Compile Include="TemporaryDirectoryFixture.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="Resources\World_TLD_Map.jpg" />
+    <Content Include="SubSpec\LICENSE.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\SubSpecAcceptanceSample\SubSpecAcceptanceSample.csproj">
+      <Project>{EE511D0D-B1EE-4246-8A78-D86B0E2AD181}</Project>
+      <Name>SubSpecAcceptanceSample</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Resource1.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>Resource1.Designer.cs</LastGenOutput>
+    </EmbeddedResource>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

SubSpecAcceptanceSample.Tests/SubSpecAcceptanceSample.Tests.csproj.user

+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <ProjectView>ShowAllFiles</ProjectView>
+  </PropertyGroup>
+</Project>

SubSpecAcceptanceSample.Tests/TemporaryDirectoryFixture.cs

+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.IO;
+using System.Threading;
+
+namespace SubSpecAcceptanceSample
+{
+	/// <summary>
+	/// Creates a temporary directory on creation and cleans it up on dispose.
+	/// </summary>
+	public class TemporaryDirectoryFixture : IDisposable
+	{
+		private readonly string _directoryPath;
+
+		public TemporaryDirectoryFixture()
+		{
+			string randomDirectoryName = Path.GetFileNameWithoutExtension( Path.GetRandomFileName() );
+
+			_directoryPath = Path.Combine( Path.GetTempPath(), randomDirectoryName );
+
+			Directory.CreateDirectory( DirectoryPath );
+		}
+
+		public string DirectoryPath
+		{
+			get { return _directoryPath; }
+		}
+
+		public void Dispose()
+		{
+			try
+			{
+				Directory.Delete( _directoryPath, true );
+			}
+			catch (IOException)
+			{
+				// Give other process a chance to release their handles
+				Thread.Sleep( 0 );
+				Directory.Delete( _directoryPath, true );
+			}
+		}
+	}
+}

SubSpecAcceptanceSample.Tests/packages.config

+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="xunit" version="1.8.0.1545" />
+  <package id="xunit.extensions" version="1.8.0.1545" />
+  <package id="SubSpec" version="1.8.0.0" />
+</packages>

SubSpecAcceptanceSample.sln

 
 Microsoft Visual Studio Solution File, Format Version 11.00
 # Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubSpecAcceptanceSample.Tests", "SubSpecAcceptanceSample.Tests\SubSpecAcceptanceSample.Tests.csproj", "{57725236-30F3-4AB1-A760-03D09EE146D4}"
+EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubSpecAcceptanceSample", "SubSpecAcceptanceSample\SubSpecAcceptanceSample.csproj", "{EE511D0D-B1EE-4246-8A78-D86B0E2AD181}"
 EndProject
 Global
 		Release|Any CPU = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{57725236-30F3-4AB1-A760-03D09EE146D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{57725236-30F3-4AB1-A760-03D09EE146D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{57725236-30F3-4AB1-A760-03D09EE146D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{57725236-30F3-4AB1-A760-03D09EE146D4}.Release|Any CPU.Build.0 = Release|Any CPU
 		{EE511D0D-B1EE-4246-8A78-D86B0E2AD181}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{EE511D0D-B1EE-4246-8A78-D86B0E2AD181}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{EE511D0D-B1EE-4246-8A78-D86B0E2AD181}.Release|Any CPU.ActiveCfg = Release|Any CPU

SubSpecAcceptanceSample.suo

Binary file modified.

SubSpecAcceptanceSample/Resources.Designer.cs

-//------------------------------------------------------------------------------
-// <auto-generated>
-//     This code was generated by a tool.
-//     Runtime Version:4.0.30319.235
-//
-//     Changes to this file may cause incorrect behavior and will be lost if
-//     the code is regenerated.
-// </auto-generated>
-//------------------------------------------------------------------------------
-
-namespace SubSpecAcceptanceSample {
-    using System;
-    
-    
-    /// <summary>
-    ///   A strongly-typed resource class, for looking up localized strings, etc.
-    /// </summary>
-    // This class was auto-generated by the StronglyTypedResourceBuilder
-    // class via a tool like ResGen or Visual Studio.
-    // To add or remove a member, edit your .ResX file then rerun ResGen
-    // with the /str option, or rebuild your VS project.
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
-    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    internal class Resources {
-        
-        private static global::System.Resources.ResourceManager resourceMan;
-        
-        private static global::System.Globalization.CultureInfo resourceCulture;
-        
-        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
-        internal Resources() {
-        }
-        
-        /// <summary>
-        ///   Returns the cached ResourceManager instance used by this class.
-        /// </summary>
-        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
-        internal static global::System.Resources.ResourceManager ResourceManager {
-            get {
-                if (object.ReferenceEquals(resourceMan, null)) {
-                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SubSpecAcceptanceSample.Resources", typeof(Resources).Assembly);
-                    resourceMan = temp;
-                }
-                return resourceMan;
-            }
-        }
-        
-        /// <summary>
-        ///   Overrides the current thread's CurrentUICulture property for all
-        ///   resource lookups using this strongly typed resource class.
-        /// </summary>
-        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
-        internal static global::System.Globalization.CultureInfo Culture {
-            get {
-                return resourceCulture;
-            }
-            set {
-                resourceCulture = value;
-            }
-        }
-        
-        internal static System.Drawing.Bitmap World_TLD_Map {
-            get {
-                object obj = ResourceManager.GetObject("World_TLD_Map", resourceCulture);
-                return ((System.Drawing.Bitmap)(obj));
-            }
-        }
-    }
-}

SubSpecAcceptanceSample/Resources.resx

-<?xml version="1.0" encoding="utf-8"?>
-<root>
-  <!-- 
-    Microsoft ResX Schema 
-    
-    Version 2.0
-    
-    The primary goals of this format is to allow a simple XML format 
-    that is mostly human readable. The generation and parsing of the 
-    various data types are done through the TypeConverter classes 
-    associated with the data types.
-    
-    Example:
-    
-    ... ado.net/XML headers & schema ...
-    <resheader name="resmimetype">text/microsoft-resx</resheader>
-    <resheader name="version">2.0</resheader>
-    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
-    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
-    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
-    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
-    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
-        <value>[base64 mime encoded serialized .NET Framework object]</value>
-    </data>
-    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
-        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
-        <comment>This is a comment</comment>
-    </data>
-                
-    There are any number of "resheader" rows that contain simple 
-    name/value pairs.
-    
-    Each data row contains a name, and value. The row also contains a 
-    type or mimetype. Type corresponds to a .NET class that support 
-    text/value conversion through the TypeConverter architecture. 
-    Classes that don't support this are serialized and stored with the 
-    mimetype set.
-    
-    The mimetype is used for serialized objects, and tells the 
-    ResXResourceReader how to depersist the object. This is currently not 
-    extensible. For a given mimetype the value must be set accordingly:
-    
-    Note - application/x-microsoft.net.object.binary.base64 is the format 
-    that the ResXResourceWriter will generate, however the reader can 
-    read any of the formats listed below.
-    
-    mimetype: application/x-microsoft.net.object.binary.base64
-    value   : The object must be serialized with 
-            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
-            : and then encoded with base64 encoding.
-    
-    mimetype: application/x-microsoft.net.object.soap.base64
-    value   : The object must be serialized with 
-            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
-            : and then encoded with base64 encoding.
-
-    mimetype: application/x-microsoft.net.object.bytearray.base64
-    value   : The object must be serialized into a byte array 
-            : using a System.ComponentModel.TypeConverter
-            : and then encoded with base64 encoding.
-    -->
-  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
-    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
-    <xsd:element name="root" msdata:IsDataSet="true">
-      <xsd:complexType>
-        <xsd:choice maxOccurs="unbounded">
-          <xsd:element name="metadata">
-            <xsd:complexType>
-              <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" />
-              </xsd:sequence>
-              <xsd:attribute name="name" use="required" type="xsd:string" />
-              <xsd:attribute name="type" type="xsd:string" />
-              <xsd:attribute name="mimetype" type="xsd:string" />
-              <xsd:attribute ref="xml:space" />
-            </xsd:complexType>
-          </xsd:element>
-          <xsd:element name="assembly">
-            <xsd:complexType>
-              <xsd:attribute name="alias" type="xsd:string" />
-              <xsd:attribute name="name" type="xsd:string" />
-            </xsd:complexType>
-          </xsd:element>
-          <xsd:element name="data">
-            <xsd:complexType>
-              <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
-                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
-              </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
-              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
-              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
-              <xsd:attribute ref="xml:space" />
-            </xsd:complexType>
-          </xsd:element>
-          <xsd:element name="resheader">
-            <xsd:complexType>
-              <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
-              </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" use="required" />
-            </xsd:complexType>
-          </xsd:element>
-        </xsd:choice>
-      </xsd:complexType>
-    </xsd:element>
-  </xsd:schema>
-  <resheader name="resmimetype">
-    <value>text/microsoft-resx</value>
-  </resheader>
-  <resheader name="version">
-    <value>2.0</value>
-  </resheader>
-  <resheader name="reader">
-    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
-  </resheader>
-  <resheader name="writer">
-    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
-  </resheader>
-  <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
-  <data name="World_TLD_Map" type="System.Resources.ResXFileRef, System.Windows.Forms">
-    <value>Resources\World_TLD_Map.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
-  </data>
-</root>

SubSpecAcceptanceSample/Resources/World_TLD_Map.jpg

Removed
Old image

SubSpecAcceptanceSample/SubSpec/LICENSE.txt

-This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.
-
-1. Definitions
-
-The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.
-
-A "contribution" is the original software, or any additions or changes to the software.
-
-A "contributor" is any person that distributes its contribution under this license.
-
-"Licensed patents" are a contributor's patent claims that read directly on its contribution.
-
-2. Grant of Rights
-
-(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
-
-(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
-
-3. Conditions and Limitations
-
-(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
-
-(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.
-
-(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.
-
-(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.
-
-(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.

SubSpecAcceptanceSample/SubSpec/SubSpec.Thesis.cs

-using System;
-using System.Collections.Generic;
-using Xunit.Sdk;
-using Xunit.Extensions;
-
-namespace SubSpec
-{
-    [AttributeUsage( AttributeTargets.Method, AllowMultiple = false, Inherited = true )]
-    public class ThesisAttribute : TheoryAttribute
-    {
-        protected override IEnumerable<ITestCommand> EnumerateTestCommands( IMethodInfo method )
-        {
-            // prepare specification invocations  
-            var theoryTestCommands = base.EnumerateTestCommands( method );
-
-            var commands = new List<ITestCommand>();
-
-            foreach (var item in theoryTestCommands)
-            {
-                if (item is TheoryCommand)
-                {
-                    commands.AddRange( SubSpec.Core.SpecificationContext.SafelyEnumerateTestCommands( method,
-                        m =>
-                        {
-                            // Create a new test class instance
-                            object obj = item.ShouldCreateInstance ? Activator.CreateInstance( method.MethodInfo.ReflectedType ) : null;
-                            
-                            // create method
-                            item.Execute( obj );
-                        } ) );
-
-                }
-                else
-                {
-                    commands.Clear();
-                    commands.Add( item );
-                    break;
-                }
-            }
-
-            return commands;
-        }
-    }
-}

SubSpecAcceptanceSample/SubSpec/SubSpec.cs

-using System;
-using System.Collections.Generic;
-using System.Text;
-using Xunit;
-using Xunit.Sdk;
-using System.Xml;
-using System.Diagnostics;
-using System.Reflection;
-using System.Linq;
-
-namespace SubSpec
-{
-    /// <remarks>
-    /// We declare our own delegate instead of using Func 
-    /// because we can't use implicit covariance on the generic type parameter in .net 3.5"/>
-    /// </remarks>
-    public delegate IDisposable ContextDelegate();
-
-    public class DisposableAction : IDisposable
-    {
-        public static readonly DisposableAction None = new DisposableAction( () => { } );
-
-        private readonly Action _action;
-
-        public DisposableAction( Action action )
-        {
-            if (action == null)
-                throw new ArgumentNullException( "action" );
-
-            _action = action;
-        }
-
-        public void Dispose()
-        {
-            _action();
-        }
-    }
-
-    public interface ISpecificationPrimitive
-    {
-        /// <summary>
-        /// Indicate that execution of this delegate should be canceled after a specified timeout.
-        /// </summary>
-        /// <param name="timeoutMs">The timeout in milliseconds.</param>
-        ISpecificationPrimitive WithTimeout( int timeoutMs );
-    }
-
-    internal static class Core
-    {
-        private class SpecificationPrimitive<T> : ISpecificationPrimitive
-        {
-            private readonly string _message;
-            private readonly T _action;
-            private int _timeoutMs;
-
-            /// <summary>
-            /// Initializes a new instance of the Context class.
-            /// </summary>
-