Beispiel #1
0
        public void DoFullRun()
        {
            if (licenseIsInvalid())
            {
                return;
            }

            var message       = new ProjectChangeMessage();
            var cache         = BootStrapper.Services.Locate <ICache>();
            var configuration = BootStrapper.Services.Locate <IConfiguration>();
            var bus           = BootStrapper.Services.Locate <IMessageBus>();
            var projects      = cache.GetAll <Project>();

            foreach (var project in projects)
            {
                if (project.Value == null)
                {
                    Logger.WriteDebug("Invalid project does not contain.Value " + project.Key);
                    continue;
                }
                project.Value.RebuildOnNextRun();
                message.AddFile(new ChangedFile(project.Key));
            }
            _resumeMinimizerOnNextRunCompleted = true;
            pauseMinimizer();
            notifyMinimizerAboutFullRun();
            bus.Publish(message);
        }
Beispiel #2
0
        public void StartOnDemandTestRun(IEnumerable <OnDemandRun> runs)
        {
            if (licenseIsInvalid())
            {
                return;
            }

            lock (_manualMinimizationLock)
            {
                var message  = new ProjectChangeMessage();
                var cache    = BootStrapper.Services.Locate <ICache>();
                var bus      = BootStrapper.Services.Locate <IMessageBus>();
                var projects = cache.GetAll <Project>();
                Logger.WriteDebug(string.Format("Recieved {0} runs", runs.Count()));
                addProjects(runs, message, projects);
                var onDemandPreProcessor = getOnDemandPreProcessor();
                foreach (var run in runs)
                {
                    Logger.WriteDebug("Adding test run to preprocessor " + run.Project);
                    onDemandPreProcessor.AddRuns(run);
                }
                onDemandPreProcessor.Activate();
                _disableOnDemandRunnerOnNextRunCompleted = true;
                _resumeMinimizerOnNextRunCompleted       = true;
                pauseMinimizer();
                bus.Publish(message);
            }
        }
        public Dictionary <string, Action <dynamic> > GetClientHandlers()
        {
            var handlers = new Dictionary <string, Action <dynamic> >();

            handlers.Add("build-test-all", (msg) => {
                var message  = new ProjectChangeMessage();
                var projects = _cache.GetAll <Project>();
                foreach (var project in projects)
                {
                    if (project.Value == null)
                    {
                        continue;
                    }
                    project.Value.RebuildOnNextRun();
                    message.AddFile(new ChangedFile(project.Key));
                }
                _bus.Publish(message);
            });
            handlers.Add("build-test-projects", (msg) => {
                var message  = new ProjectChangeMessage();
                var projects = ((IEnumerable <object>)msg.projects).Select(x => x.ToString());
                projects.ToList().ForEach(x => message.AddFile(new ChangedFile(x)));
                _bus.Publish(message);
            });

            return(handlers);
        }
Beispiel #4
0
        public void Should_rerun_test_if_pre_processor_says_so()
        {
            _runInfo.ShouldNotBuild();
            _project.Value.SetOutputPath("");
            _project.Value.SetAssemblyName("someProject.dll");
            var info = new TestRunInfo(_project, "");

            _listGenerator.Stub(l => l.Generate(null)).IgnoreArguments().Return(new string[] { "some file.csproj" });
            _configuration.Stub(c => c.BuildExecutable(_project.Value)).Return("invalid_to_not_run_builds.exe");
            var result = new TestRunResults[] { new TestRunResults("", "", false, TestRunner.NUnit, new TestResult[] { }) };

            _testRunner.Stub(t => t.CanHandleTestFor(info.Assembly)).IgnoreArguments().Return(true);
            _testRunner.Stub(t => t.RunTests(new TestRunInfo[] { info }, null, null)).IgnoreArguments()
            .Return(result);
            _runInfo.ShouldRerunAllTestWhenFinishedFor(TestRunner.Any);
            _removedTestLocator.Stub(r => r.SetRemovedTestsAsPassed(null, null)).IgnoreArguments().Return(result[0]);
            _removedTestLocator.Stub(r => r.RemoveUnmatchedRunInfoTests(null, null)).IgnoreArguments().Return(new List <TestRunResults>());
            _testAssemblyValidator.Stub(t => t.ShouldNotTestAssembly("")).IgnoreArguments().Return(false);

            var message = new ProjectChangeMessage();

            message.AddFile(new ChangedFile("some file.csproj"));
            _consumer.Consume(message);
            _testRunner.AssertWasCalled(t => t.RunTests(new TestRunInfo[] { new TestRunInfo(null, "") }, null, null), t => t.IgnoreArguments().Repeat.Twice());
        }
