public async Task ShouldReturnVersion()
        {
            var client = TestClient.CreateClient();

            using (var response = await client.GetAsync("/api/version"))
            {
                response.EnsureSuccessStatusCode();
                var version = await response.Content.ReadAsStringAsync();

                Assert.AreEqual(typeof(Startup).Assembly.GetName().Version.ToString(), version);
            }
        }
        public async Task ShouldGetVersion()
        {
            var expectedVersion = typeof(Startup).Assembly.GetName().Version.ToString();

            using (var client = TestClient.CreateClient())
                using (var response = await client.GetAsync("/api/version"))
                {
                    var version = await response.Content.ReadAsStringAsync();

                    response.EnsureSuccessStatusCode();

                    version.Should().Be(expectedVersion);
                }
        }
Пример #3
0
        public async Task ItShouldReturnSumOfNumbers(string input, int expected)
        {
            using (var client = TestClient.CreateClient())
            {
                var numbers = new SumRequest {
                    Numbers = input
                };
                var content = new StringContent(JsonConvert.SerializeObject(numbers), Encoding.UTF8, "application/json");

                using (var response = await client.PostAsync("/api/calculator", content))
                {
                    response.EnsureSuccessStatusCode();
                    var result = await response.Content.ReadAsStreamAsync();

                    result.Should().Be(expected);
                }
            }
        }