public void Simple_Upcast_of_single_event()
        {
            StaticUpcaster.Clear();
            StaticUpcaster.RegisterUpcaster(new UpcastedEvent.Upcaster());
            var evt      = new UpcastedEvent("Hello world");
            var upcasted = StaticUpcaster.UpcastEvent(evt);

            Assert.That(upcasted, Is.InstanceOf <NewEvent>());

            var upcastedEvent = (NewEvent)upcasted;

            Assert.That(upcastedEvent.RenamedProperty, Is.EqualTo("Hello world"));
        }
        public void Chain_of_upcast()
        {
            StaticUpcaster.Clear();
            StaticUpcaster.RegisterUpcaster(new UpcastedEvent.Upcaster());
            StaticUpcaster.RegisterUpcaster(new ReallyOldEvent.Upcaster());

            var evt      = new ReallyOldEvent(42);
            var upcasted = StaticUpcaster.UpcastEvent(evt);

            Assert.That(upcasted, Is.InstanceOf <NewEvent>());

            var upcastedEvent = (NewEvent)upcasted;

            Assert.That(upcastedEvent.RenamedProperty, Is.EqualTo("Property 42"));
        }
        /// <summary>
        /// Enchance and upcast the event.
        /// </summary>
        public void EnhanceAndUpcastEvent()
        {
            if (_enhanced == false && Event is DomainEvent)
            {
                _enhanced = true;
                var domainEvent = Event as DomainEvent;

                domainEvent.CommitId        = CommitId;
                domainEvent.Version         = Version;
                domainEvent.Context         = Context;
                domainEvent.CheckpointToken = CheckpointToken;

                Event = StaticUpcaster.UpcastEvent(domainEvent);
            }
        }