Coder Social home page Coder Social logo

justfakeit's Introduction

Build status JustFakeIt

Gitter An InProcess HTTP server which can be mocked and asserted against to allow for full stack HTTP testing


  • Introduction
  • Installation
  • Getting Started
  • Contributing
  • Copyright

Introduction

JustFakeIt is a mockable HTTP server which is hosted within your unit test process and provides you with the ability to test your applications entire HTTP stack without having to provide mocks for anything in the stack. Because it's hosted In Process, it's really fast and takes very little effort to use.

It will configure itself as a default proxy and let you hook any WebRequest based client by default, intercepting all outbound Http calls in scope.

Installation

Pre-requisites: The project is built in .net v4.0.

Via NuGet:

	PM> Install-Package JustFakeIt

Getting Started

Once you have the package installed into your test project, a standard wire-up will look like this.

[Fact]
public void FakeServer_ExpectGetReturnsString_ResponseMatchesExpectation()
{    
    using (var fakeServer = new FakeServer(12354))
    {
        fakeServer.Expect.Get("/123").Returns("Some String Data");
        fakeServer.Start();

        var result = new WebClient().DownloadString(new Uri("http://www.anything-at-all.com/123"));

        result.Should().Be("Some String Data");
    }
}

Ignore parameters by replacing the value with "{ignore}"

 var fakeurl = "/some-resource/{ignore}/some-resource?date={ignore}&type={ignore}";
 fakeServer.Expect.Get(fakeurl).Returns(HttpStatusCode.Accepted, expectedResult);

Set a response time by setting the ResponseTime property

 fakeServer.Expect.ResponseTime = TimeSpan.FromSeconds(5);

Contributing

If you find a bug, have a feature request or even want to contribute an enhancement or fix, please follow the contributing guidelines included in the repository.

Copyright

Copyright © JUST EAT PLC 2014

justfakeit's People

Contributors

jaimalchohan-justeat avatar cosminonea avatar jaimalchohan avatar davidwhitney avatar petemounce avatar gitter-badger avatar justeattech avatar

Watchers

Matt Jones 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.