forked from jamesbroome/Machine.Specifications.Mvc
-
Notifications
You must be signed in to change notification settings - Fork 5
/
readme.txt
88 lines (41 loc) · 2.43 KB
/
readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
Machine.Specifications.Mvc is a set of extensions for testing ASP.Net MVC specific types.
It aims to ease the testing of ActionResult objects returned from MVC Controllers by providing an MSpec BDD syntax over these types.
Current Features:
-----------------------------------------------------------------------------------
ActionResult extensions
- ShouldBeAView()
e.g. result.ShouldBeAView();
- ShouldBeARedirectToRoute()
e.g. result.ShouldBeARedirectToRoute();
- ShouldBeARedirect()
e.g. result.ShouldBeARedirect();
Each expose the And() chaining command, returning the strongly typed ActionResult.
- e.g. result.ShouldBeAView().And().ViewName.ShouldEqual("NotFound");
- e.g. result.ShouldBeARedirect().And().Url.ShouldEqual("http://someurl.com");
- e.g. result.ShouldBeARedirectToRoute().And().RouteName.ShouldEqual("RouteName");
-----------------------------------------------------------------------------------
ViewResult specific extensions
- ShouldUseDefaultView()
e.g. result.ShouldBeAView().And().ShouldUseDefaultView();
- ShouldHaveModelOfType<T>()
e.g. result.ShouldBeAView().And().ShouldHaveModelOfType<Person>();
ShouldHaveModelOfType<T>() also exposes the And() chaining command, returning the model strongly typed as T
- e.g. result.ShouldBeAView().And().ShouldHaveModelOfType<Person>().And().Id.ShouldEqual(1);
-----------------------------------------------------------------------------------
RedirectToRoute specific extensions
- ControllerName()
e.g. result.ShouldBeARedirectToRoute().And().ControllerName().ShouldEqual("Person");
- ActionName()
e.g. result.ShouldBeARedirectToRoute().And().ActionName().ShouldEqual("List");
-----------------------------------------------------------------------------------
Further ActionResult extensions
- Model<T>()
Provides a shortcut straight to the ViewData.Model property of an ActionResult cast as a ViewResult
e.g. result.Model<Person>().Name.ShouldEqual("James Broome");
- ShouldRedirectToAction<TController>(Expression<Action<TController>> action)
Provides a strongly typed shortcut to check an ActionResult cast as a RedirectToRoute against Actions on Controllers
e.g. result.ShouldRedirectToAction<HomeController>(x => x.Index());
**You must run build.bat from the command line to put down the packages, otherwise the project will not build.**