示例#1
0
 public void Should_add_exists_referencedby_records()
 {
     var existingDocument = new ProjectDocument(ProjectType.CSharp);
     existingDocument.AddReferencedBy("someproject");
     var document = _parser.Parse(getCSharpProject(), existingDocument);
     document.ReferencedBy[0].ShouldEqual("someproject");
 }
        public void Should_build_the_command_line_for_each_run()
        {
            _configuration
                .Stub(x => x.MSpecTestRunner("framework 1"))
                .Return("c:\\runner 1.exe");

            _configuration
                .Stub(x => x.MSpecTestRunner("framework 2"))
                .Return("c:\\runner 2.exe");

            _fileSystem
                .Stub(x => x.FileExists(null))
                .IgnoreArguments()
                .Return(true);

            var document1 = new ProjectDocument(ProjectType.CSharp);
            document1.SetFramework("framework 1");
            var info1 = new TestRunInfo(new Project("key 1", document1), "assembly 1");

            var document2 = new ProjectDocument(ProjectType.CSharp);
            document2.SetFramework("framework 2");
            var info2 = new TestRunInfo(new Project("key 2", document2), "assembly 2");

            var testRunInfos = new[] { info1, info2 };

            _runner.RunTests(testRunInfos, null);

            _commandLineBuilder.AssertWasCalled(x => x.Build(null),
                                                o => o.IgnoreArguments().Repeat.Twice());
        }
示例#3
0
 private void setDefaultNamespace(ProjectDocument newDocument)
 {
     var ns = _xml.SelectSingleNode("b:Project/b:PropertyGroup/b:RootNamespace", _nsManager);
     if (ns == null)
         throw new Exception("Could not read root namespace. Invalid project file.");
     newDocument.SetDefaultNamespace(ns.InnerText);
 }
示例#4
0
 public void Should_get_product_version_spesific_build_executable()
 {
     var document = new ProjectDocument(ProjectType.CSharp);
     document.SetFramework("v3.5");
     document.SetVSVersion("9.0.30729");
     _config.BuildExecutable(document).ShouldEqual(@"C:\ProductVersionFolder\MSBuild.exe");
 }
示例#5
0
 public void When_already_prepared_return_null()
 {
     var document = new ProjectDocument(ProjectType.CSharp);
     document.HasBeenReadFromFile();
     var record = new Project("someproject", document);
     var project = _preparer.Prepare(record);
     project.ShouldBeTheSameAs(record);
 }
 public void Should_add_exists_referencedby_records()
 {
     _config.Stub(x => x.ProjectsToIgnore).Return(new string[] {});
     var existingDocument = new ProjectDocument(ProjectType.CSharp);
     existingDocument.AddReferencedBy("someproject");
     var document = _parser.Parse(getCSharpProject(), existingDocument);
     document.ReferencedBy[0].ShouldEqual("someproject");
 }
示例#7
0
 public void SetUp()
 {
     var document = new ProjectDocument(ProjectType.CSharp);
     document.AddReference("ReferencedProject");
     var parser = new FakeProjectParser(new ProjectDocument[] {document});
     _cache = new FakeCache();
     _preparer = new ProjectPreparer(parser, _cache);
 }
示例#8
0
 private void setAssembly(ProjectDocument newDocument)
 {
     var assemblyName = getNode(ASSEMBLYNAME_NODE);
     var fileType = getNode(OUTPUT_TYPE).ToLower();
     if (!fileType.Equals("exe"))
         fileType = "dll";
     newDocument.SetAssemblyName(string.Format("{0}.{1}", assemblyName, fileType));
 }
示例#9
0
 public void SetUp()
 {
     _firstDocument = new ProjectDocument(ProjectType.CSharp);
     _firstDocument.HasBeenReadFromFile();
     _secondDocument = new ProjectDocument(ProjectType.CSharp);
     _secondDocument.HasBeenReadFromFile();
     var parser = new FakeProjectParser(new ProjectDocument[] { _secondDocument, _firstDocument });
     _cache = new Cache(new FakeServiceLocator(parser, delegate { return _cache; }));
 }
