public void AddConverter_ByType() { var anEvent = CreateEvent(); var converter = new EventConverter(_typeResolver); converter.AddConverter(typeof(AnEvent), _childConverter); converter.Upgrade(anEvent); _childConverter.AssertWasCalled(x => x.Upgrade(anEvent)); }
private static IEventStore InitializeEventStore() { var typeResolver = new AttributeEventTypeResolver(); typeResolver.AddAllEventsInAssembly(typeof(Program).Assembly); var converter = new EventConverter(typeResolver); converter.AddConverter(typeof(NameChangedEvent), new NameChangedEventPostConverter()); converter.AddConverter(typeof(PersonCreatedEvent), new PersonCreatedEventPostConverter()); var eventStore = new MsSqlServerEventStore(ConfigurationManager.ConnectionStrings["EventStore"].ConnectionString, typeResolver, converter); return eventStore; }
public void Upgrade() { var event1 = CreateEvent("foo"); var event2 = CreateEvent("bar"); var fooConverter = MockRepository.GenerateStub<IEventConverter>(); var barConverter = MockRepository.GenerateStub<IEventConverter>(); var converter = new EventConverter(_typeResolver); converter.AddConverter("foo", fooConverter); converter.AddConverter("bar", barConverter); converter.Upgrade(event1); converter.Upgrade(event2); fooConverter.AssertWasCalled(x => x.Upgrade(event1)); barConverter.AssertWasCalled(x => x.Upgrade(event2)); }
public void AddConverter_ByType_converter_null() { var converter = new EventConverter(_typeResolver); var ex = Assert.Throws<ArgumentNullException>(() => converter.AddConverter(typeof(AnEvent), null)); ex.ParamName.Should().Be("converter"); }
public void AddConverter_ByType_eventType_null() { var converter = new EventConverter(_typeResolver); var ex = Assert.Throws<ArgumentNullException>(() => converter.AddConverter((Type) null, _childConverter)); ex.ParamName.Should().Be("eventType"); }
public void Upgrade_theEvent_null() { var converter = new EventConverter(_typeResolver); var ex = Assert.Throws<ArgumentNullException>(() => converter.Upgrade(null)); ex.ParamName.Should().Be("theEvent"); }
public void Upgrade_unknown_event() { var converter = new EventConverter(_typeResolver); Assert.DoesNotThrow(() => converter.Upgrade(CreateEvent())); }
public void AddConverter_duplicate_name() { var converter = new EventConverter(_typeResolver); converter.AddConverter(EventName, _childConverter); var ex = Assert.Throws<ArgumentException>(() => converter.AddConverter(EventName, _childConverter)); ex.ParamName.Should().Be("eventName"); ex.Message.Should().StartWith("There is already a converter for event 'bob'."); }
public void Upgrade_unknown_event() { var converter = new EventConverter(_typeResolver); converter.Upgrade(CreateEvent()); }
public void Ctor() { var converter = new EventConverter(_typeResolver); }