Exemplo n.º 1
0
        public static ScenarioTestMetadata Map(ScenarioTest test)
        {
            _test = test;

            var type = _test.GetType();

            var scenario = new ScenarioTestMetadata(type);

            var ctor = type.GetConstructors().SingleOrDefault();

            if (ctor != null)
            {
                foreach (var parameter in ctor.GetParameters())
                {
                    var backedField = type
                                      .GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
                                      .SingleOrDefault(
                        p => string.Compare(p.Name.TrimStart('_'), parameter.Name,
                                            StringComparison.InvariantCultureIgnoreCase) == 0);
                    if (backedField != null)
                    {
                        string value;
                        try
                        {
                            value = backedField.GetValue(_test).ToString();
                        }
                        catch
                        {
                            value = "UNKNOWN!";
                        }
                        scenario.Parameters.Add(parameter.Name.ToUpper(), value);
                    }
                }
            }

            var methods = GetPotentialStepMethods(type);

            scenario.GivenMethods = ValidateAndBuildGivenMethods(methods);
            scenario.WhenMethods  = ValidateAndBuildWhenMethod(methods);
            scenario.ThenMethods  = ValidateAndBuildThenMethods(methods);

            return(scenario);
        }
Exemplo n.º 2
0
 public ScenarioRunner(object test, IReportTarget reportTarget)
 {
     _test             = test;
     _scenarioMetadata = new ScenarioTestMetadata(test.GetType());
     _reportTarget     = reportTarget;
 }
Exemplo n.º 3
0
 public ScenarioRunner(ScenarioBase scenario, IReportTarget reportTarget)
 {
     _scenario         = scenario;
     _scenarioMetadata = new ScenarioTestMetadata(scenario.GetType());
     _reportTarget     = reportTarget;
 }