Skip to content

fluentassertions/fluentassertions.aspnetcore.mvc

Repository files navigation

Project Description

Build status

FluentAssertions MVC is a set of MVC focused assertions and helper extensions to the excellent FluentAssertions library.

Installation

Add the NuGet package which matches the version of MVC you are using to your test project.

MVC 5

Add the MVC 5 NuGet package to your unit test project:

PM> Install-Package FluentAssertions.Mvc5

MVC 4

Add the MVC 4 NuGet package to your unit test project:

PM> Install-Package FluentAssertions.Mvc4

MVC 3

Add the MVC 3 NuGet package to your unit test project:

PM> Install-Package FluentAssertions.Mvc3

Getting Started

Write a unit test for your controller using one of the supported test frameworks. For exampe with NUnit:

[Test]
public void Index_Action_Returns_View()
{
    // Arrange
    var controller = new HomeController();

    // Act
    var result = controller.Index();

    // Assert
    result.Should().BeViewResult();
}