{"id":29483723,"url":"https://github.com/fabiojfl16/mockserver.aspire.hosting","last_synced_at":"2025-07-15T04:03:02.570Z","repository":{"id":257018108,"uuid":"857179756","full_name":"fabiojfl16/MockServer.Aspire.Hosting","owner":"fabiojfl16","description":"An extension to use MockServer container with .Net Aspire","archived":false,"fork":false,"pushed_at":"2024-09-27T19:16:33.000Z","size":125,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-24T09:50:45.154Z","etag":null,"topics":["aspire-dotnet","aspire-hosting","mockserver","nuget-package"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/MockServer.Aspire.Hosting","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fabiojfl16.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-14T01:31:47.000Z","updated_at":"2025-06-06T20:07:38.000Z","dependencies_parsed_at":"2024-09-17T16:44:25.309Z","dependency_job_id":null,"html_url":"https://github.com/fabiojfl16/MockServer.Aspire.Hosting","commit_stats":null,"previous_names":["fabiojfl16/mockserver.aspire.hosting"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fabiojfl16/MockServer.Aspire.Hosting","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiojfl16%2FMockServer.Aspire.Hosting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiojfl16%2FMockServer.Aspire.Hosting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiojfl16%2FMockServer.Aspire.Hosting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiojfl16%2FMockServer.Aspire.Hosting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fabiojfl16","download_url":"https://codeload.github.com/fabiojfl16/MockServer.Aspire.Hosting/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiojfl16%2FMockServer.Aspire.Hosting/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265401317,"owners_count":23758986,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aspire-dotnet","aspire-hosting","mockserver","nuget-package"],"created_at":"2025-07-15T04:01:29.839Z","updated_at":"2025-07-15T04:03:02.555Z","avatar_url":"https://github.com/fabiojfl16.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MockServer.Aspire.Hosting\nAn extension to use [MockServer](https://www.mock-server.com/) container with [.NET Aspire](https://github.com/dotnet/aspire). This is a great tool to mock external api dependencies and also for Integration tests implementation.\n\nInstall the **MockServer.Aspire.Hosting** NuGet Package in the **.AppHost** project of your solution, and add the following code in the Program.cs file\n```csharp\nvar mockserver = builder.AddMockServer(\"mockserver\", 1080);\n```\n\nThe **AddMockServer** method takes two parameters\n- The **name** used by Service Discovery: http://mockserver\n- The **port** MockServer should run on. The default port is 1080\n\n\u0026nbsp;\n\nNotice the **.WithExpectations** extension method. Here you can add a list of expectations that mockserver should respond\n```csharp\nvar mockserver = builder.AddMockServer(\"mockserver\", 1080)\n    .WithExpectations([MockServerExpectations.WheatherForecastExpectation]);\n```\n\nFor instance, this is the response mockserver should return for the GET method http://mockserver/api/weatherforecast\n```json\n\"httpRequest\": {\n\t\"method\": \"GET\",\n\t\"path\": \"/api/weatherforecast\",\n\t\"queryStringParameters\": {},\n\t\"cookies\": {}\n},\n\"httpResponse\": {\n\t\"body\": \n\t[\n\t\t{\"Date\":\"2024-09-14\",\"TemperatureC\":42,\"Summary\":\"Sweltering\",\"TemperatureF\":107},\n\t\t{\"Date\":\"2024-09-15\",\"TemperatureC\":-3,\"Summary\":\"Warm\",\"TemperatureF\":27},\n\t\t{\"Date\":\"2024-09-16\",\"TemperatureC\":43,\"Summary\":\"Freezing\",\"TemperatureF\":109},\n\t\t{\"Date\":\"2024-09-17\",\"TemperatureC\":9,\"Summary\":\"Cool\",\"TemperatureF\":48},\n\t\t{\"Date\":\"2024-09-18\",\"TemperatureC\":27,\"Summary\":\"Hot\",\"TemperatureF\":80}\n\t]\n}\n```\n\nAfter adding mockserver, you should include it as a reference for your Api\n\n```csharp\nbuilder.AddProject\u003cProjects.MockServer_Client_Web\u003e(\"webfrontend\")\n    .WithReference(mockserver);\n```\n\nTake a look at the sample project for better understanding.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabiojfl16%2Fmockserver.aspire.hosting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffabiojfl16%2Fmockserver.aspire.hosting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabiojfl16%2Fmockserver.aspire.hosting/lists"}