コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }