Skip to content
This repository has been archived by the owner on Aug 23, 2019. It is now read-only.

Commit

Permalink
Merge branch 'release-0.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
drauch committed Sep 30, 2015
2 parents d4e2762 + 39c2bf6 commit f62510a
Show file tree
Hide file tree
Showing 16 changed files with 331 additions and 50 deletions.
4 changes: 4 additions & 0 deletions .nuget/packages.config
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Machine.Specifications.Runner.Console" version="0.9.2" />
</packages>
18 changes: 12 additions & 6 deletions Gemfile.lock
Expand Up @@ -8,15 +8,18 @@ GEM
configatron (2.13.0)
yamler (>= 0.1.0)
gitflowversion (0.14.0)
mini_portile (0.5.2)
nokogiri (1.6.1-x86-mingw32)
mini_portile (~> 0.5.0)
nuget (2.8.50126.400)
rake (10.1.1)
rubyzip (1.1.0)
mini_portile (0.6.2)
nokogiri (1.6.6.2-x64-mingw32)
mini_portile (~> 0.6.0)
nokogiri (1.6.6.2-x86-mingw32)
mini_portile (~> 0.6.0)
nuget (2.8.60717.93)
rake (10.4.2)
rubyzip (1.1.7)
yamler (0.1.0)

PLATFORMS
x64-mingw32
x86-mingw32

DEPENDENCIES
Expand All @@ -25,3 +28,6 @@ DEPENDENCIES
gitflowversion
nuget
rake

BUNDLED WITH
1.10.6
4 changes: 2 additions & 2 deletions Machine.Specifications.Should.Specs/AssertionSpecs.cs
Expand Up @@ -45,10 +45,10 @@ public class when_checking_if_a_collection_contains_only_elements_that_match_a_f
Because of = () => { Exception = Catch.Exception(() => Ints.ShouldEachConformTo(x => x % 2 == 0)); };

// Horribly inconsistent here. It seems like this spec might fail because linq expressions returns ((x % 2) = 0)
// for the original ((x % 2) == 0).
// for the original ((x % 2) == 0). (fixed with .NET 4.0, therefore we use a regex match)

It should_print_the_func_description =
() => Exception.Message.ShouldContain("Should contain only elements conforming to: x => ((x % 2) = 0)");
() => Exception.Message.ShouldMatch(@"Should contain only elements conforming to: x => \(\(x % 2\) (==|=) 0\)");

It should_print_the_elements_that_did_not_match =
() => Exception.Message.ShouldMatch(@"the following items did not meet the condition: {\s+\[1\],\s+\[3\]\s+}");
Expand Down
Expand Up @@ -12,7 +12,7 @@
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SignAssembly>false</SignAssembly>
<AssemblyOriginatorKeyFile>..\Machine.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>..\Machine.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -37,11 +37,11 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Machine.Specifications" Condition="'$(SignAssembly)'=='false'">
<HintPath>..\packages\Machine.Specifications.0.8.1\lib\net20\Machine.Specifications.dll</HintPath>
<HintPath>..\packages\Machine.Specifications.0.9.3\lib\net20\Machine.Specifications.dll</HintPath>
</Reference>
<Reference Include="Machine.Specifications" Condition="'$(SignAssembly)'=='true'">
<HintPath>..\packages\Machine.Specifications-Signed.0.8.1\lib\net20\Machine.Specifications.dll</HintPath>
</Reference>
<HintPath>..\packages\Machine.Specifications-Signed.0.9.3\lib\net20\Machine.Specifications.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
Expand Down Expand Up @@ -79,10 +79,7 @@
<Target Name="AfterBuild">
<MakeDir Directories="$(SpecsFolder)" />
<Exec
Condition="'$(Configuration)' == 'Release' AND '$(SignAssembly)' == 'false'"
Command="$(SolutionDir)\packages\Machine.Specifications.0.8.1\tools\mspec.exe --progress --silent $(TargetPath) --html $(SpecsFolder)$(MSBuildProjectName).html" />
<Exec
Condition="'$(Configuration)' == 'Release' AND '$(SignAssembly)' == 'true'"
Command="$(SolutionDir)\packages\Machine.Specifications-Signed.0.8.1\tools\mspec.exe --progress --silent $(TargetPath) --html $(SpecsFolder)$(MSBuildProjectName).html" />
Condition="'$(Configuration)' == 'Release'"
Command="$(SolutionDir)\packages\Machine.Specifications.Runner.Console.0.9.2\tools\mspec.exe --progress --silent $(TargetPath) --html $(SpecsFolder)$(MSBuildProjectName).html" />
</Target>
</Project>
260 changes: 260 additions & 0 deletions Machine.Specifications.Should.Specs/ShouldBeLikeSpecs.cs
Expand Up @@ -73,6 +73,21 @@ public class with_multiple_errors