Beispiel #5
0
        public void DoPartialRun(IEnumerable <string> projects)
        {
            var message = new ProjectChangeMessage();

            projects.ToList().ForEach(x => message.AddFile(new ChangedFile(x)));
            var bus = BootStrapper.Services.Locate <IMessageBus>();

            bus.Publish(message);
        }
        public Dictionary <string, Action <dynamic> > GetClientHandlers()
        {
            var handlers = new Dictionary <string, Action <dynamic> >();

            handlers.Add("build-test-all", (msg) => {
                var message  = new ProjectChangeMessage();
                var projects = _cache.GetAll <Project>();
                foreach (var project in projects)
                {
                    if (project.Value == null)
                    {
                        continue;
                    }
                    project.Value.RebuildOnNextRun();
                    message.AddFile(new ChangedFile(project.Key));
                }
                _bus.Publish(message);
            });
            handlers.Add("build-test-projects", (msg) => {
                var message  = new ProjectChangeMessage();
                var projects = ((IEnumerable <object>)msg.projects).Select(x => x.ToString());
                projects.ToList().ForEach(x => message.AddFile(new ChangedFile(x)));
                _bus.Publish(message);
            });
            handlers.Add("on-demand-test-run", (msg) => {
                var runs = ((IEnumerable <dynamic>)msg.runs)
                           .Select(x => {
                    var run = new OnDemandRun(
                        x.project.ToString(),
                        ((IEnumerable <dynamic>)x.tests).Select(y => y.ToString()).ToArray(),
                        ((IEnumerable <dynamic>)x.members).Select(y => y.ToString()).ToArray(),
                        ((IEnumerable <dynamic>)x.namespaces).Select(y => y.ToString()).ToArray()
                        );
                    if ((bool)x.project_runall_tests == true)
                    {
                        run.ShouldRunAllTestsInProject();
                    }
                    return(run);
                });

                var message  = new ProjectChangeMessage();
                var projects = _cache.GetAll <Project>();
                Debug.WriteDebug(string.Format("Recieved {0} runs", runs.Count()));
                addProjects(runs, message, projects);
                var onDemandPreProcessor = getOnDemandPreProcessor();
                foreach (var run in runs)
                {
                    Debug.WriteDebug("Adding test run to preprocessor " + run.Project);
                    onDemandPreProcessor.AddRuns(run);
                }
                onDemandPreProcessor.Activate();
                _disableOnDemandRunnerOnNextRunCompleted = true;
                _bus.Publish(message);
            });

            return(handlers);
        }
        private void publishProjects(List <ChangedFile> totalListOfProjects)
        {
            if (totalListOfProjects.Count == 0)
            {
                return;
            }
            var projectChange = new ProjectChangeMessage();

            projectChange.AddFile(totalListOfProjects.ToArray());
            Debug.AboutToPublishProjectChanges(projectChange);
            _bus.Publish(projectChange);
        }
        public void Should_run_builds()
        {
            var executable = Assembly.GetExecutingAssembly().Location;
            _listGenerator.Stub(l => l.Generate(null)).IgnoreArguments().Return(new string[] { "some file.csproj" });
            _configuration.Stub(c => c.BuildExecutable(_project.Value)).Return(executable);
            _buildRunner.Stub(b => b.RunBuild(_project.Key, executable)).Return(new BuildRunResults(""));

            var message = new ProjectChangeMessage();
            message.AddFile(new ChangedFile("some file.csproj"));
            _consumer.Consume(message);
            _buildRunner.AssertWasCalled(b => b.RunBuild(_project.Key, executable));
        }
 private ProjectChangeMessage getProjects(TempFiles files)
 {
     var message = new ProjectChangeMessage();
     foreach (var file in files.Files)
     {
         var project = _cache.Get<Project>(file.Original);
         if (project == null)
             continue;
         message.AddFile(new ChangedFile(project.Key));
     }
     return message;
 }
Beispiel #10
0
        public void Should_not_run_builds_when_build_executable_not_defined()
        {
            var executable = Assembly.GetExecutingAssembly().Location;

            _listGenerator.Stub(l => l.Generate(null)).IgnoreArguments().Return(new string[] { "some file.csproj" });
            _configuration.Stub(c => c.BuildExecutable(_project.Value)).Return("non existing file");

            var message = new ProjectChangeMessage();

            message.AddFile(new ChangedFile("some file.csproj"));
            _consumer.Consume(message);
            _buildRunner.AssertWasNotCalled(b => b.RunBuild(_runInfo, executable, null), b => b.IgnoreArguments());
        }
