public void Single(
            [Values(VarType.N)] VarType outerBound,
            [Values(OpType.Increase)] OpType outerOp,
            [Values(VarType.Const)] VarType outerStep,
            [Values(VarType.N)] VarType innerBound,
            [Values(OpType.Multiply)] OpType innerOp,
            [Values(VarType.Prev)] VarType innerStep
            )
        {
            var random   = new Random(1224);
            var outer    = new Loop(outerBound, outerOp, outerStep);
            var inner    = new Loop(innerBound, innerOp, innerStep);
            var exercise = new DoubleLoopExercise(outer, LoopType.For, inner, LoopType.For);

            exercise.GetComplexity()
            .Should()
            .Be(ComplexityChecker.Check(exercise), exercise.GetCode(random));
        }
        public void TestAllCases(
            [Values(VarType.Const, VarType.N)] VarType outerBound,
            [Values(OpType.Increase, OpType.Multiply)] OpType outerOp,
            [Values(VarType.Const, VarType.N)] VarType outerStep
            )
        {
            var varTypes = Enum.GetValues(typeof(VarType)).Cast <VarType>();
            var random   = new Random(1224);

            foreach (var innerStep in varTypes)
            {
                var outer    = new Loop(outerBound, outerOp, outerStep);
                var exercise = new SingleLoopExercise(outer, LoopType.For);
                exercise.GetComplexity()
                .Should()
                .Be(ComplexityChecker.Check(exercise), exercise.GetCode(random));
            }
        }
Exemple #3
0
 public Complexity GetComplexity() => ComplexityChecker.Check(this);