Exemplo n.º 1
0
        public void CanDeserializeToAbstractClass(IJsonSerializer serializer)
        {
            // Arrange
            var orderPlacedEvent = new OrderPlacedEvent
            {
                EventId    = "event-123",
                OrderId    = "order-123",
                OrderLines = new List <OrderLine>()
                {
                    new()
                    {
                        Quantity = 2m,
                        ItemId   = "item-123"
                    }
                }
            };

            // Act
            var serialized   = serializer.SerializeToJson(orderPlacedEvent);
            var deserialized = serializer.DeserializeJson <Event>(serialized);

            // Assert
            deserialized.Should().NotBeNull("the deserialization should have produced something");
            deserialized.Should().BeOfType <OrderPlacedEvent>("the deserialized instance should be an OrderPlacedEvent");
            deserialized.Should().BeEquivalentTo(orderPlacedEvent);
        }