コード例 #1
0
        public void SaveAcceptanceTest()
        {
            string expectedXml = @"<?xml version=""1.0"" encoding=""utf-8""?>" + Environment.NewLine +
                                 @"<xunit2>" + Environment.NewLine +
                                 @"  <assembly filename=""C:\AssemblyFilename"" config-filename=""C:\ConfigFilename"" shadow-copy=""true"" />" + Environment.NewLine +
                                 @"  <assembly filename=""C:\AssemblyFilename2"" config-filename=""C:\ConfigFilename2"" shadow-copy=""false"" />" + Environment.NewLine +
                                 @"  <output type=""xml"" filename=""C:\XmlFilename"" />" + Environment.NewLine +
                                 @"  <output type=""html"" filename=""C:\HtmlFilename"" />" + Environment.NewLine +
                                 @"</xunit2>";

            using (var tempFile = new TempFile())
            {
                var project = new XunitProject {
                    Filename = tempFile.Filename
                };
                project.Output.Add("xml", @"C:\XmlFilename");
                project.Output.Add("html", @"C:\HtmlFilename");
                project.AddAssembly(new XunitProjectAssembly()
                {
                    AssemblyFilename = @"C:\AssemblyFilename", ConfigFilename = @"C:\ConfigFilename", ShadowCopy = true
                });
                project.AddAssembly(new XunitProjectAssembly()
                {
                    AssemblyFilename = @"C:\AssemblyFilename2", ConfigFilename = @"C:\ConfigFilename2", ShadowCopy = false
                });

                project.Save();

                Assert.Equal(expectedXml, File.ReadAllText(tempFile.Filename));
            }
        }
コード例 #2
0
        public void FilenamesAreRelativeToTheProjectLocation()
        {
            string expectedXml = @"<?xml version=""1.0"" encoding=""utf-8""?>
<xunit>
  <assemblies>
    <assembly filename=""C:\AssemblyFilename"" config-filename=""ConfigFilename"" shadow-copy=""true"" />
  </assemblies>
</xunit>";

            using (TempFile tempFile = new TempFile())
            {
                string       directory = Path.GetDirectoryName(tempFile.Filename);
                XunitProject project   = new XunitProject {
                    Filename = tempFile.Filename
                };
                project.AddAssembly(
                    new XunitProjectAssembly
                {
                    AssemblyFilename = @"C:\AssemblyFilename",
                    ConfigFilename   = Path.Combine(directory, "ConfigFilename")
                });

                project.Save();

                Assert.Equal(expectedXml, File.ReadAllText(tempFile.Filename));
            }
        }
コード例 #3
0
ファイル: RunnerForm.cs プロジェクト: paynetechnologies/xunit
        void LoadAssembly(string assemblyFilename, string configFilename)
        {
            statusLabel.Text = "Loading " + assemblyFilename + " ...";

            passedToolStripButton.Checked  = false;
            failedToolStripButton.Checked  = false;
            skippedToolStripButton.Checked = false;

            try
            {
                TestAssembly testAssembly = mate.Load(assemblyFilename, configFilename, true);
                AddTestAssembly(testAssembly);
                mruAssemblyList.Add(assemblyFilename, configFilename);
                project.AddAssembly(
                    new XunitProjectAssembly
                {
                    AssemblyFilename = assemblyFilename,
                    ConfigFilename   = configFilename
                });

                UpdateAssemblyDynamicMenus();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error loading assembly:\r\n\r\n" + ex.Message, windowTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                statusLabel.Text = "";
            }
        }
コード例 #4
0
        public void AssemblyFilenameOnly()
        {
            string expectedXml = @"<?xml version=""1.0"" encoding=""utf-8""?>
<xunit>
  <assemblies>
    <assembly filename=""C:\AssemblyFilename"" shadow-copy=""true"" />
  </assemblies>
</xunit>";

            using (TempFile tempFile = new TempFile())
            {
                XunitProject project = new XunitProject {
                    Filename = tempFile.Filename
                };
                project.AddAssembly(
                    new XunitProjectAssembly
                {
                    AssemblyFilename = @"C:\AssemblyFilename"
                });

                project.Save();

                Assert.Equal(expectedXml, File.ReadAllText(tempFile.Filename));
            }
        }
コード例 #5
0
        public void AddedAssemblyIsPartOfAssemblyList()
        {
            var project  = new XunitProject();
            var assembly = new XunitProjectAssembly();

            project.AddAssembly(assembly);

            Assert.Contains(assembly, project.Assemblies);
        }
