GithubHelp home page GithubHelp logo

benjaminkeeping / machine.specifications.mvc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joefeser/machine.specifications.mvc

1.0 2.0 0.0 2.58 MB

Machine.Specifications.Mvc is a set of extensions for testing ASP.Net MVC specific types.

Home Page: http://jamesbroo.me/introducing-machinespecificationsmvc/

C# 99.33% Shell 0.67%

machine.specifications.mvc's Introduction

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.**

machine.specifications.mvc's People

Contributors

benjaminkeeping avatar chrisrichards avatar jamesbroome avatar joefeser avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.