Beispiel #1
0
        public void CheckCyclesShouldNotThrowWhenNoCycleExists()
        {
            engine = new DependencyEngine();
            var a = new SinglePropertyType();
            var b = new SinglePropertyType();

            engine.Assign(() => b.Value).From(() => a.Value * 2, ex => { });

            Should.NotThrow(() => engine.CheckCycles());
        }
Beispiel #2
0
        public void CheckCyclesShouldThrowWhenThereIsACycle()
        {
            engine = new DependencyEngine();
            var a = new SinglePropertyType();
            var b = new SinglePropertyType();

            engine.Assign(() => b.Value).From(() => a.Value * 2, ex => { });
            engine.Assign(() => a.Value).From(() => b.Value - 2, ex => { });

            var dot = engine.ToDotFormat("Title");

            Should.Throw <CycleDetectedException>(() => engine.CheckCycles())
            .Message.ShouldBe(@"1 cycles found:
a.Value --> (a.Value * 2) --> b.Value --> (b.Value - 2) --> a.Value");
        }
Beispiel #3
0
        public void CheckCyclesShouldThrowWhenThereAreTwoCycles()
        {
            engine = new DependencyEngine();
            var a = new SinglePropertyType();
            var b = new SinglePropertyType();
            var c = new SinglePropertyType();
            var d = new SinglePropertyType();

            engine.Assign(() => b.Value).From(() => a.Value * 2, ex => { });
            engine.Assign(() => a.Value).From(() => b.Value - 2, ex => { });

            engine.Assign(() => d.Value).From(() => c.Value * 2, ex => { });
            engine.Assign(() => c.Value).From(() => d.Value - 2, ex => { });

            Should.Throw <CycleDetectedException>(() => engine.CheckCycles())
            .Message.ShouldBe(@"2 cycles found:
a.Value --> (a.Value * 2) --> b.Value --> (b.Value - 2) --> a.Value
c.Value --> (c.Value * 2) --> d.Value --> (d.Value - 2) --> c.Value");
        }
Beispiel #4
0
        public void CheckCyclesShouldThrowWhenThereIsACycle()
        {
            engine = new DependencyEngine();
            var a = new SinglePropertyType();
            var b = new SinglePropertyType();

            engine.Assign(() => b.Value).From(() => a.Value * 2, ex => { });
            engine.Assign(() => a.Value).From(() => b.Value - 2, ex => { });

            var dot = engine.ToDotFormat("Title");

            Should.Throw<CycleDetectedException>(() => engine.CheckCycles())
                  .Message.ShouldBe(@"1 cycles found:
            a.Value --> (a.Value * 2) --> b.Value --> (b.Value - 2) --> a.Value");
        }
Beispiel #5
0
        public void CheckCyclesShouldThrowWhenThereAreTwoCycles()
        {
            engine = new DependencyEngine();
            var a = new SinglePropertyType();
            var b = new SinglePropertyType();
            var c = new SinglePropertyType();
            var d = new SinglePropertyType();

            engine.Assign(() => b.Value).From(() => a.Value * 2, ex => { });
            engine.Assign(() => a.Value).From(() => b.Value - 2, ex => { });

            engine.Assign(() => d.Value).From(() => c.Value * 2, ex => { });
            engine.Assign(() => c.Value).From(() => d.Value - 2, ex => { });

            Should.Throw<CycleDetectedException>(() => engine.CheckCycles())
                  .Message.ShouldBe(@"2 cycles found:
            a.Value --> (a.Value * 2) --> b.Value --> (b.Value - 2) --> a.Value
            c.Value --> (c.Value * 2) --> d.Value --> (d.Value - 2) --> c.Value");
        }
Beispiel #6
0
        public void CheckCyclesShouldNotThrowWhenNoCycleExists()
        {
            engine = new DependencyEngine();
            var a = new SinglePropertyType();
            var b = new SinglePropertyType();

            engine.Assign(() => b.Value).From(() => a.Value * 2, ex => { });

            Should.NotThrow(() => engine.CheckCycles());
        }