Beispiel #1
0
        public async Task Send_PostWithObject_returns_201()
        {
            var request = new KRequest(HttpMethod.Post, new Uri(_uri));

            request.SetContent(new { Id = 1, Name = "Test" });
            var client = new KClient();

            var results = await client.SendAsync(request);

            Assert.True(results.First().Response.StatusCode == HttpStatusCode.Created);
        }
Beispiel #2
0
        public async Task Send_Get_returns_200()
        {
            var request = new KRequest(HttpMethod.Get, new Uri(_uri));
            var client  = new KClient(3, 2, 2); //First batch with 2 requests and a second 500ms later with 1 request, with two iterations (=> total 6 requests)

            var results = await client.SendAsync(request);

            Assert.True(results.Count() == client.RequestsPerSecond * client.Repetition);
            Assert.DoesNotContain(results, r => r.Response.StatusCode != HttpStatusCode.OK);
            Assert.DoesNotContain(results, r => r.ElapsedTime > 1000);
        }
Beispiel #3
0
        public async Task Send_GetWithReportWithResponseBody_returns_true()
        {
            var    request    = new KRequest(HttpMethod.Get, new Uri(_uri));
            var    client     = new KClient();
            string reportFile = Path.Combine(Directory.GetCurrentDirectory(), $"KReport_{DateTime.Today:yyyy-MM-dd}__{Guid.NewGuid()}.csv");

            var results = await client.SendAsync(request);

            await KLog.ReportAsync(results, reportFile);

            Assert.True(File.Exists(reportFile));
        }
Beispiel #4
0
        public async Task Send_GetWithHeader_returns_200()
        {
            var headers = new Dictionary <string, string>
            {
                { "Authorization", "Bearer xyz" }
            };
            var request = new KRequest(HttpMethod.Get, new Uri(_uri), headers);
            var client  = new KClient();

            var results = await client.SendAsync(request);

            Assert.True(results.First().Response.StatusCode == HttpStatusCode.OK);
        }
Beispiel #5
0
        public async Task Send_PostWithByteArrays_returns_201()
        {
            var request = new KRequest(HttpMethod.Post, new Uri(_uri));

            request.SetContent(new List <byte[]>()
            {
                GetTestTextFileAsByteArray(), GetTestTextFileAsByteArray()
            });
            var client = new KClient();

            var results = await client.SendAsync(request);

            Assert.True(results.First().Response.StatusCode == HttpStatusCode.Created);
        }