Beispiel #11
0
 private void addProjects(IEnumerable <OnDemandRun> runs, ProjectChangeMessage message, Project[] projects)
 {
     foreach (var run in runs)
     {
         var project = projects.FirstOrDefault(x => x.Key.Equals(run.Project));
         if (project == null)
         {
             Logger.WriteError(string.Format("Did not find matching project for run {0}", run.Project));
             continue;
         }
         message.AddFile(new ChangedFile(run.Project));
     }
 }
Beispiel #12
0
        internal static void ConsumingProjectChangeMessage(ProjectChangeMessage message)
        {
            if (_isDisabled)
            {
                return;
            }
            var builder = new StringBuilder();

            builder.AppendLine("Consuming project changes for:");
            foreach (var file in message.Files)
            {
                builder.AppendLine(string.Format("    {0}", file.FullName));
            }
            writeDebug(builder.ToString());
        }
        private ProjectChangeMessage getProjects(TempFiles files)
        {
            var message = new ProjectChangeMessage();

            foreach (var file in files.Files)
            {
                var project = _cache.Get <Project>(file.Original);
                if (project == null)
                {
                    continue;
                }
                message.AddFile(new ChangedFile(project.Key));
            }
            return(message);
        }
Beispiel #14
0
        private ProjectChangeMessage getOnDemandMessage(IEnumerable <OnDemandRun> runs, Project[] projects)
        {
            var message = new ProjectChangeMessage();

            foreach (var run in runs)
            {
                var project = projects.Where(x => x.Key.Equals(run.Project)).FirstOrDefault();
                if (project == null)
                {
                    Debug.WriteError(string.Format("Did not find matching project for run {0}", run.Project));
                    continue;
                }
                message.AddFile(new ChangedFile(run.Project));
            }
            return(message);
        }
Beispiel #15
0
        public void BuildAndTestAll()
        {
            var message  = new ProjectChangeMessage();
            var cache    = BootStrapper.Services.Locate <ICache>();
            var bus      = BootStrapper.Services.Locate <IMessageBus>();
            var projects = cache.GetAll <Project>();

            foreach (var project in projects)
            {
                if (project.Value == null)
                {
                    continue;
                }
                project.Value.RebuildOnNextRun();
                message.AddFile(new ChangedFile(project.Key));
            }
            bus.Publish(message);
        }
Beispiel #16
0
        public void Should_pre_process_run_information()
        {
            _project.Value.SetOutputPath("");
            _project.Value.SetAssemblyName("someProject.dll");
            var info = new TestRunInfo(_project, "someProject.dll");

            _listGenerator.Stub(l => l.Generate(null)).IgnoreArguments().Return(new string[] { "some file.csproj" });
            _configuration.Stub(c => c.BuildExecutable(_project.Value)).Return("invalid_to_not_run_builds.exe");
            _testRunner.Stub(t => t.CanHandleTestFor(info.Assembly)).Return(true);
            _testRunner.Stub(t => t.RunTests(new TestRunInfo[] { info }, null, null)).IgnoreArguments()
            .Return(new TestRunResults[] { new TestRunResults("", "", false, TestRunner.NUnit, new TestResult[] { }) });
            _testAssemblyValidator.Stub(t => t.ShouldNotTestAssembly("")).IgnoreArguments().Return(true);

            var message = new ProjectChangeMessage();

            message.AddFile(new ChangedFile("some file.csproj"));
            _consumer.Consume(message);
            _preProcessor.AssertWasCalled(p => p.PreProcess(null), p => p.IgnoreArguments());
        }
Beispiel #17
0
 internal static void AboutToPublishProjectChanges(ProjectChangeMessage projectChange)
 {
     writeDetail(string.Format("File change consumer about to publish change for {0} files", projectChange.Files.Length));
 }
        public void Should_run_tests()
        {
            _project.Value.SetAsNUnitTestContainer();
            _project.Value.SetOutputPath("");
            _project.Value.SetAssemblyName("someProject.dll");
            _listGenerator.Stub(l => l.Generate(null)).IgnoreArguments().Return(new string[] { "some file.csproj" });
            _configuration.Stub(c => c.BuildExecutable(_project.Value)).Return("invalid_to_not_run_builds.exe");
            _testRunner.Stub(t => t.CanHandleTestFor(_project.Value)).Return(true);
            var result = new TestRunResults[] { new TestRunResults("", "", false, new TestResult[] { }) };
            _testRunner.Stub(t => t.RunTests(new TestRunInfo[] { new TestRunInfo(_project, "") })).IgnoreArguments()
                .Return(result);
            _removedTestLocator.Stub(r => r.SetRemovedTestsAsPassed(null, null)).IgnoreArguments().Return(result[0]);

            var message = new ProjectChangeMessage();
            message.AddFile(new ChangedFile("some file.csproj"));
            _consumer.Consume(message);
            _testRunner.AssertWasCalled(t => t.RunTests(new TestRunInfo[] { new TestRunInfo(null, "") }), t => t.IgnoreArguments());
        }
