public void UrlExpressionReturnsCorrectExpression() { // Arrange & Act var url = new UrlExpression(); // Assert Assert.Equal("$url", url.Expression); }
public static UrlLookupResult Unsafe(Url url, DateTime lookupDate, UrlExpression unsafeUrlExpression, IEnumerable <ThreatListDescriptor> unsafeThreatListDescriptors) { // ... // // Throws an exception if the operation fails. return(UrlLookupResult.Build() .SetLookupDate(lookupDate) .SetResultCode(UrlLookupResultCode.Unsafe) .SetUnsafeThreatListDescriptors(unsafeThreatListDescriptors) .SetUnsafeUrlExpression(unsafeUrlExpression) .SetUrl(url) .Build()); }
/// <summary> /// Create a URL Lookup Result. /// </summary> /// <param name="builder"> /// A <see cref="UrlLookupResultBuilder" /> to initialize the URL lookup result with. /// </param> /// <exception cref="System.ArgumentNullException"> /// Thrown if <paramref name="builder" /> is a null reference. /// </exception> internal UrlLookupResult(UrlLookupResultBuilder builder) { Guard.ThrowIf(nameof(builder), builder).Null(); Guard.ThrowIf(nameof(builder), builder.Url).Null(); this.LookupDate = builder.LookupDate; this.ResultCode = builder.ResultCode; this.Url = builder.Url; // ... // // ... this._unsafeThreatListDescriptors = CreateUnsafeThreatListDescriptors(this, builder); this._unsafeUrlExpression = CreateUnsafeUrlExpression(this, builder); // <summary> // Create Unsafe Threat List Descriptors. // </summary> IEnumerable <ThreatListDescriptor> CreateUnsafeThreatListDescriptors(UrlLookupResult @this, UrlLookupResultBuilder cBuilder) { IEnumerable <ThreatListDescriptor> cUnsafeThreatListDescriptors = Array.Empty <ThreatListDescriptor>(); if (@this.IsUnsafe) { Guard.ThrowIf(nameof(cBuilder.UnsafeThreatListDescriptors), cBuilder.UnsafeThreatListDescriptors); cUnsafeThreatListDescriptors = cBuilder.UnsafeThreatListDescriptors; } return(cUnsafeThreatListDescriptors); } // <summary> // Create Unsafe URL Expression. // </summary> UrlExpression CreateUnsafeUrlExpression(UrlLookupResult @this, UrlLookupResultBuilder cBuilder) { UrlExpression cUnsafeUrlExpression = null; if (@this.IsUnsafe) { Guard.ThrowIf(nameof(cBuilder.UnsafeUrlExpression), cBuilder.UnsafeUrlExpression); cUnsafeUrlExpression = cBuilder.UnsafeUrlExpression; } return(cUnsafeUrlExpression); } }
/// <summary> /// Set Unsafe URL Expression. /// </summary> /// <param name="value"> /// The computed unsafe <see cref="UrlExpression" /> for the URL. A null reference indicates the URL is /// <see cref="UrlLookupResultCode.Safe" />. /// </param> /// <returns> /// This URL lookup result builder. /// </returns> internal UrlLookupResultBuilder SetUnsafeUrlExpression(UrlExpression value) { this.UnsafeUrlExpression = value; return(this); }