Beispiel #1
0
        public void constructor_saves_subject_internally()
        {
            KinokoSubject subject = () => { };

            Measurer measurer = new Measurer(subject, 1);

            Assert.That(measurer.Subject, Is.SameAs(subject));
        }
Beispiel #2
0
        public void constructor_saves_repeatCount_internally()
        {
            KinokoSubject subject     = () => { };
            int           repeatCount = 10;

            Measurer measurer = new Measurer(subject, repeatCount);

            Assert.That(measurer.RepeatCount, Is.EqualTo(repeatCount));
        }
Beispiel #3
0
        public void Result_contains_correct_number_of_measurements([Values(1, 2, 3, 4, 5, 10)] int n)
        {
            KinokoSubject subject  = () => { };
            Measurer      measurer = new Measurer(subject, n);

            KinokoResult result = measurer.Run();

            Assert.That(result.Measurements, Is.Not.Null);
            Assert.That(result.Measurements.Length, Is.EqualTo(n));
        }
Beispiel #4
0
        public void returns_not_null_Result()
        {
            KinokoSubject subject = () => { };
            int           repeatMeasurementCount = 10;
            Measurer      measurer = new Measurer(subject, repeatMeasurementCount);

            KinokoResult result = measurer.Run();

            Assert.That(result, Is.Not.Null);
        }
Beispiel #5
0
        public void calls_the_subject_multiple_times([Values(1, 2, 3, 4, 5, 10)] int n)
        {
            int           calledCount = 0;
            KinokoSubject subject     = () => calledCount++;
            Measurer      measurer    = new Measurer(subject, n);

            measurer.Run();

            Assert.That(calledCount, Is.EqualTo(n));
        }
Beispiel #6
0
        public void calls_the_subject()
        {
            bool          isCalled = false;
            KinokoSubject subject  = () => isCalled = true;
            int           repeatMeasurementCount = 10;
            Measurer      measurer = new Measurer(subject, repeatMeasurementCount);

            measurer.Run();

            Assert.That(isCalled, Is.True);
        }
Beispiel #7
0
        public void Result_Measurements_contains_correct_values()
        {
            int callIndex = 0;

            double[]      times    = new double[] { 60, 80, 40 };
            KinokoSubject subject  = () => Thread.Sleep((int)times[callIndex++]);
            Measurer      measurer = new Measurer(subject, times.Length);

            KinokoResult result = measurer.Run();

            AssertAreEqual(times, result.Measurements);
        }
Beispiel #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Measurer"/> class with
        /// the subject that is to be measured and
        /// the number of times the measurement should be performed.
        /// </summary>
        /// <param name="subject">The subject that is to be measured.</param>
        /// <param name="repeatCount">The number of times the measurement is performed.</param>
        /// <exception cref="ArgumentNullException">It is thrown if the subject is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown if the repeatCount value is less then 1.</exception>
        public Measurer(KinokoSubject subject, int repeatCount)
        {
            if (subject == null)
            {
                throw new ArgumentNullException("subject");
            }

            if (repeatCount < 1)
            {
                throw new ArgumentOutOfRangeException("repeatCount", "The repeat count should be an integer greater then 0.");
            }

            this.subject     = subject;
            this.repeatCount = repeatCount;
        }
Beispiel #9
0
        public void constructor_throws_if_repeatCount_is_zero()
        {
            try
            {
                KinokoSubject subject     = () => { };
                int           repeatCount = 0;

                new Measurer(subject, repeatCount);
            }
            catch (ArgumentOutOfRangeException ex)
            {
                Assert.That(ex.ParamName, Is.EqualTo("repeatCount"));
                throw;
            }
        }
Beispiel #10
0
        public void SetUp()
        {
            KinokoSubject subject = () => Thread.Sleep(10);

            measurer = new Measurer(subject, 1);
        }