示例#1
0
        public async Task TestStatusesCaching()
        {
            var(webClient, webClientFactory) = MockWebClientFactory(
                new Dictionary <string, object>
            {
                { requestUrl, data_statuses_1 }
            });

            var client = new TestRailApiClient(
                data_config,
                webClientFactory.Object);

            var statuses1 = client.Statuses;

            webClient.Verify(
                c => c.OpenReadTaskAsync(It.Is <string>(address => address == requestUrl)),
                Times.Exactly(1));

            var statuses2 = client.Statuses;

            webClient.Verify(
                c => c.OpenReadTaskAsync(It.Is <string>(address => address == requestUrl)),
                Times.Exactly(1));

            var statusesById1 = client.StatusesById;

            webClient.Verify(
                c => c.OpenReadTaskAsync(It.Is <string>(address => address == requestUrl)),
                Times.Exactly(1));

            var statusesById2 = client.StatusesById;

            webClient.Verify(
                c => c.OpenReadTaskAsync(It.Is <string>(address => address == requestUrl)),
                Times.Exactly(1));

            var statuses = await client.GetStatusesAsync();

            webClient.Verify(
                c => c.OpenReadTaskAsync(It.Is <string>(address => address == requestUrl)),
                Times.Exactly(2));

            var statuses3 = client.Statuses;

            webClient.Verify(
                c => c.OpenReadTaskAsync(It.Is <string>(address => address == requestUrl)),
                Times.Exactly(2));

            var statusesById3 = client.StatusesById;

            webClient.Verify(
                c => c.OpenReadTaskAsync(It.Is <string>(address => address == requestUrl)),
                Times.Exactly(2));
        }
        public async Task TestValidUrlInConfig(string apiUrl)
        {
            var(webClient, webClientFactory) = MockWebClientFactory(
                new Dictionary <string, object>
            {
                { "https://test:1234/index.php?/api/v2/get_statuses", data_statuses_1 }
            });

            var client = new TestRailApiClient(
                new TestRailApiClientConfiguration
            {
                Url      = apiUrl,
                UserName = "******",
                AppKey   = "qwerasdfzxcv",
            },
                webClientFactory.Object);

            var statuses = await client.GetStatusesAsync();

            Assert.That(statuses, Has.Length.GreaterThan(0));
        }