public FormSampleRunner(SampleGroup rootSampleGroup)
        {
            InitializeComponent();

            this.samplesTreeView.AfterCollapse  += new System.Windows.Forms.TreeViewEventHandler(this.samplesTreeView_AfterCollapse);
            this.samplesTreeView.DoubleClick    += new System.EventHandler(this.samplesTreeView_DoubleClick);
            this.samplesTreeView.BeforeCollapse += new System.Windows.Forms.TreeViewCancelEventHandler(this.samplesTreeView_BeforeCollapse);
            this.samplesTreeView.AfterSelect    += new System.Windows.Forms.TreeViewEventHandler(this.samplesTreeView_AfterSelect);
            this.samplesTreeView.AfterExpand    += new System.Windows.Forms.TreeViewEventHandler(this.samplesTreeView_AfterExpand);


            Text = rootSampleGroup.Title;

            ObjectDumper dumper = new ObjectDumper();

            dumper.OutputTextBox = outputTextBox;

            _runner = new SampleRunnerImpl(this, dumper);

            TreeNode rootNode = CreateTreeNode(rootSampleGroup, 0);

            rootNode.ImageKey = rootNode.SelectedImageKey = "Help";
            samplesTreeView.Nodes.Add(rootNode);
            rootNode.ExpandAll();
        }
Beispiel #2
0
        public static void ManejaEventos(string uriStr)
        {
            NetworkCredential account = new NetworkCredential("julian", "julian");
            Uri uri;

            if (!Uri.TryCreate(uriStr, UriKind.Absolute, out uri))
            {
                Console.WriteLine("Uri string is in incorrect format! " + uriStr);
                Console.ReadKey();
            }
            SampleRunner runner = new SampleRunner(uri, account);
        }
Beispiel #3
0
        void RunSample(Control parent, ExampleInfo e)
        {
            if (e == null)
            {
                return;
            }

            MethodInfo main =
                e.Example.GetMethod("Main", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) ??
                e.Example.GetMethod("Main", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] {
                typeof(object),
                typeof(object)
            }, null);

            if (main != null)
            {
                try
                {
                    if (parent != null)
                    {
                        parent.Visible = false;
                        Application.DoEvents();
                    }
                    Trace.WriteLine(String.Format("Launching sample: \"{0}\"", e.Attribute.Title));
                    Trace.WriteLine(String.Empty);

                    AppDomain sandbox = AppDomain.CreateDomain("Sandbox");
                    sandbox.DomainUnload += HandleSandboxDomainUnload;

                    SampleRunner           runner = new SampleRunner(main);
                    CrossAppDomainDelegate cross  = new CrossAppDomainDelegate(runner.Invoke);
                    sandbox.DoCallBack(cross);
                    AppDomain.Unload(sandbox);
                }
                finally
                {
                    if (parent != null)
                    {
                        textBoxOutput.Text = File.ReadAllText("debug.log");
                        parent.Visible     = true;
                        Application.DoEvents();
                    }
                }
            }
            else
            {
                MessageBox.Show("The selected example does not define a Main method", "Entry point not found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Beispiel #4
0
 static void Main(string[] args)
 {
     try
     {
         SampleRunner.Build(_formatter)
         .Register <PrimitiveTypes>('1')
         .Register <Collections>('2')
         .Register <FlowControls>('3')
         .Register <Operators>('4')
         .Run();
     }
     catch (Exception ex)
     {
         Console.WriteLine($"An error has ocurred: {ex.ToString()}");
         throw;
     }
 }
        static SampleRunner Run <T>()
        {
            Assembly     assembly = typeof(T).Assembly;
            SampleRunner runner;

            if (!_runners.TryGetValue(assembly, out runner))
            {
                runner = new SampleRunner();
                runner.AddAssembly(assembly);

                if (runner.TestPackage.Files.Count != 0)
                {
                    runner.Run();
                }

                _runners.Add(assembly, runner);
            }

            return(runner);
        }
        public FormSampleRunner(SampleGroup rootSampleGroup)
        {
            InitializeComponent();

            Text = rootSampleGroup.Title;

            ObjectDumper dumper = new ObjectDumper();

            dumper.TreeView            = treeViewOutput;
            dumper.OutputTextBox       = outputTextBox;
            dumper.GeneratedSqlTextBox = traceTextBox;
            dumper.GeneratedVfpTextBox = vfpTraceTextBox;

            _runner = new SampleRunnerImpl(this, dumper);

            TreeNode rootNode = CreateTreeNode(rootSampleGroup, 0);

            rootNode.ImageKey = rootNode.SelectedImageKey = "Help";
            samplesTreeView.Nodes.Add(rootNode);
            rootNode.Expand();
        }
        public static TestStepRun RunAllSpecificationsFor <T>()
        {
            SampleRunner runner = Run <T>();

            return(runner.GetPrimaryTestStepRun(CodeReference.CreateFromType(typeof(T))));
        }
Beispiel #8
0
 public void SetUp()
 {
     sampleRunner = new SampleRunner();
     sampleRunner.AddFixture(typeof(TSample));
     sampleRunner.Run();
 }
        void RunSample(Control parent, ExampleInfo e)
        {
            if (e == null)
                return;

            MethodInfo main =
                e.Example.GetMethod("Main", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) ??
                e.Example.GetMethod("Main", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] {
                typeof(object),
                typeof(object)
            }, null);
            if (main != null)
            {
                try
                {
                    if (parent != null)
                    {
                        parent.Visible = false;
                        Application.DoEvents();
                    }
                    Trace.WriteLine(String.Format("Launching sample: \"{0}\"", e.Attribute.Title));
                    Trace.WriteLine(String.Empty);

                    AppDomain sandbox = AppDomain.CreateDomain("Sandbox");
                    sandbox.DomainUnload += HandleSandboxDomainUnload;

                    SampleRunner runner = new SampleRunner(main);
                    CrossAppDomainDelegate cross = new CrossAppDomainDelegate(runner.Invoke);
                    sandbox.DoCallBack(cross);
                    AppDomain.Unload(sandbox);
                }
                finally
                {
                    if (parent != null)
                    {
                        textBoxOutput.Text = File.ReadAllText("debug.log");
                        parent.Visible = true;
                        Application.DoEvents();
                    }
                }
            }
            else
            {
                MessageBox.Show("The selected example does not define a Main method", "Entry point not found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }