Skip to content

Commit d7ef5a3

Browse files
committed
Merge pull request #9 from MehdiK/samples
Renamed Example to Sample in project folder names to avoid confusion
2 parents d334bcd + dc683a0 commit d7ef5a3

File tree

123 files changed

+8222
-8222
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+8222
-8222
lines changed

TestStack.FluentMVCTesting.Example.Tests/Controllers/AccountControllerTests.cs renamed to Samples/TestStack.FluentMVCTesting.Sample.Tests/Controllers/AccountControllerTests.cs

Lines changed: 98 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,98 @@
1-
using System.Web.Mvc;
2-
using System.Web.Routing;
3-
using NSubstitute;
4-
using NUnit.Framework;
5-
using TestStack.FluentMVCTesting.Sample.Controllers;
6-
using TestStack.FluentMVCTesting.Sample.Models;
7-
using TestStack.FluentMVCTesting.Sample.Services;
8-
9-
namespace TestStack.FluentMVCTesting.Sample.Tests.Controllers
10-
{
11-
class AccountControllerTests
12-
{
13-
private AccountController _controller;
14-
private IAuthenticationService _authenticationService;
15-
16-
[SetUp]
17-
public void Setup()
18-
{
19-
_authenticationService = Substitute.For<IAuthenticationService>();
20-
_controller = new AccountController(_authenticationService)
21-
{
22-
Url = new UrlHelper(Substitute.For<RequestContext>())
23-
};
24-
}
25-
26-
[Test]
27-
public void WhenViewingLoginPage_ThenShowDefaultViewWithReturnUrl()
28-
{
29-
const string returnUrl = "http://www.google.com.au/";
30-
31-
_controller.WithCallTo(c => c.Login(returnUrl))
32-
.ShouldRenderDefaultView();
33-
34-
Assert.That(_controller.ViewBag.ReturnUrl, Is.EqualTo(returnUrl));
35-
}
36-
37-
[Test]
38-
public void GivenInvalidSubmission_WhenPostingLoginDetails_ThenShowDefaultViewWithInvalidModelAndReturnUrl()
39-
{
40-
var vm = new LoginModel();
41-
const string returnUrl = "http://www.google.com.au/";
42-
43-
_controller.WithModelErrors()
44-
.WithCallTo(c => c.Login(vm, returnUrl))
45-
.ShouldRenderDefaultView()
46-
.WithModel(vm);
47-
48-
Assert.That(_controller.ViewBag.ReturnUrl, Is.EqualTo(returnUrl));
49-
}
50-
51-
[Test]
52-
public void GivenValidSubmissionButIncorrectDetails_WhenPostingLoginDetails_ThenShowDefaultViewWithInvalidModelAndReturnUrlAndErrorMessage()
53-
{
54-
var vm = new LoginModel();
55-
const string returnUrl = "http://www.google.com.au/";
56-
_authenticationService.Login(vm).Returns(false);
57-
58-
_controller.WithCallTo(c => c.Login(vm, returnUrl))
59-
.ShouldRenderDefaultView()
60-
.WithModel(vm)
61-
.AndModelError("").ThatEquals("The user name or password provided is incorrect.");
62-
63-
Assert.That(_controller.ViewBag.ReturnUrl, Is.EqualTo(returnUrl));
64-
}
65-
66-
[Test]
67-
public void GivenLocalReturnUrlAndValidSubmission_WhenPostingLoginDetails_ThenLogUserInAndRedirectToReturnUrl()
68-
{
69-
var vm = new LoginModel();
70-
const string returnUrl = "/localurl";
71-
_authenticationService.Login(vm).Returns(true);
72-
73-
_controller.WithCallTo(c => c.Login(vm, returnUrl))
74-
.ShouldRedirectTo(returnUrl);
75-
}
76-
77-
[Test]
78-
public void GivenNonLocalReturnUrlAndValidSubmission_WhenPostingLoginDetails_ThenLogUserInAndRedirectToHomepage()
79-
{
80-
var vm = new LoginModel();
81-
const string returnUrl = "http://www.google.com.au/";
82-
_authenticationService.Login(vm).Returns(true);
83-
84-
_controller.WithCallTo(c => c.Login(vm, returnUrl))
85-
.ShouldRedirectTo<HomeController>(c => c.Index());
86-
}
87-
88-
[Test]
89-
public void GivenNoReturnUrlAndValidSubmission_WhenPostingLoginDetails_ThenLogUserInAndRedirectToHomepage([Values(null, "")] string returnUrl)
90-
{
91-
var vm = new LoginModel();
92-
_authenticationService.Login(vm).Returns(true);
93-
94-
_controller.WithCallTo(c => c.Login(vm, returnUrl))
95-
.ShouldRedirectTo<HomeController>(c => c.Index());
96-
}
97-
}
98-
}
1+
using System.Web.Mvc;
2+
using System.Web.Routing;
3+
using NSubstitute;
4+
using NUnit.Framework;
5+
using TestStack.FluentMVCTesting.Sample.Controllers;
6+
using TestStack.FluentMVCTesting.Sample.Models;
7+
using TestStack.FluentMVCTesting.Sample.Services;
8+
9+
namespace TestStack.FluentMVCTesting.Sample.Tests.Controllers
10+
{
11+
class AccountControllerTests
12+
{
13+
private AccountController _controller;
14+
private IAuthenticationService _authenticationService;
15+
16+
[SetUp]
17+
public void Setup()
18+
{
19+
_authenticationService = Substitute.For<IAuthenticationService>();
20+
_controller = new AccountController(_authenticationService)
21+
{
22+
Url = new UrlHelper(Substitute.For<RequestContext>())
23+
};
24+
}
25+
26+
[Test]
27+
public void WhenViewingLoginPage_ThenShowDefaultViewWithReturnUrl()
28+
{
29+
const string returnUrl = "http://www.google.com.au/";
30+
31+
_controller.WithCallTo(c => c.Login(returnUrl))
32+
.ShouldRenderDefaultView();
33+
34+
Assert.That(_controller.ViewBag.ReturnUrl, Is.EqualTo(returnUrl));
35+
}
36+
37+
[Test]
38+
public void GivenInvalidSubmission_WhenPostingLoginDetails_ThenShowDefaultViewWithInvalidModelAndReturnUrl()
39+
{
40+
var vm = new LoginModel();
41+
const string returnUrl = "http://www.google.com.au/";
42+
43+
_controller.WithModelErrors()
44+
.WithCallTo(c => c.Login(vm, returnUrl))
45+
.ShouldRenderDefaultView()
46+
.WithModel(vm);
47+
48+
Assert.That(_controller.ViewBag.ReturnUrl, Is.EqualTo(returnUrl));
49+
}
50+
51+
[Test]
52+
public void GivenValidSubmissionButIncorrectDetails_WhenPostingLoginDetails_ThenShowDefaultViewWithInvalidModelAndReturnUrlAndErrorMessage()
53+
{
54+
var vm = new LoginModel();
55+
const string returnUrl = "http://www.google.com.au/";
56+
_authenticationService.Login(vm).Returns(false);
57+
58+
_controller.WithCallTo(c => c.Login(vm, returnUrl))
59+
.ShouldRenderDefaultView()
60+
.WithModel(vm)
61+
.AndModelError("").ThatEquals("The user name or password provided is incorrect.");
62+
63+
Assert.That(_controller.ViewBag.ReturnUrl, Is.EqualTo(returnUrl));
64+
}
65+
66+
[Test]
67+
public void GivenLocalReturnUrlAndValidSubmission_WhenPostingLoginDetails_ThenLogUserInAndRedirectToReturnUrl()
68+
{
69+
var vm = new LoginModel();
70+
const string returnUrl = "/localurl";
71+
_authenticationService.Login(vm).Returns(true);
72+
73+
_controller.WithCallTo(c => c.Login(vm, returnUrl))
74+
.ShouldRedirectTo(returnUrl);
75+
}
76+
77+
[Test]
78+
public void GivenNonLocalReturnUrlAndValidSubmission_WhenPostingLoginDetails_ThenLogUserInAndRedirectToHomepage()
79+
{
80+
var vm = new LoginModel();
81+
const string returnUrl = "http://www.google.com.au/";
82+
_authenticationService.Login(vm).Returns(true);
83+
84+
_controller.WithCallTo(c => c.Login(vm, returnUrl))
85+
.ShouldRedirectTo<HomeController>(c => c.Index());
86+
}
87+
88+
[Test]
89+
public void GivenNoReturnUrlAndValidSubmission_WhenPostingLoginDetails_ThenLogUserInAndRedirectToHomepage([Values(null, "")] string returnUrl)
90+
{
91+
var vm = new LoginModel();
92+
_authenticationService.Login(vm).Returns(true);
93+
94+
_controller.WithCallTo(c => c.Login(vm, returnUrl))
95+
.ShouldRedirectTo<HomeController>(c => c.Index());
96+
}
97+
}
98+
}

