public void DelaySecondsWithSerialization() { var t = new CoroutineTestClass(_output); var exc = new CoroutineExecutor(); var thread = exc.Start(t.DelaySeconds(1)); Assert.True(thread.Status == CoroutineThreadStatus.Yielded); exc.Tick(TimeSpan.FromSeconds(0.55)); Assert.True(thread.Status == CoroutineThreadStatus.Yielded); exc.Tick(TimeSpan.FromSeconds(0.55)); Assert.True(thread.Status == CoroutineThreadStatus.Yielded); var serializer = new JsonSerializer(); serializer.Converters.Add(new CoroutineConverter(true, false)); var settings = new JsonSerializerSettings { Formatting = Formatting.Indented, Converters = new JsonConverter[] { new CoroutineConverter(true, false), new NameValueDictionaryConverter() }, TypeNameHandling = TypeNameHandling.Auto }; string resultString = JsonConvert.SerializeObject(exc, settings); //var dcss = new DataContractSerializerSettings {PreserveObjectReferences = true}; //var dcs = new DataContractSerializer(typeof(CoroutineExecutor), dcss); //var ms = new MemoryStream(); //dcs.WriteObject(ms, exc); //var dat = ms.ToArray(); //var mss = Encoding.UTF8.GetString(dat, 0, dat.Length); exc.Tick(TimeSpan.FromSeconds(0.55)); Assert.True(thread.Status == CoroutineThreadStatus.Finished); var desexc = JsonConvert.DeserializeObject <CoroutineExecutor>(resultString, settings); }
public void DelaySecondsWithSerialization() { var t = new CoroutineTestClass(_output); var exc = new CoroutineExecutor(); var thread = exc.Start(t.DelaySeconds(1)); Assert.True(thread.Status == CoroutineThreadStatus.Yielded); exc.Tick(TimeSpan.FromSeconds(0.55)); Assert.True(thread.Status == CoroutineThreadStatus.Yielded); exc.Tick(TimeSpan.FromSeconds(0.55)); Assert.True(thread.Status == CoroutineThreadStatus.Yielded); var serializer = new JsonSerializer(); serializer.Converters.Add(new CoroutineConverter(true, false)); var settings = new JsonSerializerSettings { Formatting = Formatting.Indented, Converters = new JsonConverter[] { new CoroutineConverter(true, false), new NameValueDictionaryConverter() }, TypeNameHandling = TypeNameHandling.Auto }; string resultString = JsonConvert.SerializeObject(exc, settings); //var dcss = new DataContractSerializerSettings {PreserveObjectReferences = true}; //var dcs = new DataContractSerializer(typeof(CoroutineExecutor), dcss); //var ms = new MemoryStream(); //dcs.WriteObject(ms, exc); //var dat = ms.ToArray(); //var mss = Encoding.UTF8.GetString(dat, 0, dat.Length); exc.Tick(TimeSpan.FromSeconds(0.55)); Assert.True(thread.Status == CoroutineThreadStatus.Finished); var desexc = JsonConvert.DeserializeObject<CoroutineExecutor>(resultString, settings); }
public void DelaySecondsNoSerialization() { var t = new CoroutineTestClass(_output); var exc = new CoroutineExecutor(); var thread = exc.Start(t.DelaySeconds(1)); Assert.True(thread.Status == CoroutineThreadStatus.Yielded); exc.Tick(TimeSpan.FromSeconds(0.55)); Assert.True(thread.Status == CoroutineThreadStatus.Yielded); exc.Tick(TimeSpan.FromSeconds(0.55)); Assert.True(thread.Status == CoroutineThreadStatus.Yielded); exc.Tick(TimeSpan.FromSeconds(0.55)); Assert.True(thread.Status == CoroutineThreadStatus.Finished); }