Skip to content

Instantly share code, notes, and snippets.

View phatboyg's full-sized avatar

Chris Patterson phatboyg

View GitHub Profile
[Test]
public void mock()
{
Func<int,int> mocked = MockRepository.GenerateMock<Func<int, int>>();
mocked.Expect(x => x(27)).Return(47);
int result = mocked(27);
mocked.VerifyAllExpectations();
ObjectFactory.Configure(x =>
{
x.AddRegistry(new ServerRegistry());
});
public class ServerRegistry : MassTransitRegistryBase {
public ServerRegistry()
{
RegisterControlBus("msmq://localhost/test_server_control", x => { });
// message sender coder
IServiceBus bus = ObjectFactory.GetInstance<IServiceBus>();
var message = new MyCommand { Text = "How's it going?" };
ObjectFactory.GetInstance<IEndpointFactory>().GetEndpoint("msmq://localhost/test_server").Send(message, x => x.SendResponseTo(bus));
/// - snip
internal class Program
{
private static void Main(string[] args)
{
RunConfiguration configuration = RunnerConfigurator.New(x =>
{
x.SetServiceName("CalebMailService");
x.SetDisplayName("Caleb's Mail Service");
x.SetDescription("Give you some sexy mail service");
@phatboyg
phatboyg / .gitconfig
Created March 24, 2010 12:17
Git Config
[core]
autoCRLF = false
editor = c:/bin/git/npp.cmd
[diff]
tool = kd3
[merge]
tool = kd3
[difftool "kd3"]
cmd = c:/bin/git/kdiff3.cmd \"$LOCAL\" \"$REMOTE\"
[difftool]
public class SimpleExample
{
public void SomeMethod<T>(T arg)
{
DoSomethingWith(arg);
}
}
@phatboyg
phatboyg / ActorSyntax.cs
Created November 10, 2010 16:00
Examinations on how actors should work
public class CustomerAccount :
Actor
{
string _name;
public void Handle(Message<UpdateName> msg)
{
_name = msg.Name;
}
}
@phatboyg
phatboyg / MassTransitConsumer.cs
Created June 29, 2011 01:48 — forked from jrutley/Ping.cs
MassTransit 2.0 beta questions (updated to allow run from different machines)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MassTransit;
using MassTransitExperimentShared;
using System.Threading;
namespace MassTransitConsumer
{
@phatboyg
phatboyg / SagaTrace.txt
Created June 29, 2011 19:00
Output from Trace
-------------------------------------------------------------------------------------------------------------------------------------------
Trace URI: msmq://localhost/mt_subscriptions 15 messages
-------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------
Received: c940f977-ff3f-4195-99a5-9f110121ddd9 2011-06-29 05:35:20.614
---------------------------------------------------------------------------------------------------------------------------------------
Message Id: ad32c234-567b-4691-9f2f-314e31498c8a\1067975
Source Address: msmq://localhost/mt_subscriptions?tx=false
Input Address: msmq:
@phatboyg
phatboyg / MyActor.cs
Created July 27, 2011 13:49
How to stage build actors in an actor chain/network
public class MyActor :
Actor
{
public MyActor(Inbox inbox)
{
inbox.Receive<InitMyActor>(initMsg =>
{
var myActorScopeValue = initMsg.Scope;
inbox.Loop(loop =>