コード例 #1
0
        public void Executes_the_task_when_run_inside_a_TeamCity_build(TeamCityTask task)
        {
            task.ForceTaskExecution = false;

            using (Mocks.Record())
            {
                SetupResult.For(task.BuildEnvironment.IsTeamCityBuild).Return(true);

                task.Log(Level.Verbose, null);
                LastCall.Constraints(Is.Equal(Level.Verbose), Text.Contains("Skipping task execution")).Repeat.Never();

                task.Log(Level.Verbose, null);
                LastCall.Constraints(Is.Anything(), Is.Anything()).Repeat.Any();
            }

            using (Mocks.Playback())
            {
                Reflector.InvokeMethod(task, "ExecuteTask");
            }
        }
コード例 #2
0
        public void Skips_task_execution_when_run_outside_of_TeamCity(TeamCityTask task)
        {
            task.ForceTaskExecution = false;

            using (Mocks.Record())
            {
                SetupResult.For(task.BuildEnvironment.IsTeamCityBuild).Return(false);

                task.Log(Level.Verbose, null);
                LastCall.Constraints(Is.Equal(Level.Verbose), Text.Contains("Skipping task execution"));
            }

            using (Mocks.Playback())
            {
                Reflector.InvokeMethod(task, "ExecuteTask");
            }
        }