예제 #1
0
        public void Run_should_populate_StartTime_and_EndTime_and_TotalRunTime()
        {
            // Arrange
            var beforeStart = DateTime.UtcNow;
            var config = new Config();
            var testCaseReader = new TestCaseReaderMock();
            var stringReader = new StringReader("");

            var response = new HttpResponse();
            response.ResponseTime = TimeSpan.FromSeconds(5);

            HttpClientMock httpClient = new HttpClientMock(response);
            IResultWriter resultWriter = new ResultWriterStub();
            var runner = new TestSessionRunner(config, httpClient, resultWriter);

            var caseCollection = CreateCaseCollection(new[]
            {
                new Case() { Url = "foo1" },
            });

            // Act
            TestCaseSession session = runner.Run(caseCollection);

            // Assert
            Assert.That(session.StartTime, Is.GreaterThanOrEqualTo(beforeStart));
            Assert.That(session.EndTime, Is.GreaterThanOrEqualTo(session.StartTime));
            Assert.That(session.TotalRunTime, Is.EqualTo(session.EndTime - session.StartTime));
        }
예제 #2
0
        public void Run_should_set_MinResponseTime_and_MaxResponseTime_from_http_response_times()
        {
            // Arrange
            var config = new Config();
            var stringReader = new StringReader("");
            var testCaseReader = new TestCaseReaderMock();

            var response = new HttpResponse();
            response.ResponseTime = TimeSpan.FromSeconds(5);

            HttpClientMock httpClient = new HttpClientMock(response);
            httpClient.ResponseTimes = new List<TimeSpan>()
            {
                // Deliberately mixed up order
                TimeSpan.FromSeconds(5),
                TimeSpan.FromSeconds(88),
                TimeSpan.FromSeconds(3),
                TimeSpan.FromSeconds(10)
            };
            httpClient.Response = response;

            IResultWriter resultWriter = new ResultWriterStub();
            var runner = new TestSessionRunner(config, httpClient, resultWriter);

            var caseCollection = CreateCaseCollection(new[]
            {
                new Case() { Url = "foo1" },
                new Case() { Url = "foo2" },
                new Case() { Url = "foo3" },
                new Case() { Url = "foo4" },
            });

            // Act
            TestCaseSession session = runner.Run(caseCollection);

            // Assert
            Assert.That(session.MinResponseTime, Is.EqualTo(TimeSpan.FromSeconds(3)));
            Assert.That(session.MaxResponseTime, Is.EqualTo(TimeSpan.FromSeconds(88)));
        }