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")); }
public void Simple_Upcast_of_changeset() { StaticUpcaster.Clear(); StaticUpcaster.RegisterUpcaster(new UpcastedEvent.Upcaster()); var cs = new Changeset(1, new object[] { new UpcastedEvent("Hello world") }); var upcasted = StaticUpcaster.UpcastChangeset(cs); Assert.That(object.ReferenceEquals(upcasted, cs)); Assert.That(upcasted, Is.InstanceOf <Changeset>()); var upcastedCs = (Changeset)upcasted; Assert.That(upcastedCs.Events.Single(), Is.InstanceOf <NewEvent>()); var upcastedEvent = (NewEvent)upcastedCs.Events.Single(); Assert.That(upcastedEvent.RenamedProperty, Is.EqualTo("Hello world")); }
public void Cannot_Register_two_distinct_upcasters() { StaticUpcaster.Clear(); StaticUpcaster.RegisterUpcaster(new UpcastedEvent.Upcaster()); Assert.Throws <ArgumentException>(() => StaticUpcaster.RegisterUpcaster(new UpcastedEvent.Upcaster())); }