Example #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);
     }
 }
Example #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));
 }
Example #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;
 }
Example #4
0
 static void ShowActual(ExecuteParameters parameters, object actual)
 {
     parameters.Cell.AddToAttribute(
         CellAttribute.InformationSuffix,
         actual == null ? "null"
             : actual.ToString().Length == 0 ? "blank"
             : actual.ToString());
 }
Example #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));
        }
 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));
 }
Example #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));
 }
Example #8
0
 static void ShowActual(ExecuteParameters parameters, object actual)
 {
     parameters.Cell.AddToAttribute(
         CellAttribute.InformationSuffix,
         actual == null ? "null"
         : actual.ToString().Length == 0 ? "blank"
         : actual.ToString());
 }
Example #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;
 }
Example #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);
            }
        }
Example #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 + "\"]");
     }
 }
Example #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;
        }
Example #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;
 }
Example #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);
        }
Example #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;
 }
Example #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);
        }
Example #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 => {});
 }
Example #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;
        }
Example #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;
        }
Example #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 => {});
 }
Example #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);
        }
Example #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;
 }
Example #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);
        }
Example #24
0
 public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters)
 {
     return(context.Command == ExecuteCommand.Check &&
            parameters.Cell.Text.StartsWith(">>"));
 }
Example #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;
 }
Example #26
0
 public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters)
 {
     return context.Command == ExecuteCommand.Check
         && parameters.Cell.Text.StartsWith(">>");
 }
Example #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);
 }
Example #28
0
 public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters)
 {
     return(context.Command == ExecuteCommand.Check &&
            exceptionIdentifier.IsStartOf(parameters.Cell.Text) && parameters.Cell.Text.EndsWith("]"));
 }
Example #29
0
 public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters)
 {
     return context.Command == ExecuteCommand.Check && errorIdentifier.Equals(parameters.Cell.Text);
 }
Example #30
0
 public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters)
 {
     return context.Command == ExecuteCommand.Check
         && exceptionIdentifier.IsStartOf(parameters.Cell.Text) && parameters.Cell.Text.EndsWith("]");
 }
Example #31
0
 public override TypedValue Execute(ExecuteContext context, ExecuteParameters parameters)
 {
     ShowActual(parameters, GetActual(context, parameters));
     return TypedValue.Void;
 }
Example #32
0
 public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters)
 {
     return true;
 }
Example #33
0
 public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters)
 {
     return(true);
 }
Example #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);
 }