Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to .NET 4.0 and MVC 4 #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Libraries/Machine.Specifications.dll
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{9BAAB949-8224-4F46-BB81-E529671273CD}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Machine.Specifications.Mvc.Example</RootNamespace>
<AssemblyName>Machine.Specifications.Mvc.Example</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Build\Example\</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>..\..\Build\Example\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Machine.Specifications, Version=0.3.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Libraries\Machine.Specifications.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System.Web.Routing">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Person.cs" />
<Compile Include="PersonController.cs" />
<Compile Include="PersonControllerSpecs.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Machine.Specifications.MVC\Machine.Specifications.Mvc.csproj">
<Project>{E6626A76-01EA-4C2C-AAF8-F6BA2C4F86F8}</Project>
<Name>Machine.Specifications.Mvc</Name>
</ProjectReference>
</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>
8 changes: 8 additions & 0 deletions Source/Backup/Machine.Specifications.MVC.Example/Person.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Machine.Specifications.Mvc.Example
{
public class Person
{
public int Id { get; set; }
public string Name { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
namespace Machine.Specifications.Mvc.Example
{
using System;
using System.Web.Mvc;
using System.Web.Routing;

public class PersonController : Controller
{
public ActionResult Index()
{
return View();
}

public ActionResult Show(int id)
{
if (id == 999)
{
return View("NotFound");
}

var person = new Person() { Id = id, Name = "James Broome" };

return View(person);
}

public ActionResult Update()
{
return View();
}

public ActionResult Update(Person person, bool loggedIn)
{
if (!loggedIn)
{
return new RedirectResult("http://openid.co.uk");
}

if (person.Id == 999)
{
// Error
return new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Person", action = "Update" }));
}

// Update the person...

return new RedirectToRouteResult(new RouteValueDictionary(new { controller = "Person", action = "List" }));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
//-------------------------------------------------------------------------------------------------
// <auto-generated>
// Marked as auto-generated so StyleCop will ignore BDD style tests
// </auto-generated>
//-------------------------------------------------------------------------------------------------

using Machine.Specifications;

namespace Machine.Specifications.Mvc.Example
{
using System.Web.Mvc;

[Subject(typeof(PersonController))]
public class context_for_a_person_controller
{
protected static PersonController personController;

Establish context = () =>
{
personController = new PersonController();
};
}

[Subject(typeof(PersonController))]
public class when_the_person_controller_is_told_to_show_a_user : context_for_a_person_controller
{
static ActionResult result;

Because of = () => result = personController.Show(1);

It should_show_the_default_view = () =>
result.ShouldBeAView().And().ShouldUseDefaultView();

It should_show_the_correct_user_id_in_the_view = () =>
result.ShouldBeAView().And().ShouldHaveModelOfType<Person>().And().Id.ShouldEqual(1);

It should_show_the_correct_user_name_in_the_view = () =>
result.Model<Person>().Name.ShouldEqual("James Broome"); // Shorter syntax for accessing model
}

[Subject(typeof(PersonController))]
public class when_the_person_controller_is_told_to_show_a_user_that_does_not_exist : context_for_a_person_controller
{
static ActionResult result;

Because of = () => result = personController.Show(999);

It should_return_the_not_found_view = () =>
result.ShouldBeAView().And().ViewName.ShouldEqual("NotFound");
}

[Subject(typeof(PersonController))]
public class when_the_person_controller_is_told_to_update_a_person : context_for_a_person_controller
{
static ActionResult result;

Because of = () => result = personController.Update(new Person(), true);

It should_redirect_to_the_list_view = () =>
{
result.ShouldBeARedirectToRoute().And().ControllerName().ShouldEqual("Person");
result.ShouldBeARedirectToRoute().And().ActionName().ShouldEqual("List");
};
}

[Subject(typeof(PersonController))]
public class when_the_person_controller_is_told_to_update_a_person_and_there_is_an_error : context_for_a_person_controller
{
static ActionResult result;

Because of = () => result = personController.Update(new Person() { Id = 999 }, true);

It should_redirect_to_the_update_view = () => result.ShouldRedirectToAction<PersonController>(x => x.Update());
}

[Subject(typeof(PersonController))]
public class when_the_person_controller_is_told_to_update_a_person_and_the_user_is_not_authenticated : context_for_a_person_controller
{
static ActionResult result;

Because of = () => result = personController.Update(new Person(), false);

It should_redirect_to_the_open_id_url = () =>
result.ShouldBeARedirect().And().Url.ShouldEqual("http://openid.co.uk");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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("Machine.Specifications.Mvc.Example")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("James Broome")]
[assembly: AssemblyProduct("Machine.Specifications.Mvc.Example")]
[assembly: AssemblyCopyright("Copyright © James Broome 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("b0955994-cd25-4704-92b6-8a6e45bf5a95")]

// 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")]
Loading