示例#10
0
		public void When_custom_output_path_use_custom_output_path()
		{
			var document = new ProjectDocument(ProjectType.CSharp);
			document.SetAssemblyName("mehassembly.dll");
			document.SetOutputPath(string.Format("bin{0}Debug", Path.DirectorySeparatorChar));
			var project = new Project(string.Format("C:{0}Project{0}Location{0}meh.csproj", Path.DirectorySeparatorChar), document);
			var assembly = project.GetAssembly(string.Format("bin{0}bleh{0}", Path.DirectorySeparatorChar));
			assembly.ShouldEqual(string.Format(@"C:{0}Project{0}Location{0}bin{0}bleh{0}mehassembly.dll", Path.DirectorySeparatorChar));
		}
示例#11
0
 public void SetUp()
 {
     var document = new ProjectDocument(ProjectType.CSharp);
     document.AddReference("ReferencedProject");
     var parser = new FakeProjectParser(new ProjectDocument[] {document});
     _cache = new FakeCache();
     _preparer = new ProjectPreparer(parser, _cache);
     _testProject = Path.GetFullPath(string.Format("TestResources{0}VS2008{0}CSharpNUnitTestProject.csproj", Path.DirectorySeparatorChar));
 }
示例#12
0
		public void When_custom_output_path_exists_use_only_custom_output_path()
		{
			var path = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
			var document = new ProjectDocument(ProjectType.CSharp);
			document.SetAssemblyName("mehassembly.dll");
			document.SetOutputPath(string.Format("bin{0}Debug", Path.DirectorySeparatorChar));
			var project = new Project(string.Format("C:{0}Project{0}Location{0}meh.csproj", Path.DirectorySeparatorChar), document);
			var assembly = project.GetAssembly(path);
			assembly.ShouldEqual(string.Format(Path.Combine(path, "mehassembly.dll"), Path.DirectorySeparatorChar));
		}
示例#13
0
 public void Should_populate_referenced_by()
 {
     var record = new Project("someproject", null);
     var referencedProject = new ProjectDocument(ProjectType.CSharp);
     _cache.WhenGeting("ReferencedProject")
         .Return(new Project("", referencedProject));
     var project = _preparer.Prepare(record);
     project.ShouldNotBeNull();
     referencedProject.ReferencedBy[0].ShouldEqual("someproject");
 }
示例#14
0
 public void SetUp()
 {
     _firstDocument = new ProjectDocument(ProjectType.CSharp);
     _firstDocument.HasBeenReadFromFile();
     _secondDocument = new ProjectDocument(ProjectType.CSharp);
     _secondDocument.HasBeenReadFromFile();
     var parser = new FakeProjectParser(new ProjectDocument[] { _secondDocument, _firstDocument });
     _cache = new Cache(new FakeServiceLocator(parser, delegate { return _cache; }));
     _testProject = Path.GetFullPath(string.Format("TestResources{0}VS2008{0}CSharpNUnitTestProject.csproj", Path.DirectorySeparatorChar));
     _testProjectVB = Path.GetFullPath(string.Format("TestResources{0}VS2008{0}NUnitTestProjectVisualBasic.vbproj", Path.DirectorySeparatorChar));
 }
示例#15
0
 private void setAssembly(ProjectDocument newDocument)
 {
     var assemblyName = getNode(ASSEMBLYNAME_NODE);
     if (assemblyName.Length == 0)
         throw new Exception("Could not read assembly name. Invalid project file.");
     var fileType = getNode(OUTPUT_TYPE).ToLower();
     if (fileType.Contains("exe"))
         fileType = "exe";
     else
         fileType = "dll";
     newDocument.SetAssemblyName(string.Format("{0}.{1}", assemblyName, fileType));
 }