コード例 #6
0
        public void ProjectIsDirtyWhenAddingAssembly()
        {
            var project  = new XunitProject();
            var assembly = new XunitProjectAssembly();

            project.AddAssembly(assembly);

            Assert.True(project.IsDirty);
        }
コード例 #7
0
        public void NullFilenameThrows()
        {
            var project = new XunitProject();

            project.AddAssembly(new XunitProjectAssembly {
                AssemblyFilename = "foo"
            });

            Assert.Throws <ArgumentNullException>(() => project.SaveAs(null));
        }
コード例 #8
0
        public void RemovesAssemblyFromAssembliesList()
        {
            var project  = new XunitProject();
            var assembly = new XunitProjectAssembly();

            project.AddAssembly(assembly);

            project.RemoveAssembly(assembly);

            Assert.DoesNotContain(assembly, project.Assemblies);
        }
コード例 #9
0
        public void SaveAcceptanceTest()
        {
            string expectedXml = @"<?xml version=""1.0"" encoding=""utf-8""?>
<xunit>
  <assemblies>
    <assembly filename=""C:\AssemblyFilename"" config-filename=""C:\ConfigFilename"" shadow-copy=""true"">
      <output type=""xml"" filename=""C:\XmlFilename"" />
      <output type=""html"" filename=""C:\HtmlFilename"" />
    </assembly>
    <assembly filename=""C:\AssemblyFilename2"" config-filename=""C:\ConfigFilename2"" shadow-copy=""false"">
      <output type=""xml"" filename=""C:\XmlFilename2"" />
      <output type=""html"" filename=""C:\HtmlFilename2"" />
    </assembly>
  </assemblies>
</xunit>";

            using (TempFile tempFile = new TempFile())
            {
                XunitProject project = new XunitProject {
                    Filename = tempFile.Filename
                };
                XunitProjectAssembly assembly1 = new XunitProjectAssembly();
                assembly1.AssemblyFilename = @"C:\AssemblyFilename";
                assembly1.ConfigFilename   = @"C:\ConfigFilename";
                assembly1.ShadowCopy       = true;
                assembly1.Output.Add("xml", @"C:\XmlFilename");
                assembly1.Output.Add("html", @"C:\HtmlFilename");
                project.AddAssembly(assembly1);
                XunitProjectAssembly assembly2 = new XunitProjectAssembly();
                assembly2.AssemblyFilename = @"C:\AssemblyFilename2";
                assembly2.ConfigFilename   = @"C:\ConfigFilename2";
                assembly2.ShadowCopy       = false;
                assembly2.Output.Add("xml", @"C:\XmlFilename2");
                assembly2.Output.Add("html", @"C:\HtmlFilename2");
                project.AddAssembly(assembly2);

                project.Save();

                Assert.Equal(expectedXml, File.ReadAllText(tempFile.Filename));
            }
        }
コード例 #10
0
        public void InvalidFilenameThrows()
        {
            var project = new XunitProject {
                Filename = @"C:\\" + Guid.NewGuid() + "\\" + Guid.NewGuid()
            };

            project.AddAssembly(new XunitProjectAssembly {
                AssemblyFilename = "foo"
            });

            Assert.Throws <DirectoryNotFoundException>(() => project.Save());
        }
コード例 #11
0
        public void ProjectIsDirtyWhenRemovingAssembly()
        {
            var project  = new XunitProject();
            var assembly = new XunitProjectAssembly();

            project.AddAssembly(assembly);
            project.IsDirty = false;

            project.RemoveAssembly(assembly);

            Assert.True(project.IsDirty);
        }
コード例 #12
0
        static XunitProject GetSingleAssemblyProject(string assemblyFile, string configFile)
        {
            XunitProject project = new XunitProject();

            project.AddAssembly(
                new XunitProjectAssembly
            {
                AssemblyFilename = assemblyFile,
                ConfigFilename   = configFile,
                ShadowCopy       = true
            }
                );
            return(project);
        }
コード例 #13
0
        public void ProjectIsMarkedCleanWhenSaved()
        {
            using (var tempFile = new TempFile())
            {
                var project  = new XunitProject();
                var assembly = new XunitProjectAssembly {
                    AssemblyFilename = @"C:\FooBar"
                };
                project.AddAssembly(assembly);

                project.SaveAs(tempFile.Filename);

                Assert.False(project.IsDirty);
            }
        }
コード例 #14
0
        public void FilenameIsUpdated()
        {
            using (var tempFile = new TempFile())
            {
                var project  = new XunitProject();
                var assembly = new XunitProjectAssembly {
                    AssemblyFilename = @"C:\FooBar"
                };
                project.AddAssembly(assembly);

                project.SaveAs(tempFile.Filename);

                Assert.Equal(tempFile.Filename, project.Filename);
            }
        }
