Ejemplo n.º 1
0
 void MarkCellWithCounts(ExecuteParameters parameters, TestCounts beforeCounts)
 {
     string style = Processor.TestStatus.Counts.Subtract(beforeCounts).Style;
     if (!string.IsNullOrEmpty(style) && string.IsNullOrEmpty(parameters.Cell.GetAttribute(CellAttribute.Status))) {
         parameters.Cell.SetAttribute(CellAttribute.Status, style);
     }
 }
Ejemplo n.º 2
0
 void Input(ExecuteContext context, ExecuteParameters parameters)
 {
     var beforeCounts = new TestCounts(Processor.TestStatus.Counts);
     Processor.InvokeWithThrow(context.SystemUnderTest, GetMemberName(parameters.Members),
                      new CellTree(parameters.Cells));
     MarkCellWithLastResults(parameters, p => MarkCellWithCounts(p, beforeCounts));
 }
Ejemplo n.º 3
0
 void MarkCellWithLastResults(ExecuteParameters parameters, Action<ExecuteParameters> markWithCounts)
 {
     if (parameters.Cells != null && !string.IsNullOrEmpty(Processor.TestStatus.LastAction)) {
         parameters.Cell.SetAttribute(CellAttribute.Folded, Processor.TestStatus.LastAction);
         markWithCounts(parameters);
     }
     Processor.TestStatus.LastAction = null;
 }
Ejemplo n.º 4
0
 static void ShowActual(ExecuteParameters parameters, object actual)
 {
     parameters.Cell.AddToAttribute(
         CellAttribute.InformationSuffix,
         actual == null ? "null"
             : actual.ToString().Length == 0 ? "blank"
             : actual.ToString());
 }
Ejemplo n.º 5
0
        void Input(ExecuteContext context, ExecuteParameters parameters)
        {
            var beforeCounts = new TestCounts(Processor.TestStatus.Counts);

            Processor.InvokeWithThrow(context.SystemUnderTest, GetMemberName(parameters.Members),
                                      new CellTree(parameters.Cells));
            MarkCellWithLastResults(parameters, p => MarkCellWithCounts(p, beforeCounts));
        }
Ejemplo n.º 6
0
 public void LastActionIsSetAsInputCellAttribute()
 {
     SetUpSUT("procedure");
     var parameters = new ExecuteParameters(
         ExecuteParameters.MakeMemberCell(new CellTreeLeaf("procedure"), targetCell));
     execute.Execute(new ExecuteContext(ExecuteCommand.Input, target.Value), parameters);
     Assert.AreEqual("blah blah", targetCell.Value.GetAttribute(CellAttribute.Extension));
 }
Ejemplo n.º 7
0
 public void LastActionIsSetAsExpectedCellAttribute()
 {
     SetUpSUT("procedure");
     var parameters = new ExecuteParameters(
         ExecuteParameters.Make(new CellTreeLeaf("procedure"), new CellTree(), targetCell));
     execute.Execute(new ExecuteContext(ExecuteCommand.Check, target.Value), parameters);
     Assert.AreEqual("blah blah", targetCell.Value.GetAttribute(CellAttribute.Folded));
 }
Ejemplo n.º 8
0
 static void ShowActual(ExecuteParameters parameters, object actual)
 {
     parameters.Cell.AddToAttribute(
         CellAttribute.InformationSuffix,
         actual == null ? "null"
         : actual.ToString().Length == 0 ? "blank"
         : actual.ToString());
 }
Ejemplo n.º 9
0
 void MarkCellWithLastResults(ExecuteParameters parameters, Action <ExecuteParameters> markWithCounts)
 {
     if (parameters.Cells != null && !string.IsNullOrEmpty(Processor.TestStatus.LastAction))
     {
         parameters.Cell.SetAttribute(CellAttribute.Extension, Processor.TestStatus.LastAction);
         markWithCounts(parameters);
     }
     Processor.TestStatus.LastAction = null;
 }
Ejemplo n.º 10
0
        void MarkCellWithCounts(ExecuteParameters parameters, TestCounts beforeCounts)
        {
            string style = Processor.TestStatus.Counts.Subtract(beforeCounts).Style;

            if (!string.IsNullOrEmpty(style) && string.IsNullOrEmpty(parameters.Cell.GetAttribute(CellAttribute.Status)))
            {
                parameters.Cell.SetAttribute(CellAttribute.Status, style);
            }
        }
Ejemplo n.º 11
0
 private void EvaluateException(bool expression, ExecuteParameters parameters, TargetInvocationException e)
 {
     if (expression) {
         Processor.TestStatus.MarkRight(parameters.Cell);
     }
     else {
         Processor.TestStatus.MarkWrong(parameters.Cell, "exception[" + e.InnerException.GetType().Name + ": \"" + e.InnerException.Message + "\"]");
     }
 }
