
An awesome Moq Rest Client project to jumpstart your projects!
·
Report Bug
·
Request Feature
Table of Contents
This is a lightweight mocking tool for .net 6 plus. The goal is to stay light and easy to integrate into your project.
Here's why:
- Your time should be focused on creating something amazing. A project that solves a problem and helps others
- You shouldn't be doing the same tasks over and over like creating a service project to mock your HTTP requests.
- You should implement DRY principles to the rest of your life 😄
Of course, your needs may be different. So I'll be adding more features shortly. You may also suggest changes by forking this repo and creating a pull request or opening an issue.
This section should list any major frameworks/libraries used to bootstrap your project. Leave any add-ons/plugins for the acknowledgements section. Here are a few examples.
This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.
This is an example of how to list things you need to use the software and how to install them.
- nuget
Install-Package MoqHttp -Version 1.0.0
You should beable to download and run out of the box after a build.
[Fact]
public async void Get_Should_Work_Correctly()
{
//Arrange
_mockServer = new HttpServer(Port);
_mockServer.Run();
//Act
_mockServer.Config.Get("/test/123").Send("It Really Works!");
var responseGet = await _httpClient.GetAsync($"{_address}/test/123");
_mockServer.Config.Get("/testAction/123").Send(context =>
{
context.Response.StatusCode = 200;
const string response = "Action Test";
var buffer = System.Text.Encoding.UTF8.GetBytes(response);
context.Response.Body.WriteAsync(buffer, 0, buffer.Length);
});
var responseGetAction = await _httpClient.GetAsync($"{_address}/testAction/123");
_mockServer.Dispose();
//Assert
Assert.Equal("It Really Works!", await responseGet.Content.ReadAsStringAsync());
Assert.Equal(200, (int)responseGet.StatusCode);
Assert.Equal("Action Test", await responseGetAction.Content.ReadAsStringAsync());
Assert.Equal(200, (int)responseGetAction.StatusCode);
}
More comming soon
- Add Changelog
- Add back to top links
- Clean up docs
- Add Additional Templates w/ Examples
- Add "components" document to easily copy & paste sections of the readme
- Return xml and json
- Json
- xml
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
If you want to improve the development of this project, you must, after changing or improving whatever, run the project's tests to prove that they are working.
Distributed under the MIT License. See LICENSE.txt
for more information.
Cameron Young - @sigfualt - [email protected]
Use this space to list resources you find helpful and would like to give credit to. I've included a few of my favorites to kick things off!