Пример #1
0
        public void CurrentTimeStep_IncrementedOnTick()
        {
            TimedGraph <Guid> graph = new TimedGraph <Guid>(identProvider, 10);

            graph.Tick();
            Assert.AreEqual(1, graph.CurrentTimeStep);
        }
Пример #2
0
        public void AddTimedVertex_PresentAtStep2_InVertexSetAtStep2()
        {
            Func <Graph <Guid>, int, IEnumerable <Guid>, bool> presentAt2 =
                (g, t, e) => t == 2;

            TimedGraph <Guid>  graph = new TimedGraph <Guid>(identProvider, 5);
            TimedVertex <Guid> tv    = new TimedVertex <Guid>(identProvider, presentAt2);

            graph.AddTimedVertex(tv);
            graph.Tick(2);

            Assert.IsTrue(graph.Vertices.Contains(tv));
        }
Пример #3
0
        public void Presence_UsesAnonymousFunction()
        {
            TimedVertex <Guid> tv = new TimedVertex <Guid>(identProvider,
                                                           Present: (g, t, e) => t == 5);

            TimedGraph <Guid> graph = new TimedGraph <Guid>(identProvider, 10);

            graph.AddTimedVertex(tv);

            Assert.AreEqual(0, graph.CurrentTimeStep);
            Assert.IsFalse(tv.IsPresentAt(graph, graph.CurrentTimeStep));

            graph.Tick(5);
            Assert.AreEqual(5, graph.CurrentTimeStep);
            Assert.IsTrue(tv.IsPresentAt(graph, graph.CurrentTimeStep));
        }
Пример #4
0
        public void Tick_StepParam_ExceptionWhenParamTooLarge()
        {
            TimedGraph <Guid> graph = new TimedGraph <Guid>(identProvider, 20);

            graph.Tick(21);
        }
Пример #5
0
        public void Tick_NoParam_Exception_WhenTimestepExceedsMax()
        {
            TimedGraph <Guid> graph = new TimedGraph <Guid>(identProvider, 0);

            graph.Tick();
        }