public void verify_when_no_arguments_passed_that_response_contains_error()
 {
     StartThreadProfilerCommand command = new StartThreadProfilerCommand(new MockThreadProfilingService());
     object response = command.Process(null);
     Dictionary<string, object> respDict = response as Dictionary<string, object>;
     Assert.IsTrue(respDict.ContainsKey("error"));
 }
 public void verify_when_no_arguments_passed_that_response_is_expected_dictionary_type()
 {
     StartThreadProfilerCommand command = new StartThreadProfilerCommand(new MockThreadProfilingService());
     object response = command.Process(null);
     Dictionary<string, object> respDict = response as Dictionary<string, object>;
     Assert.IsNotNull(respDict);
 }
 public void verify_when_no_arguments_passed_that_response_dictionary_contains_single_entry()
 {
     StartThreadProfilerCommand command = new StartThreadProfilerCommand(new MockThreadProfilingService());
     object response = command.Process(null);
     Dictionary<string, object> respDict = response as Dictionary<string, object>;
     Assert.AreEqual(1, respDict.Count);
 }
Пример #4
0
        public void verify_when_no_arguments_passed_that_response_is_not_null()
        {
            StartThreadProfilerCommand command = new StartThreadProfilerCommand(new MockThreadProfilingService());
            object response = command.Process(null);

            Assert.IsNotNull(response);
        }
        public void verify_when_profile_id_not_in_arguments_that_response_contains_correct_error_message()
        {
            Dictionary<string, object> arguments = new Dictionary<string, object>();
            arguments.Add("sample_period", 0.1);
            arguments.Add("duration", 180.0);
            arguments.Add("only_runnable_threads", false);
            arguments.Add("only_request_threads", false);
            arguments.Add("profile_agent_code", false);

            StartThreadProfilerCommand command = new StartThreadProfilerCommand(new MockThreadProfilingService());
            object response = command.Process(arguments);
            Dictionary<string, object> respDict = response as Dictionary<string, object>;
            Assert.AreEqual("A valid profile_id must be supplied to start a thread profiling session.", respDict["error"].ToString());
        }
        public void verify_when_profile_id_not_in_arguments_that_response_contains_an_error()
        {
            Dictionary<string, object> arguments = new Dictionary<string, object>();
            arguments.Add("sample_period", 0.1);
            arguments.Add("duration", 180.0);
            arguments.Add("only_runnable_threads", false);
            arguments.Add("only_request_threads", false);
            arguments.Add("profile_agent_code", false);

            StartThreadProfilerCommand command = new StartThreadProfilerCommand(new MockThreadProfilingService());
            object response = command.Process(arguments);
            Dictionary<string, object> respDict = response as Dictionary<string, object>;
            Assert.IsTrue(respDict.ContainsKey("error"));
        }
        public void verify_if_duration_argument_missing_that_max_duration_in_msec_set_to_default()
        {
            Dictionary<string, object> arguments = new Dictionary<string, object>();
            arguments.Add("profile_id", 4444);
            arguments.Add("sample_period", 0.1);
            arguments.Add("only_runnable_threads", false);
            arguments.Add("only_request_threads", false);
            arguments.Add("profile_agent_code", false);

            MockThreadProfilingService service = new MockThreadProfilingService();
            StartThreadProfilerCommand command = new StartThreadProfilerCommand(service);
            object response = command.Process(arguments);
            Assert.AreEqual(ThreadProfilerCommandArgs.DefaultSamplingDurationSeconds * 1000, service.Duration);
        }
        public void verify_when_profile_id_is_in_arguments_and_a_thread_profiling_session_is_currently_active_that_response_does_not_contain_an_error()
        {
            Dictionary <string, object> arguments = new Dictionary <string, object>();

            arguments.Add("profile_id", 4444);

            MockThreadProfilingService service  = new MockThreadProfilingService();
            StartThreadProfilerCommand startCmd = new StartThreadProfilerCommand(service);
            StopThreadProfilerCommand  command  = new StopThreadProfilerCommand(service);
            object response = command.Process(arguments);
            Dictionary <string, object> respDict = response as Dictionary <string, object>;

            Assert.IsFalse(respDict.ContainsKey("error"));
        }
        public void verify_duration_argument_equal_to_10_minutes_converts_correctly_to_duration_in_msec()
        {
            Dictionary<string, object> arguments = new Dictionary<string, object>();
            arguments.Add("profile_id", 4444);
            arguments.Add("sample_period", 0.1);
            arguments.Add("duration", 600.00);
            arguments.Add("only_runnable_threads", false);
            arguments.Add("only_request_threads", false);
            arguments.Add("profile_agent_code", false);

            MockThreadProfilingService service = new MockThreadProfilingService();
            StartThreadProfilerCommand command = new StartThreadProfilerCommand(service);
            object response = command.Process(arguments);
            Assert.AreEqual(600000, service.Duration);
        }
        public void verify_duration_argument_equal_to_less_than_minimum_duration_converts_to_minimum_duration_in_msec()
        {
            Dictionary<string, object> arguments = new Dictionary<string, object>();
            arguments.Add("profile_id", 4444);
            arguments.Add("sample_period", 0.1);
            arguments.Add("duration", 4.9);
            arguments.Add("only_runnable_threads", false);
            arguments.Add("only_request_threads", false);
            arguments.Add("profile_agent_code", false);

            MockThreadProfilingService service = new MockThreadProfilingService();
            StartThreadProfilerCommand command = new StartThreadProfilerCommand(service);
            object response = command.Process(arguments);
            Assert.AreEqual(ThreadProfilerCommandArgs.MinimumSamplingDurationSeconds * 1000, service.Duration);
        }
        public void verify_sample_period_argument_overflow_converts_to_max_frequency_in_msec()
        {
            Dictionary<string, object> arguments = new Dictionary<string, object>();
            arguments.Add("profile_id", 4444);
            arguments.Add("sample_period", 999999999999999999);
            arguments.Add("duration", 180.0);
            arguments.Add("only_runnable_threads", false);
            arguments.Add("only_request_threads", false);
            arguments.Add("profile_agent_code", false);

            MockThreadProfilingService service = new MockThreadProfilingService();
            StartThreadProfilerCommand command = new StartThreadProfilerCommand(service);
            object response = command.Process(arguments);
            Assert.AreEqual(ThreadProfilerCommandArgs.MaximumSamplingFrequencySeconds * 1000, service.Frequency);
        }
        public void verify_sample_period_argument_equal_to_less_than_1_second_sample_converts_correctly_to_frequency_in_msec()
        {
            Dictionary<string, object> arguments = new Dictionary<string, object>();
            arguments.Add("profile_id", 4444);
            arguments.Add("sample_period", 0.91);
            arguments.Add("duration", 180.0);
            arguments.Add("only_runnable_threads", false);
            arguments.Add("only_request_threads", false);
            arguments.Add("profile_agent_code", false);

            MockThreadProfilingService service = new MockThreadProfilingService();
            StartThreadProfilerCommand command = new StartThreadProfilerCommand(service);
            object response = command.Process(arguments);
            Assert.AreEqual(910, service.Frequency);
        }