public MessageHandling(string path = "calculator.db") { var es = new FilesInFolderEventstore(path); _mp = new MessagePump(es); _mp.RegisterCommandPipeline(new ExpandNumberPipeline()); _mp.RegisterQueryPipeline(new NumberPipeline()); _mp.RegisterQueryPipeline(new ResultPipeline()); _mp.RegisterCommandPipeline(new AppendOperatorPipeline()); }
public MessageHandling(IEventstore es) { _ms = new MessagePump(es); _ms.RegisterCommandPipeline(new StartGamePipeline()); _ms.RegisterCommandPipeline(new PlaceTokenPipeline()); _ms.RegisterQueryPipeline(new GamePipeline()); }
public void Run() { const string PATH = "msgpump_tests"; if (Directory.Exists(PATH)) { Directory.Delete(PATH, true); } var es = new FilesInFolderEventstore(PATH); var sut = new MessagePump(es); sut.RegisterCommandPipeline(new IncrementPipeline()); sut.RegisterCommandPipeline(new DecrementPipeline()); sut.RegisterQueryPipeline(new CounterValuePipeline()); var result = sut.Handle(new Increment { CounterId = "a" }); Assert.IsType <Success>(result.response); result = sut.Handle(new Increment { CounterId = "b" }); Assert.IsType <Success>(result.response); result = sut.Handle(new Increment { CounterId = "a" }); Assert.IsType <Success>(result.response); var qresult = sut.Handle <CounterValue.Result>(new CounterValue { CounterId = "a" }); Assert.Equal(2, qresult.response.Value); result = sut.Handle(new Decrement() { CounterId = "x" }); Assert.IsType <Failure>(result.response); result = sut.Handle(new Decrement() { CounterId = "a" }); Assert.IsType <Success>(result.response); qresult = sut.Handle <CounterValue.Result>(new CounterValue { CounterId = "a" }); Assert.Equal(1, qresult.response.Value); }