コード例 #15
0
        public void AssemblyFilenameOnly()
        {
            string expectedXml = @"<?xml version=""1.0"" encoding=""utf-8""?>" + Environment.NewLine +
                                 @"<xunit2>" + Environment.NewLine +
                                 @"  <assembly filename=""C:\AssemblyFilename"" shadow-copy=""true"" />" + Environment.NewLine +
                                 @"</xunit2>";

            using (var tempFile = new TempFile())
            {
                var project = new XunitProject {
                    Filename = tempFile.Filename
                };
                project.AddAssembly(new XunitProjectAssembly {
                    AssemblyFilename = @"C:\AssemblyFilename"
                });

                project.Save();

                Assert.Equal(expectedXml, File.ReadAllText(tempFile.Filename));
            }
        }
コード例 #16
0
ファイル: CommandLine.cs プロジェクト: nulltoken/xunit
 static XunitProject GetSingleAssemblyProject(string assemblyFile, string configFile)
 {
     XunitProject project = new XunitProject();
     project.AddAssembly(
         new XunitProjectAssembly
         {
             AssemblyFilename = assemblyFile,
             ConfigFilename = configFile,
             ShadowCopy = true
         }
     );
     return project;
 }
コード例 #17
0
        public IEnumerable <AutoTest.TestRunners.Shared.Results.TestResult> Run(RunSettings settings, ITestFeedbackProvider channel)
        {
            var          logger  = new XUnitLogger(channel);
            XunitProject project = new XunitProject();

            var runner = settings.Assembly;

            // Set assembly externally as XUnit screws up the casing
            logger.SetCurrentAssembly(runner.Assembly);

            XunitProjectAssembly assembly = new XunitProjectAssembly
            {
                AssemblyFilename = runner.Assembly,
                ConfigFilename   = null,
                ShadowCopy       = false
            };

            project.AddAssembly(assembly);

            foreach (XunitProjectAssembly asm in project.Assemblies)
            {
                using (ExecutorWrapper wrapper = new ExecutorWrapper(asm.AssemblyFilename, asm.ConfigFilename, asm.ShadowCopy))
                {
                    try
                    {
                        var xunitRunner = new TestRunner(wrapper, logger);
                        //Run all tests
                        if (runner.Tests.Count() == 0 && runner.Members.Count() == 0 && runner.Namespaces.Count() == 0)
                        {
                            xunitRunner.RunAssembly();
                        }
                        //Run tests
                        if (runner.Tests.Count() > 0)
                        {
                            foreach (var test in runner.Tests)
                            {
                                xunitRunner.RunTest(test.Substring(0, test.LastIndexOf(".")), test.Substring(test.LastIndexOf(".") + 1, test.Length - (test.LastIndexOf(".") + 1)));
                            }
                        }
                        //Run members
                        if (runner.Members.Count() > 0)
                        {
                            foreach (var member in runner.Members)
                            {
                                xunitRunner.RunClass(member);
                            }
                        }
                        //Run namespaces
                        if (runner.Namespaces.Count() > 0)
                        {
                            var loadedAssembly = Assembly.LoadFrom(runner.Assembly);
                            var types          = loadedAssembly.GetExportedTypes();
                            loadedAssembly = null;
                            foreach (var ns in runner.Namespaces)
                            {
                                foreach (Type type in types)
                                {
                                    if (ns == null || type.Namespace == ns)
                                    {
                                        xunitRunner.RunClass(type.FullName);
                                    }
                                }
                            }
                        }
                    }
                    catch (ArgumentException ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(logger.Results);
        }
コード例 #18
0
ファイル: CommandLine.cs プロジェクト: chrisortman/coulda
        static XunitProject GetSingleAssemblyProject(Dictionary<string, string> transforms, string assemblyFile, string configFile, bool noShadow)
        {
            XunitProjectAssembly assembly = new XunitProjectAssembly { AssemblyFilename = assemblyFile, ConfigFilename = configFile, ShadowCopy = !noShadow };
            foreach (var transform in transforms)
                assembly.Output.Add(transform.Key, transform.Value);

            XunitProject project = new XunitProject();
            project.AddAssembly(assembly);
            return project;
        }
コード例 #19
0
        public void NullAssemblyThrows()
        {
            var project = new XunitProject();

            Assert.Throws <ArgumentNullException>(() => project.AddAssembly(null));
        }