Exemplo n.º 1
0
        public async Task RunService_Success_TestAsync()
        {
            fConfig
            .Interval
            .Returns(TimeSpan.FromSeconds(7));

            fConfig
            .Url
            .Returns("http://dot.com/");

            fHttpService
            .DiscoveryAsync(Arg.Is <Uri>(x => x.AbsoluteUri == "http://dot.com/"), Arg.Any <CancellationToken>())
            .Returns(new string[] { "https://dot.eu/" });

            await fService.StartAsync(default);
Exemplo n.º 2
0
        private async Task LoadAsync(Uri discoveryUrl, TimeSpan delay, CancellationToken cancellationToken)
        {
            while (!cancellationToken.IsCancellationRequested)
            {
                try
                {
                    var endpoints = await fHttpService.DiscoveryAsync(discoveryUrl, cancellationToken);

                    Console.WriteLine($"Discovered '${discoveryUrl}', found endpoints: '{string.Join(',', endpoints)}'");

                    foreach (var endpoint in endpoints)
                    {
                        await fResourcesRepository.AddAsync(new Uri(endpoint).AbsoluteUri, cancellationToken);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Error while discovering endpoint '${discoveryUrl}'.");
                    Console.WriteLine(ex);
                }

                await Task.Delay(delay, cancellationToken);
            }
        }