Exemple #1
0
        public void SerializeToTextWriter(BigObject obj)
        {
            var writer = new StringWriter();

            _converter.Serialize(obj, writer);

            var serialized = writer.ToString();
            var result     = JsonConvert.DeserializeObject <BigObject>(serialized);

            result.Should().BeEquivalentTo(obj);
        }
Exemple #2
0
        public void DeserializeActors()
        {
            var provider = new DependencyCollection()
                           .AddECS()
                           .AddAssets(ctx => _assets)
                           .BuildProvider();

            var serialized = _jsonConverter.Serialize(_actors);

            using var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(serialized));

            var actors       = provider.GetRequired <IActorContext>();
            var actorsSource = provider.Activate <JsonStreamSource <Actor> >(new LocalList <object>(memoryStream));

            actors.Load(actorsSource);

            actors.Should().Contain(_actors);
        }
Exemple #3
0
        public void Serialize <T>(T value)
        {
            var stringWriter = new StringWriter();

            _converter.Serialize(value, stringWriter);

            var actual = stringWriter.ToString();

            actual.Should().Be(JsonConvert.SerializeObject(value));
        }
Exemple #4
0
        public long Velo()
        {
            long stub = 0;

            for (var i = 0; i < _dataset.Length; i++)
            {
                var element    = _dataset[i];
                var serialized = _converter.Serialize(element);
                stub += serialized.Length;
            }

            return(stub);
        }
Exemple #5
0
        public void Serialize_Array_Object(Boo[] array)
        {
            var json         = _converter.Serialize(array);
            var deserialized = JsonConvert.DeserializeObject <Boo[]>(json);

            for (var i = 0; i < array.Length; i++)
            {
                var element             = array[i];
                var deserializedElement = deserialized[i];

                Assert.Equal(element.Bool, deserializedElement.Bool);
                Assert.Equal(element.Double, deserializedElement.Double);
                Assert.Equal(element.Float, deserializedElement.Float);
                Assert.Equal(element.Int, deserializedElement.Int);
            }
        }