コード例 #1
0
        public async Task <Result> InvokeAsync(CancellationToken cancellation)
        {
            using (IServiceScope scope = _scopeBuilder.Build())
            {
                IConfigurationValidator configurationValidator = GetService <IConfigurationValidator>(scope);
                Result validateConfigurationResult             = await configurationValidator.ValidateAsync(cancellation);

                if (validateConfigurationResult.IsFailed)
                {
                    return(validateConfigurationResult);
                }

                IExternalAddressClient            externalAddressClient = GetService <IExternalAddressClient>(scope);
                Result <IExternalAddressResponse> externalAddressResult = await externalAddressClient.GetAsync(cancellation);

                if (externalAddressResult.IsFailed)
                {
                    return(validateConfigurationResult.Merge(externalAddressResult));
                }

                IEnumerable <IDDNSService> dnsServices = GetService <IEnumerable <IDDNSService> >(scope);
                Result processResult = await ProcessAsync(dnsServices, externalAddressResult.Value, cancellation);

                return(validateConfigurationResult.Merge(externalAddressResult, processResult));
            }
        }
コード例 #2
0
        public async Task SingleExceptionIsCaught()
        {
            IEnumerable <IDDNSService> services = new[] { new NotImplementedExceptionThrowingDDNSService() };
            IConfigurationValidator    configurationValidator = A.Fake <IConfigurationValidator>();
            IExternalAddressClient     externalAddressClient  = A.Fake <IExternalAddressClient>();

            A.CallTo(() => configurationValidator.ValidateAsync(A <CancellationToken> .Ignored)).Returns(Result.Ok());

            A.CallTo(() => externalAddressClient.GetAsync(A <CancellationToken> .Ignored)).Returns(Result.Ok <IExternalAddressResponse>(new ExternalAddressResponse(default)));