Ejemplo n.º 1
0
            /// <summary/>
            public RunAssembly(Executor executor, object _handler)
            {
                ExecutorCallback handler = ExecutorCallback.Wrap(_handler);

                executor.RunOnSTAThreadWithPreservedWorkingDirectory(() =>
                {
                    bool @continue         = true;
                    AssemblyResult results =
                        new AssemblyResult(executor.assemblyFilename,
                                           AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);

                    foreach (Type type in executor.assembly.GetExportedTypes())
                    {
                        ITestClassCommand testClassCommand = TestClassCommandFactory.Make(type);

                        if (testClassCommand != null)
                        {
                            ClassResult classResult =
                                TestClassCommandRunner.Execute(testClassCommand,
                                                               null,
                                                               command => @continue = OnTestStart(command, handler),
                                                               result => @continue  = OnTestResult(result, handler));

                            results.Add(classResult);
                        }

                        if (!@continue)
                        {
                            break;
                        }
                    }

                    OnTestResult(results, handler);
                });
            }
Ejemplo n.º 2
0
    public void ToXml()
    {
        XmlDocument doc = new XmlDocument();
        doc.LoadXml("<foo/>");
        XmlNode parentNode = doc.ChildNodes[0];
        AssemblyResult assemblyResult = new AssemblyResult(filename, @"C:\Foo\Bar");

        XmlNode resultNode = assemblyResult.ToXml(parentNode);

        Assert.Equal("assembly", resultNode.Name);
        Assert.Equal(Path.GetFullPath(filename), resultNode.Attributes["name"].Value);
        Assert.Equal(@"C:\Foo\Bar", resultNode.Attributes["configFile"].Value);
        Assert.NotNull(resultNode.Attributes["run-date"]);
        Assert.NotNull(resultNode.Attributes["run-time"]);
        Assert.Equal("0.000", resultNode.Attributes["time"].Value);
        Assert.Equal("0", resultNode.Attributes["total"].Value);
        Assert.Equal("0", resultNode.Attributes["passed"].Value);
        Assert.Equal("0", resultNode.Attributes["failed"].Value);
        Assert.Equal("0", resultNode.Attributes["skipped"].Value);
        string expectedEnvironment = String.Format("{0}-bit .NET {1}", IntPtr.Size * 8, Environment.Version);
        Assert.Equal(expectedEnvironment, resultNode.Attributes["environment"].Value);
    }
Ejemplo n.º 3
0
    public void ToXml_WithChildren()
    {
        XmlDocument doc = new XmlDocument();
        doc.LoadXml("<foo/>");
        XmlNode parentNode = doc.ChildNodes[0];
        PassedResult passedResult = new PassedResult("foo", "bar", null, null);
        passedResult.ExecutionTime = 1.1;
        FailedResult failedResult = new FailedResult("foo", "bar", null, null, "extype", "message", "stack");
        failedResult.ExecutionTime = 2.2;
        SkipResult skipResult = new SkipResult("foo", "bar", null, null, "reason");
        ClassResult classResult = new ClassResult(typeof(object));
        classResult.Add(passedResult);
        classResult.Add(failedResult);
        classResult.Add(skipResult);
        AssemblyResult assemblyResult = new AssemblyResult(filename);
        assemblyResult.Add(classResult);

        XmlNode resultNode = assemblyResult.ToXml(parentNode);

        Assert.Equal("3.300", resultNode.Attributes["time"].Value);
        Assert.Equal("3", resultNode.Attributes["total"].Value);
        Assert.Equal("1", resultNode.Attributes["passed"].Value);
        Assert.Equal("1", resultNode.Attributes["failed"].Value);
        Assert.Equal("1", resultNode.Attributes["skipped"].Value);
        Assert.Single(resultNode.SelectNodes("class"));
    }
Ejemplo n.º 4
0
    public void AssemblyResultName()
    {
        AssemblyResult assemblyResult = new AssemblyResult(filename);

        Assert.Equal(Path.GetFullPath(filename), assemblyResult.Filename);
    }
Ejemplo n.º 5
0
    public void AssemblyResultConfigFilename()
    {
        AssemblyResult assemblyResult = new AssemblyResult(filename, @"C:\Foo\Bar");

        Assert.Equal(@"C:\Foo\Bar", assemblyResult.ConfigFilename);
    }
Ejemplo n.º 6
0
    public void AssemblyResultCodeBase()
    {
        AssemblyResult assemblyResult = new AssemblyResult(filename);

        Assert.Equal(Path.GetDirectoryName(Path.GetFullPath(filename)), assemblyResult.Directory);
    }
Ejemplo n.º 7
0
        public void AssemblyResultConfigFilename()
        {
            AssemblyResult assemblyResult = new AssemblyResult(filename, fullPathName);

            Assert.Equal(fullPathName, assemblyResult.ConfigFilename);
        }
Ejemplo n.º 8
0
            /// <summary/>
            public RunAssembly(Executor executor, object _handler)
            {
                ExecutorCallback handler = ExecutorCallback.Wrap(_handler);

                executor.RunOnSTAThreadWithPreservedWorkingDirectory(() =>
                    {
                        bool @continue = true;
                        AssemblyResult results =
                            new AssemblyResult(executor.assemblyFilename,
                                               AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);

                        foreach (Type type in executor.assembly.GetExportedTypes())
                        {
                            ITestClassCommand testClassCommand = TestClassCommandFactory.Make(type);

                            if (testClassCommand != null)
                            {
                                ClassResult classResult =
                                    TestClassCommandRunner.Execute(testClassCommand,
                                                                   null,
                                                                   command => @continue = OnTestStart(command, handler),
                                                                   result => @continue = OnTestResult(result, handler));

                                results.Add(classResult);
                            }

                            if (!@continue)
                                break;
                        }

                        OnTestResult(results, handler);
                    });
            }
Ejemplo n.º 9
0
            /// <summary/>
            public RunAssembly(Executor executor, object _handler)
            {
                ICallbackEventHandler handler = _handler as ICallbackEventHandler;

                RunOnSTAThread(() =>
                    {
                        bool @continue = true;
                        AssemblyResult results =
                            new AssemblyResult(new Uri(executor.assembly.CodeBase).LocalPath,
                                               AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);

                        foreach (Type type in executor.assembly.GetExportedTypes())
                        {
                            ITestClassCommand testClassCommand = TestClassCommandFactory.Make(type);

                            if (testClassCommand != null)
                            {
                                ClassResult classResult =
                                    TestClassCommandRunner.Execute(testClassCommand,
                                                                   null,
                                                                   command => @continue = OnTestStart(command, handler),
                                                                   result => @continue = OnTestResult(result, handler));

                                results.Add(classResult);
                            }

                            if (!@continue)
                                break;
                        }

                        OnTestResult(results, handler);
                    });
            }