Programming Tips ๐Ÿ’ก
51.6K subscribers
67 photos
10 videos
30 files
354 links
Programming & AI:
Tips ๐Ÿ’ก
Articles ๐Ÿ“•
Resources ๐Ÿ‘พ
Design Patterns ๐Ÿ’Ž
Software Principles โœ…

๐Ÿ‡ณ๐Ÿ‡ฑ Contact: @MoienTajik

๐ŸŽฏ Buy ads: https://telega.io/c/ProgrammingTip
Download Telegram
WireMock.NET ๐Ÿ˜ฎ

WireMock.NET is a .NET library for stubbing and mocking HTTP services. With WireMock.NET, you can define the expected responses for particular requests, and the library will intercept and manage those requests for you. โœ”๏ธ

This allows for easy testing of the code that makes HTTP requests, without having to rely on the actual external service being available and without hacking HttpClient. ๐Ÿ†’

Sample code snippet:

[Test]
public async Task sample_WireMock_usage()
{
// Setup WireMock.Net server
using var wireMock = WireMockServer.StartWithAdminInterface(port: 1080, ssl: false);

// Setup WebApplicationFactory
await using var appFactory = new WebApplicationFactory<Program>().WithWebHostBuilder(builder =>
{
builder.ConfigureAppConfiguration(configurationBuilder =>
{
// Override downstream service addresses pointing to WireMock address
configurationBuilder.AddInMemoryCollection(new Dictionary<string, string>
{
["ExternalServices:WeatherService"] = "http://localhost:1080"
});
});
});

// Prepare stub for outgoing request
wireMock
.Given(
Request.Create()
.WithPath("/api/v1.0/weather")
.WithParam("lat", "10.99")
.WithParam("lon", "44.34")
.UsingGet()
)
.RespondWith(
Response.Create()
.WithStatusCode(200)
.WithHeader("Content-Type", "application/json; charset=utf-8")
.WithBodyAsJson(new
{
temp = 298.48,
feels_like = 298.74,
temp_min = 297.56,
temp_max = 300.05,
pressure = 1015,
humidity = 64
})
);

// Automate tested app
}


[ Blog ] : https://cezarypiatek.github.io/post/mocking-outgoing-http-requests-p1

ใ€ฐ๏ธใ€ฐ๏ธใ€ฐ๏ธใ€ฐ๏ธใ€ฐ๏ธใ€ฐ๏ธ
#UnitTest #DotNet #CSharp
@ProgrammingTip
Please open Telegram to view this post
VIEW IN TELEGRAM
A Structured Roadmap to Master Software Testing for Developers ๐Ÿš€

Struggling to navigate the world of testing? ๐Ÿ’ญ
Iโ€™ve compiled a comprehensive roadmap to help developers learn testing concepts systematicallyโ€”whether you're a beginner or looking to fill gaps in your knowledge.

๐Ÿ” Whatโ€™s Inside?
โœ… Core Testing Concepts (White/Gray/Black Box)
โœ… Test Design (Equivalence Partitioning, Boundary Analysis, etc.)
โœ… Naming Standards
โœ… Patterns (AAA, Four-Phase, BDD with Gherkin)
โœ… Test Types (Unit, Integration, E2E, Performance, etc.)
โœ… Tools & Frameworks (xUnit, Playwright, K6, AutoFixture, etc.)
โœ… Best Practices (Clean Test Code, Test Smells, Coverage)
โœ… Static Analysis & CI/CD Integration


๐Ÿ“Œ Highlights
Self-assessment friendly โ†’ Track your progress.

Language-agnostic โ†’ Examples in .NET, JS, Python, PHP.

Practical focus โ†’ From TDD/BDD to CI/CD pipelines.


[GitHub] : https://github.com/hasanxdev/Test-Roadmap-For-Developers

ใ€ฐ๏ธใ€ฐ๏ธใ€ฐ๏ธใ€ฐ๏ธใ€ฐ๏ธใ€ฐ๏ธ

#Test #Roadmap #UnitTest #IntegrationTest

@ProgrammingTip