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