示例#16
0
 private void setAssembly(ProjectDocument newDocument)
 {
     var assemblyName = _xml.SelectSingleNode("b:Project/b:PropertyGroup/b:AssemblyName", _nsManager);
     if (assemblyName == null)
         throw new Exception("Could not read assembly name. Invalid project file.");
     var outputType = _xml.SelectSingleNode("b:Project/b:PropertyGroup/b:OutputType", _nsManager); ;
     if (outputType == null)
         throw new Exception("Could not read output type. Invalid project file.");
     string fileType = "dll";
     if (outputType.InnerText.ToLower().Contains("exe"))
         fileType = "exe";
     newDocument.SetAssemblyName(string.Format("{0}.{1}", assemblyName.InnerText, fileType));
 }
        public void Should_report_the_time_info()
        {
            var document = new ProjectDocument(ProjectType.CSharp);
            document.SetFramework("framework 1");
            var info = new TestRunInfo(new Project("key 1", document), "assembly 1");

            var infos = new[] { info };
            var run = new MSpecTestRunner.Run { RunInfos = infos };

            var args = _builder.Build(run);

            Assert.That(args, Is.StringContaining("--timeinfo"));
        }
        public void Should_create_an_xml_report()
        {
            var document = new ProjectDocument(ProjectType.CSharp);
            document.SetFramework("framework 1");
            var info = new TestRunInfo(new Project("key 1", document), "assembly 1");

            var infos = new[] { info };
            var run = new MSpecTestRunner.Run { RunInfos = infos };

            var args = _builder.Build(run);

            Assert.That(args, Is.StringContaining("--xml"));
            Assert.That(run.Cleanups.Count(), Is.EqualTo(1));
            Assert.That(run.Harvesters.Count(), Is.EqualTo(1));
        } 
        public void Should_create_the_assembly_list()
        {
            var document = new ProjectDocument(ProjectType.CSharp);
            document.SetFramework("framework 1");
            var info1 = new TestRunInfo(new Project("key 1", document), "assembly 1");
            var info2 = new TestRunInfo(new Project("key 2", document), "assembly 2");

            var infos = new[] { info1, info2 };
            var run = new MSpecTestRunner.Run { RunInfos = infos };

            var args = _builder.Build(run);

            Assert.That(args, Is.StringContaining(" \"assembly 1\""));
            Assert.That(args, Is.StringContaining(" \"assembly 2\""));
        }
        public void Should_create_the_assembly_list_from_distinct_assembly_names()
        {
            var document = new ProjectDocument(ProjectType.CSharp);
            document.SetFramework("framework 1");
            var info1 = new TestRunInfo(new Project("key 1", document), "assembly 1");
            var info2 = new TestRunInfo(new Project("key 2", document), "assembly 1");

            var infos = new[] { info1, info2 };
            var run = new MSpecTestRunner.Run { RunInfos = infos };

            var args = _builder.Build(run);

            var assembly1Count = new Regex("assembly 1").Matches(args).Count;
            Assert.That(assembly1Count, Is.EqualTo(1));
        }
示例#21
0
 public ProjectDocument Parse(string projectFile, ProjectDocument existingDocument)
 {
     _projectFile = projectFile;
     readFile();
     var newDocument = new ProjectDocument(getType());
     setAssembly(newDocument);
     setConfiguration(newDocument);
     setPlatform(newDocument);
     setOutputPath(newDocument);
     setFrameworkVersion(newDocument);
     setProductVersion(newDocument);
     setContainsTests(newDocument);
     setReferences(newDocument);
     setReferencedBy(newDocument, existingDocument);
     return newDocument;
 }
示例#22
0
 private void setOutputPath(ProjectDocument newDocument)
 {
     var configuration = string.Format("{0}|{1}", newDocument.BuildConfiguration, newDocument.Platform);
     var configurations = getNodes(PROPERTYGROUP_START, PROPERTYGROUP_END);
     for (int i = 0; i < configurations.Length; i++)
     {
         var content = configurations[i];
         if (content.Contains(configuration))
         {
             newDocument.SetOutputPath(
                 getNode(OUTPUTPATH_NODE, content)
                 .Replace("\\", Path.DirectorySeparatorChar.ToString()));
             break;
         }
     }
 }
示例#23
0
        public ProjectDocument Parse(string projectFile, ProjectDocument existingDocument)
        {
            _projectFile = projectFile;
            readFile();
            var newDocument = new ProjectDocument(getType());
            setAssembly(newDocument);
            setDefaultNamespace(newDocument);
            setOutputPath(newDocument);
            setFrameworkVersion(newDocument);
            setProductVersion(newDocument);
			setBinaryReferences(newDocument);
            setReferences(newDocument);
            setReferencedBy(newDocument, existingDocument);
            setFiles(newDocument);
            return newDocument;
        }
