Skip to content

KamRon-67/MoqHttp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MoqHttp

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

MoqHttp

An awesome Moq Rest Client project to jumpstart your projects!

· Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

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.

(back to top)

Built With

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.

(back to top)

Getting Started

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.

Prerequisites

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

Installation

You should beable to download and run out of the box after a build.

(back to top)

Usage

    [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

Roadmap

  • 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).

(back to top)

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

💉 Project tests

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.

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Cameron Young - @sigfualt - [email protected]

(back to top)

Acknowledgments

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!

(back to top)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages