Exemple #1
0
        private static void BeginTestExecution(string solutionDir, string testFileDir)
        {
            ClearTempPath();

            var type     = GetLookupType(testFileDir);
            var solution = SolutionFile.Load(solutionDir);

            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("\nDetermening files To compile");
            Console.WriteLine("-------------------------------");

            var buildFiles = BuildMonkey.Using(new NRefactorySourceExaminer(), solution, new SourceFromFileRepository())
                             .WhatFilesAreRequiredToBuild(type);

            CopyBuildFilesToTempDir(buildFiles);

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("\nCompiling files:");
            Console.WriteLine("-------------------------------");

            var buildFilesCompiler = new BuildFilesCompiler();
            var result             = buildFilesCompiler.Compile(buildFiles);

            ProcessResult(result);
        }
        public void ShouldNotAddDependencyIfNotInSolution()
        {
            examiner.Stub(e => e.ExamineSource(Arg <string> .Is.Anything)).Return(new List <TypeInfo> {
                "Foo"
            });
            solutionFile.Stub(s => s.FindClassByType(Arg <TypeInfo> .Is.Anything)).Return(new Class("stub"));

            var buildFiles = BuildMonkey
                             .Using(examiner, solutionFile, sourceCodeRepo)
                             .WhatFilesAreRequiredToBuild(string.Empty);

            Assert.That(buildFiles.HasAClassCalled("Foo.cs"), Is.False);
        }
        public void ShouldRetrieveClassDependenciesFromExaminer()
        {
            const string source   = @"public class Foo() {}";
            var          fooClass = new Class("Foo");

            sourceCodeRepo.Stub(sr => sr.SourceFor(fooClass)).Return(source);

            BuildMonkey
            .Using(examiner, solutionFile, sourceCodeRepo)
            .WhatFilesAreRequiredToBuild(fooClass);

            examiner.AssertWasCalled(e => e.ExamineSource((source)));
        }
        public void ShouldAddAllReferencesFoundInASolution()
        {
            var references = new List <Reference> {
                new Reference("System.Web")
            };

            solutionFile.Stub(s => s.AllReferences).Return(references);

            var buildFile = BuildMonkey
                            .Using(examiner, solutionFile, sourceCodeRepo)
                            .WhatFilesAreRequiredToBuild(string.Empty);

            Assert.That(buildFile.HasAReferenceCalled("System.Web.dll"));
        }
        public void ShouldAddDependencyIfInSolution()
        {
            var      fooClass = new Class("Foo.cs");
            TypeInfo type     = "Foo";

            examiner.Stub(e => e.ExamineSource(Arg <string> .Is.Anything)).Return(new List <TypeInfo> {
                type
            });
            solutionFile.Stub(s => s.FindClassByType(type)).Return(fooClass);

            var buildFiles = BuildMonkey
                             .Using(examiner, solutionFile, sourceCodeRepo)
                             .WhatFilesAreRequiredToBuild(string.Empty);

            Assert.That(buildFiles.HasAClassCalled("Foo.cs"));
        }