Skip to content

Instantly share code, notes, and snippets.

View moodmosaic's full-sized avatar

Nikos Baxevanis moodmosaic

View GitHub Profile
@moodmosaic
moodmosaic / BuildHttpSelfHostServer.cs
Created May 11, 2012 10:19
Draft: Minimum code required to initialize Windsor and return a new HttpSelfHostServer instance. (Work in-progress.)
private static HttpSelfHostServer BuildHttpSelfHostServer(string baseAddress)
{
var configuration = new HttpSelfHostConfiguration(baseAddress);
configuration.DependencyResolver =
new WindsorDependencyResolver(
new WindsorContainer()
.Install(new WebWindsorInstaller()));
configuration.Routes.MapHttpRoute(
@moodmosaic
moodmosaic / Equality_Behaves_As_Expected.cs
Last active December 15, 2015 07:39
A discussion branch for a question about Likeness on Stack Overflow.
// http://stackoverflow.com/questions/15558873/trouble-using-autofixtures-createproxy-to-use-likeness-semanticcomparison-feat
[Fact]
public void Equality_Behaves_As_Expected()
{
var template = new Fixture().Create<Band>();
var createdBand = new Band
{
Brass = template.Brass,
@moodmosaic
moodmosaic / Test_With_InlineAutoMockDataAttribute.cs
Last active December 16, 2015 12:28
A discussion branch for a question on Stack Overflow about using AutoFixture declaratively.
// http://stackoverflow.com/questions/16145284/autofixture-how-to-express-the-following-code-declaratively/16145954?noredirect=1#16145284
public class Tests
{
[Theory]
[InlineAutoMockData(@"-o=C:\Temp\someFile -p=1")]
[InlineAutoMockData(@"-p=1 -o=C:\Temp\someFile")]
public void ParseMissingParameterShouldReturnCorrectResult(
string argsString,
SomeClass sut)
@moodmosaic
moodmosaic / Ploeh.AutoFixture.js
Last active December 18, 2015 20:29
Node.js sample adapter-module for AutoFixture via Edge.js
var create = require('edge').func(function () {/*
//#r "Ploeh.AutoFixture.dll"
using System;
using Ploeh.AutoFixture;
public class Startup
{
public async System.Threading.Tasks.Task<object> Invoke(object request)
@moodmosaic
moodmosaic / SemanticEqualityComparisonInFSharp.fs
Last active December 30, 2015 13:49
Compare complex object graphs with SemanticComparer<T>.
module SemanticEqualityComparisonInFSharp
open System
open System.Reflection
open Ploeh.SemanticComparison
open Xunit
open Xunit.Extensions
[<CustomEquality; NoComparison>]
type StructuralType =
@moodmosaic
moodmosaic / GreedyFactoryMethods.cs
Last active January 2, 2016 17:29
AutoFixture strategy for invoking Factory Methods with most parameters based on Twitter discussion on https://twitter.com/madstt/status/420850414641090560
internal class GreedyFactoryMethodQuery : IMethodQuery
{
public IEnumerable<IMethod> SelectMethods(Type type)
{
if (type == null)
throw new ArgumentNullException("type");
return from mi in type.GetMethods(
BindingFlags.Static | BindingFlags.Public)
where mi.ReturnType == type
@moodmosaic
moodmosaic / ApiControllerRegistration.cs
Created March 15, 2012 14:04
Post: Using the Web API Dependency Resolver with Castle Windsor
foreach (Type controller in typeof(OrderController).Assembly.GetTypes().Where(type => typeof(IHttpController).IsAssignableFrom(type)))
{
// https://github.com/srkirkland/Inflector/blob/5fd4c818dd172bbe276fb210f25c2e2ceaff019e/Inflector/Inflector.cs
string name = Inflector.Pluralize(controller.Name.Replace("Controller", ""));
container.Register(Component
.For(controller)
.Named(name)
.LifestylePerWebRequest());
}
# Last checked
# $ date
# Mon Feb 27 23:59:15 EEST 2017
2017-02-17 https://fsharpforfunandprofit.com/cap/
2017-02-17 https://fsharpforfunandprofit.com/turtle/
2017-02-17 https://fsharpforfunandprofit.com/video/
2016-12-05 https://fsharpforfunandprofit.com/posts/dependency-injection-1
2016-08-01 https://fsharpforfunandprofit.com/installing-and-using/
2016-06-23 https://fsharpforfunandprofit.com/parser/
@moodmosaic
moodmosaic / Main.hs
Created May 25, 2017 03:21
Servant example from "Write a client library for any web API in 5 minutes" https://haskell-servant.github.io/client-in-5-minutes.html
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
import Control.Applicative
import Control.Monad
import Control.Monad.IO.Class
import Control.Monad.Trans.Except
import Data.Aeson
We couldn’t find that file to show.