示例#24
0
        private void setOutputPath(ProjectDocument newDocument)
        {
			newDocument.SetOutputPath(Path.Combine("bin", "AutoTest.NET") + Path.DirectorySeparatorChar);
//            var configuration = string.Format("{0}|{1}", newDocument.BuildConfiguration, newDocument.Platform);
//            var configurations = getNodes(PROPERTYGROUP_START, PROPERTYGROUP_END);
//            for (int i = 0; i < configurations.Length; i++)
//            {
//                var content = configurations[i];
//                if (content.Contains(configuration))
//                {
//                    newDocument.SetOutputPath(
//                        getNode(OUTPUTPATH_NODE, content)
//                        .Replace("\\", Path.DirectorySeparatorChar.ToString()));
//                    break;
//                }
//            }
        }
        public void Should_create_a_filter_file_when_tests_to_run_are_specified()
        {
            var document = new ProjectDocument(ProjectType.CSharp);
            document.SetFramework("framework 1");
            var info = new TestRunInfo(new Project("key 1", document), "assembly 1");
            info.AddTestsToRun(new[]
                               {
                                   new TestToRun(TestRunner.MSpec, "test 1"),
                                   new TestToRun(TestRunner.MSpec, "test 2")
                               });

            var infos = new[] { info };
            var run = new MSpecTestRunner.Run { RunInfos = infos };

            var args = _builder.Build(run);

            Assert.That(args, Is.StringContaining("--filter"));
            Assert.That(run.Cleanups.Count(), Is.EqualTo(2), "Should contain cleanup for XML report and filter");
        }
示例#26
0
 private void setProductVersion(ProjectDocument newDocument)
 {
     newDocument.SetVSVersion(getNode("b:Project/b:PropertyGroup/b:ProductVersion"));
 }
示例#27
0
 public void Reload()
 {
     Value = new ProjectDocument(Value.Type);
 }
示例#28
0
 private void setFrameworkVersion(ProjectDocument newDocument)
 {
     newDocument.SetFramework(getNode("b:Project/b:PropertyGroup/b:TargetFrameworkVersion"));
 }
示例#29
0
 private void setOutputPath(ProjectDocument newDocument)
 {
     newDocument.SetOutputPath(Path.Combine("bin", "AutoTest.Net") + Path.DirectorySeparatorChar);
 }
        public void Should_not_create_a_filter_file_when_all_tests_are_run()
        {
            var document = new ProjectDocument(ProjectType.CSharp);
            document.SetFramework("framework 1");
            var info = new TestRunInfo(new Project("key 1", document), "assembly 1");

            var infos = new[] { info };
            var run = new MSpecTestRunner.Run { RunInfos = infos };

            var args = _builder.Build(run);

            Assert.That(args, Is.Not.StringContaining("--filter"));
        }
示例#31
0
 public ProjectDocument Parse(string projectFile, ProjectDocument existingDocument)
 {
     return _documents.Pop();
 }
示例#32
0
 public Project(string key, ProjectDocument value)
 {
     Key   = key;
     Value = value;
 }
示例#33
0
 public FakeProjectParser(ProjectDocument[] documents)
 {
     _documents = new Stack<ProjectDocument>(documents);
 }
示例#34
0
 public void Should_get_framework_spesific_build_executable()
 {
     var document = new ProjectDocument(ProjectType.CSharp);
     document.SetFramework("v3.5");
     _config.BuildExecutable(document).ShouldEqual(@"C:\SomefolderOther\MSBuild.exe");
 }
示例#35
0
 public bool CanHandleTestFor(ProjectDocument document)
 {
     return document.ContainsMSTests;
 }
示例#36
0
 private void setBinaryReferences(ProjectDocument document)
 {
     getNodes("b:Project/b:ItemGroup/b:Reference", "Include")
     .Where(x => _fsService.FileExists(x)).ToList()
     .ForEach(x => document.AddBinaryReference(x));
 }