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); }
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); }
public void Serialize <T>(T value) { var stringWriter = new StringWriter(); _converter.Serialize(value, stringWriter); var actual = stringWriter.ToString(); actual.Should().Be(JsonConvert.SerializeObject(value)); }
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); }
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); } }