Ejemplo n.º 12
0
        public override TypedValue Execute(ExecuteContext context, ExecuteParameters parameters)
        {
            object value = GetActual(context, parameters);
            var symbol = new Symbol(parameters.Cell.Text.Substring(2), value);
            Processor.Store(symbol);

            parameters.Cell.AddToAttribute(CellAttribute.InformationSuffix, value == null ? "null" : value.ToString());

            return TypedValue.Void;
        }
Ejemplo n.º 13
0
 public override TypedValue Execute(ExecuteContext context, ExecuteParameters parameters)
 {
     try {
         object actual = GetActual(context, parameters);
         Processor.TestStatus.MarkWrong(parameters.Cell, actual.ToString());
     }
     catch {
         Processor.TestStatus.MarkRight(parameters.Cell);
     }
     return TypedValue.Void;
 }
Ejemplo n.º 14
0
        public override TypedValue Execute(ExecuteContext context, ExecuteParameters parameters)
        {
            object value  = GetActual(context, parameters);
            var    symbol = new Symbol(parameters.Cell.Text.Substring(2), value);

            Processor.Store(symbol);

            parameters.Cell.AddToAttribute(CellAttribute.InformationSuffix, value == null ? "null" : value.ToString());

            return(TypedValue.Void);
        }
Ejemplo n.º 15
0
 TypedValue Invoke(ExecuteContext context, ExecuteParameters parameters)
 {
     var beforeCounts = new TestCounts(Processor.TestStatus.Counts);
     TypedValue target = context.Target.Value;
     var targetObjectProvider = target.Value as TargetObjectProvider;
     string name = GetMemberName(parameters.Members);
     TypedValue result = Processor.Invoke(
             targetObjectProvider != null ? new TypedValue(targetObjectProvider.GetTargetObject()) : target,
             name, parameters.Parameters);
     MarkCellWithLastResults(parameters, p => MarkCellWithCounts(p, beforeCounts));
     return result;
 }
Ejemplo n.º 16
0
        TypedValue Invoke(ExecuteContext context, ExecuteParameters parameters)
        {
            var        beforeCounts         = new TestCounts(Processor.TestStatus.Counts);
            TypedValue target               = context.Target.Value;
            var        targetObjectProvider = target.Value as TargetObjectProvider;
            string     name   = GetMemberName(parameters.Members);
            TypedValue result = Processor.Invoke(
                targetObjectProvider != null ? new TypedValue(targetObjectProvider.GetTargetObject()) : target,
                name, parameters.Parameters);

            MarkCellWithLastResults(parameters, p => MarkCellWithCounts(p, beforeCounts));
            return(result);
        }
Ejemplo n.º 17
0
 void Check(ExecuteContext context, ExecuteParameters parameters)
 {
     try {
         TypedValue actual = GetTypedActual(context, parameters);
         if (Processor.Compare(actual, parameters.Cells)) {
             Processor.TestStatus.MarkRight(parameters.Cell);
         }
         else {
             Processor.TestStatus.MarkWrong(parameters.Cell, actual.ValueString);
         }
     }
     catch (IgnoredException) {}
     MarkCellWithLastResults(parameters, p => {});
 }
Ejemplo n.º 18
0
        public override TypedValue Execute(ExecuteContext context, ExecuteParameters parameters)
        {
            switch (context.Command) {
                case ExecuteCommand.Check:
                    Check(context, parameters);
                    break;

                case ExecuteCommand.Invoke:
                    return Invoke(context, parameters);

                default:
                    throw new ArgumentException(string.Format("Unrecognized operation '{0}'", context.Command));
            }
            return TypedValue.Void;
        }
Ejemplo n.º 19
0
        public override TypedValue Execute(ExecuteContext context, ExecuteParameters parameters)
        {
            switch (context.Command) {
                case ExecuteCommand.Input:
                    TypedValue actual = Processor.Invoke(context.SystemUnderTest, GetMemberName(parameters.Members),
                                                         new TreeList<Cell>());
                    if (actual.IsValid) ShowActual(parameters, actual.Value);
                    break;

                case ExecuteCommand.Check:
                    ShowActual(parameters, GetActual(context, parameters));
                    break;
            }
            return TypedValue.Void;
        }
Ejemplo n.º 20
0
 void Check(ExecuteContext context, ExecuteParameters parameters)
 {
     try {
         TypedValue actual = GetTypedActual(context, parameters);
         if (Processor.Compare(actual, parameters.Cells))
         {
             Processor.TestStatus.MarkRight(parameters.Cell);
         }
         else
         {
             Processor.TestStatus.MarkWrong(parameters.Cell, actual.ValueString);
         }
     }
     catch (IgnoredException) {}
     MarkCellWithLastResults(parameters, p => {});
 }
