Example #1
0
        public void Deserialize()
        {
            var e = new TestEvent {
                Foo = "Hello!"
            };
            var serialized = EventSerialization.Serialize(e);

            var result = (TestEvent)EventSerialization.Deserialize(serialized);

            Assert.NotSame(e, result);
            Assert.Equal(e.Id, result.Id);
            Assert.Equal(e.Foo, result.Foo);
        }
Example #2
0
        public void EventSerialization_acceptance_test()
        {
            var myEvent = new MyEvent {
                Item = new ConcreteClass {
                    Number = 2,
                },
            };

            EventSerialization.JsonSerializerSettings = new JsonSerializerSettings {
                TypeNameHandling = TypeNameHandling.Auto,
            };

            var serializationResult   = EventSerialization.Serialize(myEvent);
            var deserializationResult = EventSerialization.Deserialize(serializationResult);

            Assert.IsType <ConcreteClass>(((MyEvent)deserializationResult).Item);
        }
        public Event Load(long index)
        {
            var text = File.ReadAllText(FilepathFor(index));

            return(EventSerialization.Deserialize(text));
        }