Пример #1
0
        public void E2ESimplestApp()
        {
            var            app   = new ConsoleApp(1, 1);
            var            panel = app.LayoutRoot.Add(new SpacetimePanel(1, 1));
            SpacialElement element;
            TimeSpan       lastAge = TimeSpan.Zero;

            panel.SpaceTime.QueueAction(() =>
            {
                element = new SpacialElement();
                panel.SpaceTime.Add(element);

                panel.SpaceTime.Add(TimeFunction.Create(() =>
                {
                    lastAge = element.CalculateAge();
                    if (Time.CurrentTime.Now == TimeSpan.FromSeconds(.5))
                    {
                        Time.CurrentTime.Stop();
                        app.Stop();
                    }
                }));
            });

            panel.SpaceTime.Start();
            app.Start().Wait();
            Assert.AreEqual(.5, lastAge.TotalSeconds);
        }
Пример #2
0
        public void E2ESimplestApp()
        {
            var            app   = new ConsoleApp(1, 1);
            var            panel = app.LayoutRoot.Add(new SpaceTimePanel(1, 1));
            SpacialElement element;
            TimeSpan       lastAge = TimeSpan.Zero;

            panel.SpaceTime.InvokeNextCycle(() =>
            {
                element = new SpacialElement();
                panel.SpaceTime.Add(element);

                panel.SpaceTime.Invoke(async() =>
                {
                    lastAge = element.CalculateAge();
                    if (Time.CurrentTime.Now == TimeSpan.FromSeconds(.5))
                    {
                        Time.CurrentTime.Stop();
                    }
                    await Time.CurrentTime.YieldAsync();
                });
            });

            panel.SpaceTime.Start().Then(() => app.Stop());
            app.Start().Wait();
            Assert.AreEqual(.5, lastAge.TotalSeconds);
        }