public void TestLoop1() { var department5 = new FinishDepartment(); var department4 = new UnconditionalDepartment() { NewStamp = new Stamp() }; var department3 = new ConditionalDepartment( stampCondition: department4.NewStamp, ifDepartment: new UnconditionalDepartment(department5) { NewStamp = new Stamp() }, elseDepartment: new UnconditionalDepartment(department4) { NewStamp = new Stamp() } ); var department2 = new UnconditionalDepartment(department3) { NewStamp = new Stamp() }; var department1 = new UnconditionalDepartment(department2) { NewStamp = new Stamp() }; department4.SetNextDepartment(department2); var graphWorker = new GraphWorker( startDepartment: department1, finishDepartment: department5, targetDepartment: department5 ); graphWorker.Start(); graphWorker.Wait(); IReadOnlyList <IReadOnlyList <Stamp> > output = new List <List <Stamp> > { new List <Stamp> { department1.NewStamp, department2.NewStamp, department3.ElseDepartment.NewStamp, department4.NewStamp, department3.IfDepartment.NewStamp } }; Assert.True(IsEqual(graphWorker.GetResult(), output)); Assert.True(!graphWorker.IsEndlessLoop()); }
public void TestLoop2() { var d9 = new UnconditionalDepartment() { NewStamp = new Stamp() }; var d8 = new UnconditionalDepartment() { NewStamp = new Stamp() }; var d7 = new UnconditionalDepartment() { NewStamp = new Stamp() }; var d6 = new FinishDepartment(); var d5 = new ConditionalDepartment( stampCondition: d9.NewStamp, ifDepartment: new UnconditionalDepartment(d6) { NewStamp = new Stamp() }, elseDepartment: new UnconditionalDepartment(d9) { NewStamp = new Stamp() } ); var d4 = new ConditionalDepartment( stampCondition: d8.NewStamp, ifDepartment: new UnconditionalDepartment(d5) { NewStamp = new Stamp() }, elseDepartment: new UnconditionalDepartment(d8) { NewStamp = new Stamp() } ); var d3 = new ConditionalDepartment( stampCondition: d7.NewStamp, ifDepartment: new UnconditionalDepartment(d4) { NewStamp = new Stamp() }, elseDepartment: new UnconditionalDepartment(d7) { NewStamp = new Stamp() } ); var d2 = new UnconditionalDepartment(d3) { NewStamp = new Stamp() }; var d1 = new UnconditionalDepartment(d2); d9.SetNextDepartment(d2); d8.SetNextDepartment(d2); d7.SetNextDepartment(d2); var graphWorker = new GraphWorker( startDepartment: d1, finishDepartment: d6, targetDepartment: d2 ); graphWorker.Start(); graphWorker.Wait(); IReadOnlyList <IReadOnlyList <Stamp> > output = new List <List <Stamp> > { new List <Stamp> { d2.NewStamp }, new List <Stamp> { d2.NewStamp, d3.ElseDepartment.NewStamp, d7.NewStamp }, new List <Stamp> { d2.NewStamp, d3.ElseDepartment.NewStamp, d7.NewStamp, d3.IfDepartment.NewStamp, d4.ElseDepartment.NewStamp, d8.NewStamp }, new List <Stamp> { d2.NewStamp, d3.ElseDepartment.NewStamp, d7.NewStamp, d3.IfDepartment.NewStamp, d4.ElseDepartment.NewStamp, d8.NewStamp, d4.IfDepartment.NewStamp, d5.ElseDepartment.NewStamp, d9.NewStamp } }; Assert.True(IsEqual(graphWorker.GetResult(), output)); Assert.True(!graphWorker.IsEndlessLoop()); }