示例#1
0
 private static bool EqualMaxResponseTime(TimeSpan value1, TimeSpan value2)
 {
     if (TimeSpanExtensions.Divide(value1, 2.0) <= value2)
     {
         return(TimeSpanExtensions.Multiply(value1, 2.0) >= value2);
     }
     return(false);
 }
        public static void Division(TimeSpan timeSpan, double factor, TimeSpan expected)
        {
            // This code is borrowed from the official .NET implementation:
            //   https://git.io/JYvjY#L1152-L1158
            // We can remove these copy-and-pasted lines in the future when Libplanet drops
            // .NET Standard 2.0 support and becomes to support .NET Standard 2.1 or higher.
            double divisor = 1.0 / factor;

            Assert.Equal(expected, TimeSpanExtensions.Divide(timeSpan, divisor));
        }
        public static void NaNDivision()
        {
            // This code is borrowed from the official .NET implementation:
            //   https://git.io/JYvhp#L1171-L1175
            // We can remove these copy-and-pasted lines in the future when Libplanet drops
            // .NET Standard 2.0 support and becomes to support .NET Standard 2.1 or higher.
            ArgumentException e = Assert.Throws <ArgumentException>(
                () => TimeSpanExtensions.Divide(TimeSpan.FromDays(1), double.NaN)
                );

            Assert.Equal("divisor", e.ParamName);
        }
 public static void DivideByZero()
 {
     // This code is borrowed from the official .NET implementation:
     //   https://git.io/JYvjT#L1160-L1169
     // We can remove these copy-and-pasted lines in the future when Libplanet drops
     // .NET Standard 2.0 support and becomes to support .NET Standard 2.1 or higher.
     Assert.Throws <OverflowException>(
         () => TimeSpanExtensions.Divide(TimeSpan.FromDays(1), 0)
         );
     Assert.Throws <OverflowException>(
         () => TimeSpanExtensions.Divide(TimeSpan.FromDays(-1), 0)
         );
     Assert.Throws <OverflowException>(() => TimeSpanExtensions.Divide(TimeSpan.Zero, 0));
 }
示例#5
0
 private bool EqualFields(IgmpQueryVersion3Layer other)
 {
     if (other != null && this.GroupAddress == other.GroupAddress && (this.IsSuppressRouterSideProcessing == other.IsSuppressRouterSideProcessing && (int)this.QueryRobustnessVariable == (int)other.QueryRobustnessVariable) && (TimeSpanExtensions.Divide(this.QueryInterval, 2.0) <= other.QueryInterval && TimeSpanExtensions.Multiply(this.QueryInterval, 2.0) >= other.QueryInterval))
     {
         return(Enumerable.SequenceEqual <IpV4Address>((IEnumerable <IpV4Address>) this.SourceAddresses, (IEnumerable <IpV4Address>)other.SourceAddresses));
     }
     return(false);
 }