Ejemplo n.º 1
0
        public void SerializeAndDeserializeEventWithEnumerationOfKeys()
        {
            Converts.Repository
            .AddJsonEnumSearchHandler()
            .AddJsonObjectSearchHandler()
            .AddJsonPrimitivesSearchHandler()
            .AddJsonKey()
            .AddJsonTimeSpan();

            IFormatter formatter = new CompositeEventFormatter(
                new ReflectionCompositeTypeProvider(
                    new ReflectionCompositeDelegateFactory(),
                    BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public
                    ),
                new DefaultFactory <JsonCompositeStorage>()
                );

            IKey  orderKey = KeyFactory.Create(typeof(Order));
            Order order    = new Order(orderKey);

            order.AddItem(KeyFactory.Create(typeof(Product)), 4);

            OrderItemSummaryChanged changed = order.Events.OfType <OrderItemSummaryChanged>().First();

            string json = formatter.Serialize(changed);

            changed = formatter.Deserialize <OrderItemSummaryChanged>(json);

            Assert.AreEqual(1, changed.ProductKeys.Count());
        }
Ejemplo n.º 2
0
 Task IEventHandler <OrderItemSummaryChanged> .HandleAsync(OrderItemSummaryChanged payload)
 {
     return(Task.FromResult(true));
 }