예제 #1
0
        public async Task GetSwagger()
        {
            using var adapter    = TestServers.Create <Startup>();
            using var httpClient = adapter.GetTestClient();
            var response = await httpClient.GetAsync("/swagger/v1/swagger.json");

            var code = (int)response.StatusCode;

            if (code >= 400)
            {
                throw new Exception($"StatusCode: {response.StatusCode}");
            }

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            var content = await response.Content.ReadAsStringAsync();

            File.WriteAllText("./swagger.json", content);
        }
예제 #2
0
        public async Task TestCreateTicket()
        {
            using var adapter    = TestServers.Create <Startup>();
            using var httpClient = adapter.GetTestClient();
            ResponseEntity <Ticket> response = await CreateTicket(httpClient);

            var code = (int)response.StatusCode;

            if (code >= 400)
            {
                throw new Exception($"StatusCode: {response.StatusCode}");
            }
            var path = response.Headers.Location.PathAndQuery;

            Assert.Equal(HttpStatusCode.Created, response.StatusCode);
            Assert.StartsWith("/api/v1/tickets", path);
            Ticket entity = response.Body;

            Assert.Equal(5, entity.Priority);
        }