Beispiel #19
0
 private void addProjects(IEnumerable<OnDemandRun> runs, ProjectChangeMessage message, Project[] projects)
 {
     foreach (var run in runs)
     {
         var project = projects.FirstOrDefault(x => x.Key.Equals(run.Project));
         if (project == null)
         {
             Logger.WriteError(string.Format("Did not find matching project for run {0}", run.Project));
             continue;
         }
         message.AddFile(new ChangedFile(run.Project));
     }
 }
		public void Should_rerun_test_if_pre_processor_says_so()
		{
            _runInfo.ShouldNotBuild();
            _project.Value.SetOutputPath("");
            _project.Value.SetAssemblyName("someProject.dll");
            var info = new TestRunInfo(_project, "");
            _listGenerator.Stub(l => l.Generate(null)).IgnoreArguments().Return(new string[] { "some file.csproj" });
            _configuration.Stub(c => c.BuildExecutable(_project.Value)).Return("invalid_to_not_run_builds.exe");
            var result = new TestRunResults[] { new TestRunResults("", "", false, TestRunner.NUnit, new TestResult[] { }) };
            _testRunner.Stub(t => t.CanHandleTestFor(info.Assembly)).IgnoreArguments().Return(true);
            _testRunner.Stub(t => t.RunTests(new TestRunInfo[] { info })).IgnoreArguments()
                .Return(result);
			_runInfo.ShouldRerunAllTestWhenFinishedFor(TestRunner.Any);
            _removedTestLocator.Stub(r => r.SetRemovedTestsAsPassed(null, null)).IgnoreArguments().Return(result[0]);
            _testAssemblyValidator.Stub(t => t.ShouldNotTestAssembly("")).IgnoreArguments().Return(false);

            var message = new ProjectChangeMessage();
            message.AddFile(new ChangedFile("some file.csproj"));
            _consumer.Consume(message);
            _testRunner.AssertWasCalled(t => t.RunTests(new TestRunInfo[] { new TestRunInfo(null, "") }), t => t.IgnoreArguments().Repeat.Twice());
		}
Beispiel #21
0
 public void BuildAndTestAll()
 {
     var message = new ProjectChangeMessage();
     var cache = BootStrapper.Services.Locate<ICache>();
     var bus = BootStrapper.Services.Locate<IMessageBus>();
     var projects = cache.GetAll<Project>();
     foreach (var project in projects)
     {
         if (project.Value == null)
             continue;
         project.Value.RebuildOnNextRun();
         message.AddFile(new ChangedFile(project.Key));
     }
     bus.Publish(message);
 }
        public void Should_not_run_builds_when_build_executable_not_defined()
        {
            var executable = Assembly.GetExecutingAssembly().Location;
            _listGenerator.Stub(l => l.Generate(null)).IgnoreArguments().Return(new string[] { "some file.csproj" });
            _configuration.Stub(c => c.BuildExecutable(_project.Value)).Return("non existing file");

            var message = new ProjectChangeMessage();
            message.AddFile(new ChangedFile("some file.csproj"));
            _consumer.Consume(message);
            _buildRunner.AssertWasNotCalled(b => b.RunBuild(_runInfo, executable, null), b => b.IgnoreArguments());
        }
Beispiel #23
0
 private ProjectChangeMessage getOnDemandMessage(IEnumerable<OnDemandRun> runs, Project[] projects)
 {
     var message = new ProjectChangeMessage();
     foreach (var run in runs)
     {
         var project = projects.Where(x => x.Key.Equals(run.Project)).FirstOrDefault();
         if (project == null)
         {
             Debug.WriteError(string.Format("Did not find matching project for run {0}", run.Project));
             continue;
         }
         message.AddFile(new ChangedFile(run.Project));
     }
     return message;
 }