Ejemplo n.º 21
0
        public override TypedValue Execute(ExecuteContext context, ExecuteParameters parameters)
        {
            switch (context.Command)
            {
            case ExecuteCommand.Input:
                TypedValue actual = Processor.Invoke(context.SystemUnderTest, GetMemberName(parameters.Members),
                                                     new CellTree());
                if (actual.IsValid)
                {
                    ShowActual(parameters, actual.Value);
                }
                break;

            case ExecuteCommand.Check:
                ShowActual(parameters, GetActual(context, parameters));
                break;
            }
            return(TypedValue.Void);
        }
Ejemplo n.º 22
0
 public override TypedValue Execute(ExecuteContext context, ExecuteParameters parameters)
 {
     string exceptionContent = parameters.Cell.Text.Substring("exception[".Length, parameters.Cell.Text.Length - ("exception[".Length + 1));
     try {
         GetActual(context, parameters);
         Processor.TestStatus.MarkWrong(parameters.Cell, "no exception");
     }
     catch (TargetInvocationException e) {
         if (IsMessageOnly(exceptionContent)) {
             EvaluateException(e.InnerException.Message == exceptionContent.Substring(1, exceptionContent.Length - 2), parameters, e);
         }
         else if (IsExceptionTypeNameOnly(exceptionContent)) {
             string actual = e.InnerException.GetType().Name + ": \"" + e.InnerException.Message + "\"";
             EvaluateException(exceptionContent == actual, parameters, e);
         }
         else {
             EvaluateException(e.InnerException.GetType().Name == exceptionContent, parameters, e);
         }
     }
     return TypedValue.Void;
 }
Ejemplo n.º 23
0
        public override TypedValue Execute(ExecuteContext context, ExecuteParameters parameters)
        {
            switch (context.Command)
            {
            case ExecuteCommand.Input:
                Input(context, parameters);
                break;

            case ExecuteCommand.Check:
                Check(context, parameters);
                break;

            case ExecuteCommand.Compare:
                return(new TypedValue(Processor.Compare(context.Target.Value, parameters.Cells)));

            case ExecuteCommand.Invoke:
                return(Invoke(context, parameters));

            default:
                throw new ArgumentException(string.Format("Unrecognized operation '{0}'", context.Command));
            }
            return(TypedValue.Void);
        }
Ejemplo n.º 24
0
 public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters)
 {
     return(context.Command == ExecuteCommand.Check &&
            parameters.Cell.Text.StartsWith(">>"));
 }
Ejemplo n.º 25
0
 public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters)
 {
     return (context.Command == ExecuteCommand.Check || context.Command == ExecuteCommand.Input)
            && parameters.Cell.Text.Length == 0
            && parameters.Cells.IsLeaf;
 }
Ejemplo n.º 26
0
 public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters)
 {
     return context.Command == ExecuteCommand.Check
         && parameters.Cell.Text.StartsWith(">>");
 }
Ejemplo n.º 27
0
 TypedValue Execute(Tree<Cell> targetCell)
 {
     var parameters = new ExecuteParameters(
         ExecuteParameters.Make(new CellTreeLeaf(memberName), new CellTree(), targetCell));
     return execute.Execute(new ExecuteContext(ExecuteCommand.Invoke, target), parameters);
 }
Ejemplo n.º 28
0
 public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters)
 {
     return(context.Command == ExecuteCommand.Check &&
            exceptionIdentifier.IsStartOf(parameters.Cell.Text) && parameters.Cell.Text.EndsWith("]"));
 }
Ejemplo n.º 29
0
 public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters)
 {
     return context.Command == ExecuteCommand.Check && errorIdentifier.Equals(parameters.Cell.Text);
 }
Ejemplo n.º 30
0
 public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters)
 {
     return context.Command == ExecuteCommand.Check
         && exceptionIdentifier.IsStartOf(parameters.Cell.Text) && parameters.Cell.Text.EndsWith("]");
 }
Ejemplo n.º 31
0
 public override TypedValue Execute(ExecuteContext context, ExecuteParameters parameters)
 {
     ShowActual(parameters, GetActual(context, parameters));
     return TypedValue.Void;
 }
Ejemplo n.º 32
0
 public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters)
 {
     return true;
 }
Ejemplo n.º 33
0
 public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters)
 {
     return(true);
 }
Ejemplo n.º 34
0
 public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters)
 {
     return((context.Command == ExecuteCommand.Check || context.Command == ExecuteCommand.Input) &&
            parameters.Cell.Text.Length == 0 &&
            parameters.Cells.IsLeaf);
 }