Skip to content

Instantly share code, notes, and snippets.

View Stefan-Ilic's full-sized avatar
🦈
Never stop swimming

Stefan Ilic Stefan-Ilic

🦈
Never stop swimming
  • Vienna, Austria
View GitHub Profile
@yetanotherchris
yetanotherchris / in-memory-http-server.cs
Last active February 4, 2024 14:00
In memory http server for C# unit and integration tests
public static Task BasicHttpServer(string url, string outputHtml)
{
return Task.Run(() =>
{
HttpListener listener = new HttpListener();
listener.Prefixes.Add(url);
listener.Start();
// GetContext method blocks while waiting for a request.
HttpListenerContext context = listener.GetContext();
@mariusschulz
mariusschulz / HtmlHelperExtensions.cs
Last active November 15, 2022 21:54
Two C# extension methods for inlining script and style bundles into the HTML response using ASP.NET MVC and the System.Web.Optimization framework.
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
public static class HtmlHelperExtensions
{
public static IHtmlString InlineScripts(this HtmlHelper htmlHelper, string bundleVirtualPath)
{
return htmlHelper.InlineBundle(bundleVirtualPath, htmlTagName: "script");
@asierba
asierba / unittestconsole.cs
Last active January 19, 2024 11:12
How to mock console in unit tests
class Program
{
public static void Main(string[] args)
{
Console.WriteLine("What's your name?");
var name = Console.ReadLine();
Console.WriteLine(string.Format("Hello {0}!!", name));
}
[Test]
@davidfowl
davidfowl / dotnetlayout.md
Last active June 3, 2024 23:39
.NET project structure
$/
  artifacts/
  build/
  docs/
  lib/
  packages/
  samples/
  src/
 tests/