It should_throw = () => Exception.ShouldBeOfExactType<SpecificationException>();
}

public class with_different_types
{
public class and_object_should_equal_integer
{
Because of = () => Exception = Catch.Exception(() => new object().ShouldEqual(5));
It should_throw_specificationException = () => Exception.ShouldBeOfExactType<SpecificationException>();
}

public class and_integer_should_equal_object
{
Because of = () => Exception = Catch.Exception(() => 5.ShouldEqual(new object()));
It should_throw_specificationException = () => Exception.ShouldBeOfExactType<SpecificationException>();
}
}
}

[Subject(typeof(ShouldExtensionMethods))]
Expand Down Expand Up @@ -447,4 +462,249 @@ public class and_the_objects_differ_and_have_null_values
}");
}
}

[Subject(typeof (ShouldExtensionMethods))]
public class when_node_with_circular_references
{
class Node
{
public string Field;
public Node Next;
}

static Exception exception;

static Node actualNode;
static Node expectedNode;

Establish ctx = () =>
{
actualNode = new Node { Field = "field1" };
expectedNode = new Node { Field = "field1" };
};

class and_the_objects_are_equal
{
Establish ctx = () => actualNode.Next = actualNode;

Because of = () => exception = Catch.Exception(() => actualNode.ShouldBeLike(actualNode));

It should_not_throw = () => exception.ShouldBeNull();
}

class and_the_objects_are_similar
{
Establish ctx = () =>
{
actualNode.Next = actualNode;
expectedNode.Next = expectedNode;
};

Because of = () => exception = Catch.Exception(() => actualNode.ShouldBeLike(expectedNode));

It should_not_throw = () => exception.ShouldBeNull();
}

class and_the_objects_differ_by_string_field
{
Establish ctx = () =>
{
actualNode.Next = actualNode;
expectedNode.Next = expectedNode;
expectedNode.Field = "field2";
};

Because of = () => exception = Catch.Exception(() => actualNode.ShouldBeLike(expectedNode));

It should_throw = () => exception.ShouldBeOfExactType<SpecificationException>();

It should_contain_message = () => exception.Message.ShouldEqual(@"""Field"":
String lengths are both 6. Strings differ at index 5.
Expected: ""field2""
But was: ""field1""
----------------^");
}

class and_expected_has_circular_reference
{
Establish ctx = () =>
{
actualNode.Next = null;
expectedNode.Next = expectedNode;
};

Because of = () => exception = Catch.Exception(() => actualNode.ShouldBeLike(expectedNode));

It should_throw = () => exception.ShouldBeOfExactType<SpecificationException>();

It should_contain_message = () => exception.Message.ShouldEqual(@"""Next"":
Expected: Machine.Specifications.Should.Specs.when_node_with_circular_references+Node
But was: [null]");
}

class and_actual_has_circular_reference
{
Establish ctx = () =>
{
actualNode.Next = actualNode;
expectedNode.Next = null;
};

Because of = () => exception = Catch.Exception(() => actualNode.ShouldBeLike(expectedNode));

It should_throw = () => exception.ShouldBeOfExactType<SpecificationException>();

It should_contain_message = () => exception.Message.ShouldEqual(@"""Next"":
Expected: [null]
But was: Machine.Specifications.Should.Specs.when_node_with_circular_references+Node");
}

class and_the_object_graph_is_similar
{
Establish ctx = () =>
{
actualNode.Next = actualNode;
var interNode = new Node { Field = "field1", Next = expectedNode };
expectedNode.Next = interNode;
};

Because of = () => exception = Catch.Exception(() => actualNode.ShouldBeLike(expectedNode));

It should_not_throw = () => exception.ShouldBeNull();
}

class and_the_objects_differ_by_referencing_node
{
Establish ctx = () =>
{
actualNode.Next = actualNode;
var interNode = new Node {Field = "field3", Next = expectedNode};
expectedNode.Next = interNode;
};

Because of = () => exception = Catch.Exception(() => actualNode.ShouldBeLike(expectedNode));

It should_throw = () => exception.ShouldBeOfExactType<SpecificationException>();

It should_contain_message = () => exception.Message.ShouldEqual(@"""Next.Field"":
String lengths are both 6. Strings differ at index 5.
Expected: ""field3""
But was: ""field1""
----------------^");
}

class and_the_node_has_indirect_circular_reference
{
Establish ctx = () =>
{
var interNode = new Node {Field = "node3", Next = actualNode };
actualNode.Next = expectedNode;
expectedNode.Next = interNode;
};

Because of = () => exception = Catch.Exception(() => actualNode.ShouldBeLike(actualNode));

It should_not_throw = () => exception.ShouldBeNull();
}
}

[Subject(typeof (ShouldExtensionMethods))]
public class when_node_with_inner_static_node
{
class Node
{
public string Field;
public static readonly Node Inner = new Node();
}

static Exception exception;
static Node actualNode;
static Node expectedNode;

Establish ctx = () =>
{
actualNode = new Node { Field = "a" };
expectedNode = new Node { Field="a" };
};

Because of = () => exception = Catch.Exception(() => actualNode.ShouldBeLike(expectedNode));

It should_not_throw = () => exception.ShouldBeNull();
}

[Subject(typeof(ShouldExtensionMethods))]
class when_complex_type_with_circular_references_are_in_collection
{
class Node
{
public string Field;
public Node Next;
}

static Exception exception;

static Node node1;
static Node node2;

static List<Node> actualNodeList;
static List<Node> expectedNodeList;

Establish ctx = () =>
{
node1 = new Node {Field = "node1Field"};
node1.Next = node1;
node2 = new Node {Field = "node2Field"};
node2.Next = node2;
};

class and_the_elements_are_similar
{
Establish ctx = () =>
{
actualNodeList = new List<Node> { node1, node2 };
expectedNodeList = new List<Node> { node1, node2 };
};

Because of = () => exception = Catch.Exception(() => actualNodeList.ShouldBeLike(expectedNodeList));

It should_not_throw = () => exception.ShouldBeNull();
}

class and_the_elements_differ
{
Establish ctx = () =>
{
actualNodeList = new List<Node> { node1, node2 };
var node3 = new Node {Field = "node3Field"};
node3.Next = node3;
expectedNodeList = new List<Node> { node1, node3 };
};

Because of = () => exception = Catch.Exception(() => actualNodeList.ShouldBeLike(expectedNodeList));

It should_throw = () => exception.ShouldBeOfExactType<SpecificationException>();

It should_contain_message = () => exception.Message.ShouldEqual(@"""[1].Field"":
String lengths are both 10. Strings differ at index 4.
Expected: ""node3Field""
But was: ""node2Field""
---------------^");

}

class and_the_elements_reference_each_other
{
Establish ctx = () =>
{
node1.Next = node2;
node2.Next = node1;
actualNodeList = new List<Node> { node1, node2 };
expectedNodeList = new List<Node> { node1, node2 };
};

Because of = () => exception = Catch.Exception(() => actualNodeList.ShouldBeLike(expectedNodeList));

It should_not_throw = () => exception.ShouldBeNull();
}
}
}
4 changes: 2 additions & 2 deletions Machine.Specifications.Should.Specs/packages.config
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="GitFlowVersionTask" version="0.14.0" targetFramework="net35" />
<package id="Machine.Specifications" version="0.8.1" targetFramework="net35" />
<package id="Machine.Specifications-Signed" version="0.8.1" targetFramework="net35" />
<package id="Machine.Specifications" version="0.9.3" targetFramework="net35" />
<package id="Machine.Specifications-Signed" version="0.9.3" targetFramework="net35" />
</packages>
5 changes: 4 additions & 1 deletion Machine.Specifications.Should.sln
@@ -1,13 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
VisualStudioVersion = 12.0.30723.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Machine.Specifications.Should", "Machine.Specifications.Should\Machine.Specifications.Should.csproj", "{4B86A9FC-4D07-40E3-AEB6-2898B5292972}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Machine.Specifications.Should.Specs", "Machine.Specifications.Should.Specs\Machine.Specifications.Should.Specs.csproj", "{B7E595D5-A988-4616-8548-87D3D691D28F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{F2235C5B-4B1B-4C2A-AB71-2EBA41BCC7C4}"
ProjectSection(SolutionItems) = preProject
.nuget\packages.config = .nuget\packages.config
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down

0 comments on commit f62510a

Please sign in to comment.