public void TestSelectorCompletesOnFirstSucceed()
        {
            var selector = new Selector("", 1, 1);

            selector.AddChild(TestingResources.GetRunRunFail());
            selector.AddChild(TestingResources.GetRunRunSuccess());

            //all of these should be ignored
            //TODO: Should probably check if these are run anyways
            //      through the Concat operation
            selector.AddChild(TestingResources.GetRunRunFail());
            selector.AddChild(TestingResources.GetRunRunFail());
            selector.AddChild(TestingResources.GetRunRunFail());
            selector.AddChild(TestingResources.GetRunRunFail());

            var actual = new List <BehaviorState>();

            var expected = new List <BehaviorState>();

            expected.Add(BehaviorState.Running);
            expected.Add(BehaviorState.Success);

            selector.Start().Subscribe((x) => actual.Add(x));

            Assert.AreEqual(expected, actual);
        }
        public void TestSequencerFailsOnAnyFail()
        {
            var sequencer = new Sequencer("", 1, 1);

            sequencer.AddChild(TestingResources.GetRunRunFail());

            var actual = new List <BehaviorState>();

            var expected = new List <BehaviorState>();

            expected.Add(BehaviorState.Fail);

            sequencer.Start().Subscribe((x) => actual.Add(x));

            Assert.AreEqual(expected, actual);
        }
        public void TestInverterInvertsFail()
        {
            var inverter = new Inverter("", 1, 1);

            inverter.Children.Add(TestingResources.GetRunRunFail());

            var actual = new List <BehaviorState>();

            var expected = new List <BehaviorState>();

            expected.Add(BehaviorState.Success);

            inverter.Start().Subscribe((x) => actual.Add(x));

            Assert.AreEqual(expected, actual);
        }
        public void TestSelectorFailsIfNoneSucceed()
        {
            var selector = new Selector("", 1, 1);

            selector.AddChild(TestingResources.GetRunRunFail()); //should be "running"
            selector.AddChild(TestingResources.GetRunRunFail()); //should be "running"

            var actual = new List <BehaviorState>();

            var expected = new List <BehaviorState>();

            expected.Add(BehaviorState.Running);
            expected.Add(BehaviorState.Running);
            expected.Add(BehaviorState.Fail);

            selector.Start().Subscribe((x) => actual.Add(x));
            Assert.AreEqual(expected, actual);
        }
Example #5
0
        public void TestMergeFailRatioFails()
        {
            var runner = new Merge("", 1, 1);

            runner.SucceedFailPercentForSucceess = 40;            //under 40% succeed should fail

            runner.AddChild(TestingResources.GetRunRunSuccess()); //success = 1/1
            runner.AddChild(TestingResources.GetRunRunFail());    //success = 1/2
            runner.AddChild(TestingResources.GetRunRunFail());    //publish fail, success = 1/3
            var actual = new List <BehaviorState>();

            var expected = new List <BehaviorState>();

            expected.Add(BehaviorState.Running);
            expected.Add(BehaviorState.Running);
            expected.Add(BehaviorState.Running);
            expected.Add(BehaviorState.Fail);

            runner.Start().Subscribe((x) => actual.Add(x));

            Assert.AreEqual(expected, actual);
        }
Example #6
0
        public void TestMergeSucceedRatioSucceeds()
        {
            var runner = new Merge("", 1, 1);

            runner.SucceedFailPercentForSucceess = 51;            //over 50% succeed should succeed

            runner.AddChild(TestingResources.GetRunRunSuccess()); //publish running, success = 1/1
            runner.AddChild(TestingResources.GetRunRunSuccess()); //publish running, success = 2/2
            runner.AddChild(TestingResources.GetRunRunFail());    //publish running, success = 2/3
                                                                  //publish success, success = 2/3

            var actual = new List <BehaviorState>();

            var expected = new List <BehaviorState>();

            expected.Add(BehaviorState.Running);
            expected.Add(BehaviorState.Running);
            expected.Add(BehaviorState.Running);
            expected.Add(BehaviorState.Success);

            runner.Start().Subscribe((x) => actual.Add(x));

            Assert.AreEqual(expected, actual);
        }