public void ParseDomainEventWrapper_NoKeyInRegistration() { var domainEventWrapper = new [] { new DomainEventWrapper { EntityStreamVersion = 12, OverallVersion = 0, DomainEvent = new Event1(Guid.NewGuid(), "Name") } }; var serializeObject = JsonConvert.SerializeObject(domainEventWrapper); var eventTypeRegistration = new EventRegistration(); var domainEventFactory = new DomainEventFactory(eventTypeRegistration); var ev = domainEventFactory.Deserialize(serializeObject); var domainEventWrappers = ev.ToList(); Assert.AreEqual(0, domainEventWrappers.Count); }
public void ParseDomainEventWrapper_StringKey() { var domainEventWrapper = new [] { new DomainEventWrapper { EntityStreamVersion = 12, OverallVersion = 0, DomainEvent = new Event2("luls", "Name") } }; var serializeObject = JsonConvert.SerializeObject(domainEventWrapper); var eventTypeRegistration = new EventRegistration { { nameof(Event2), typeof(Event2) } }; var domainEventFactory = new DomainEventFactory(eventTypeRegistration); var domainEventWrappers = domainEventFactory.Deserialize(serializeObject).ToList(); var wrapperActual = domainEventWrappers.Single(); Assert.AreEqual("luls", wrapperActual.DomainEvent.EntityId); }
public void ParseDomainEventWrapper() { var domainEventWrapper = new [] { new DomainEventWrapper { EntityStreamVersion = 12, OverallVersion = 1, DomainEvent = new Event1(Guid.NewGuid(), "Name") } }; var serializeObject = JsonConvert.SerializeObject(domainEventWrapper); var eventTypeRegistration = new EventRegistration { { nameof(Event1), typeof(Event1) } }; var domainEventFactory = new DomainEventFactory(eventTypeRegistration); var ev = domainEventFactory.Deserialize(serializeObject); var domainEventWrappers = ev.ToList(); var wrapperActual = domainEventWrappers.Single(); var wrapperExpected = domainEventWrapper.Single(); Assert.AreEqual(wrapperExpected.DomainEvent.EntityId, wrapperActual.DomainEvent.EntityId); Assert.AreEqual(wrapperExpected.EntityStreamVersion, wrapperActual.EntityStreamVersion); Assert.AreEqual(wrapperExpected.OverallVersion, wrapperActual.OverallVersion); Assert.AreEqual(((Event1)wrapperExpected.DomainEvent).Name, ((Event1)wrapperActual.DomainEvent).Name); }