Beispiel #24
0
        public void DoFullRun()
        {
            if (licenseIsInvalid())
                return;

            var message = new ProjectChangeMessage();
            var cache = BootStrapper.Services.Locate<ICache>();
            var configuration = BootStrapper.Services.Locate<IConfiguration>();
            var bus = BootStrapper.Services.Locate<IMessageBus>();
            var projects = cache.GetAll<Project>();
            foreach (var project in projects)
            {
                if (project.Value == null)
                {
                    Logger.WriteDebug("Invalid project does not contain.Value " + project.Key);
                    continue;
                }
                project.Value.RebuildOnNextRun();
                message.AddFile(new ChangedFile(project.Key));
            }
            _resumeMinimizerOnNextRunCompleted = true;
            pauseMinimizer();
            notifyMinimizerAboutFullRun();
            bus.Publish(message);
        }
        public void Should_pre_process_run_information()
        {
            _project.Value.SetOutputPath("");
            _project.Value.SetAssemblyName("someProject.dll");
            var info = new TestRunInfo(_project, "someProject.dll");
            _listGenerator.Stub(l => l.Generate(null)).IgnoreArguments().Return(new string[] { "some file.csproj" });
            _configuration.Stub(c => c.BuildExecutable(_project.Value)).Return("invalid_to_not_run_builds.exe");
            _testRunner.Stub(t => t.CanHandleTestFor(info.Assembly)).Return(true);
            _testRunner.Stub(t => t.RunTests(new TestRunInfo[] { info })).IgnoreArguments()
                .Return(new TestRunResults[] { new TestRunResults("", "", false, TestRunner.NUnit, new TestResult[] { }) });
            _testAssemblyValidator.Stub(t => t.ShouldNotTestAssembly("")).IgnoreArguments().Return(true);

            var message = new ProjectChangeMessage();
            message.AddFile(new ChangedFile("some file.csproj"));
            _consumer.Consume(message);
            _preProcessor.AssertWasCalled(p => p.PreProcess(null), p => p.IgnoreArguments());
        }
Beispiel #26
0
 public void DoPartialRun(IEnumerable<string> projects)
 {
     var message = new ProjectChangeMessage();
     projects.ToList().ForEach(x => message.AddFile(new ChangedFile(x)));
     var bus = BootStrapper.Services.Locate<IMessageBus>();
     bus.Publish(message);
 }
		public void Should_rerun_test_if_pre_processor_says_so()
		{
			_project.Value.SetAsNUnitTestContainer();
            _project.Value.SetOutputPath("");
            _project.Value.SetAssemblyName("someProject.dll");
            _listGenerator.Stub(l => l.Generate(null)).IgnoreArguments().Return(new string[] { "some file.csproj" });
            _configuration.Stub(c => c.BuildExecutable(_project.Value)).Return("invalid_to_not_run_builds.exe");
            _testRunner.Stub(t => t.CanHandleTestFor(_project.Value)).Return(true);
            _testRunner.Stub(t => t.RunTests(new TestRunInfo[] { new TestRunInfo(_project, "") })).IgnoreArguments()
                .Return(new TestRunResults[] { new TestRunResults("", "", new TestResult[] {}) });
			_runInfo.RerunAllTestWhenFinished();

            var message = new ProjectChangeMessage();
            message.AddFile(new ChangedFile("some file.csproj"));
            _consumer.Consume(message);
            _testRunner.AssertWasCalled(t => t.RunTests(new TestRunInfo[] { new TestRunInfo(null, "") }), t => t.IgnoreArguments().Repeat.Twice());
		}
Beispiel #28
0
        public void StartOnDemandTestRun(IEnumerable<OnDemandRun> runs)
        {
            if (licenseIsInvalid())
                return;

            lock (_manualMinimizationLock)
            {
                var message = new ProjectChangeMessage();
                var cache = BootStrapper.Services.Locate<ICache>();
                var bus = BootStrapper.Services.Locate<IMessageBus>();
                var projects = cache.GetAll<Project>();
                Logger.WriteDebug(string.Format("Recieved {0} runs", runs.Count()));
                addProjects(runs, message, projects);
                var onDemandPreProcessor = getOnDemandPreProcessor();
                foreach (var run in runs)
                {
                    Logger.WriteDebug("Adding test run to preprocessor " + run.Project);
                    onDemandPreProcessor.AddRuns(run);
                }
                onDemandPreProcessor.Activate();
                _disableOnDemandRunnerOnNextRunCompleted = true;
                _resumeMinimizerOnNextRunCompleted = true;
                pauseMinimizer();
                bus.Publish(message);
            }
        }