Exemplo n.º 1
0
        public void Json_CaseInsensitive()
        {
            var json = @"{ ""prop_a"":22047748656944,""prop_b"":281179222,""prop_c"":4,""prop_d"":4}";

            var serializer = new JsonEventDeserializer <CustomModel>(StandardResolver.SnakeCase);

            var result = (CustomModel)serializer.Deserialize(Encoding.UTF8.GetBytes(json)).Event;

            result.PropA.Should().Be(22047748656944);
            result.PropB.Should().Be(281179222);
            result.PropC.Should().Be(4);
        }
        public void WhenDataIsNotNullThenShouldSerializeWithExpectedValueNonGeneric()
        {
            var serializer = new JsonEventDeserializer();

            var result = (FakeEvent)serializer.Deserialize(_json, typeof(FakeEvent));

            result.Should().NotBeNull();
            result.Id.Should().Be(EventId.From(Guid.Parse("5eb0ea02-7dde-4730-bd61-09fcf1065e11").ToString()));
            result.Subject.Should().Be(Guid.Parse("fdfbd5b3-cafb-4376-a3fa-7f74c20a0188").ToString());
            result.Timestamp.Should().Be(DateTimeOffset.MaxValue);
            result.Version.Should().Be(3);
        }
Exemplo n.º 3
0
        public void JsonSerializing()
        {
            var fixture = new Fixture();
            var e       = fixture.Create <RedEvent>();

            var serializer = new JsonEventDeserializer <RedEvent>();

            var bytes = JsonSerializer.Serialize(e);

            var deserialized = serializer.Deserialize(bytes);

            deserialized.Event.Should().BeEquivalentTo(e);
        }