TestStack.FluentMVCTesting.Example.Tests/Properties/AssemblyInfo.cs renamed to Samples/TestStack.FluentMVCTesting.Sample.Tests/Properties/AssemblyInfo.cs

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
using System.Reflection;
2-
using System.Runtime.CompilerServices;
3-
using System.Runtime.InteropServices;
4-
5-
// General Information about an assembly is controlled through the following
6-
// set of attributes. Change these attribute values to modify the information
7-
// associated with an assembly.
8-
[assembly: AssemblyTitle("TestStack.FluentMVCTesting.Example.Tests")]
9-
[assembly: AssemblyDescription("")]
10-
[assembly: AssemblyConfiguration("")]
11-
[assembly: AssemblyCompany("")]
12-
[assembly: AssemblyProduct("TestStack.FluentMVCTesting.Example.Tests")]
13-
[assembly: AssemblyCopyright("Copyright © 2013")]
14-
[assembly: AssemblyTrademark("")]
15-
[assembly: AssemblyCulture("")]
16-
17-
// Setting ComVisible to false makes the types in this assembly not visible
18-
// to COM components. If you need to access a type in this assembly from
19-
// COM, set the ComVisible attribute to true on that type.
20-
[assembly: ComVisible(false)]
21-
22-
// The following GUID is for the ID of the typelib if this project is exposed to COM
23-
[assembly: Guid("d9c8385f-0b68-48ec-9399-360df30e0707")]
24-
25-
// Version information for an assembly consists of the following four values:
26-
//
27-
// Major Version
28-
// Minor Version
29-
// Build Number
30-
// Revision
31-
//
32-
// You can specify all the values or you can default the Build and Revision Numbers
33-
// by using the '*' as shown below:
34-
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.0.0.0")]
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("TestStack.FluentMVCTesting.Example.Tests")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("TestStack.FluentMVCTesting.Example.Tests")]
13+
[assembly: AssemblyCopyright("Copyright © 2013")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("d9c8385f-0b68-48ec-9399-360df30e0707")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)