Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }