try-catch-FAIL

Failure is inevitable

NAVIGATION - SEARCH

SpecsFor Updates!

image

New versions of both SpecsFor.Web.Helpers and SpecsFor.Mvc rolled out this week, thanks to the contributions of two users from the community.

First, Dan Patterson was kind enough to improve the Fake* objects, making it possible to simulate AJAX requests.  He added two new interfaces that can be used for configuring the behavior of the fake objects: IHeaderParamsProvider, and IServerParamsProvider.  You can find these improvements in the 1.6.0 release.

public class when_posting_to_index_through_ajax : SpecsFor<IsAjaxRequestController>
{
    private ActionResult _result;

    protected override void Given()
    {
        this.FakeAjaxRequest();
    }

    protected override void When()
    {
        _result = SUT.Index(It.IsAny<string>());
    }

    [Test]
    public void then_result_is_JsonResult()
    {
        _result.ShouldBeType(typeof(JsonResult));
    }
}

Next, Markus Neuhoff made a big contribution to SpecsFor.Mvc: you can now enable and test with SSL!  You still have to configure the port you want to use for SSL first, but after that, all you have to do is use the fluent API to configure things.  This change is available in SpecsFor.Mvc 4.6.0.

var config = new SpecsForMvcConfig();
config.UseIISExpress()
    .UsePort(44300)
    .UseHttps()
    .With(Project.Named("SpecsFor.Mvc.Demo"))
    .CleanupPublishedFiles()
    .ApplyWebConfigTransformForConfig("Test");

Thanks, Markus and Dan, for your contributions!

About Matt Honeycutt...

Matt Honeycutt is a software architect specializing in ASP.NET web applications, particularly ASP.NET MVC. He has over a decade of experience in building (and testing!) web applications. He’s an avid practitioner of Test-Driven Development, creating both the SpecsFor and SpecsFor.Mvc frameworks.

He's also an author for Pluralsight, where he publishes courses on everything from web applications to testing!

blog comments powered by Disqus