示例#1
0
        public void GetRandomInt64Test()
        {
            var actual = RandomValueEx.GetRandomInt64(10, 20);

            Assert.True(actual >= 10, "To small");
            Assert.True(actual < 20, "To big");
        }
        public void SafeToInt64InvalidValueDefaultTest()
        {
            var expected = RandomValueEx.GetRandomInt64();
            var actual   = "InvalidValue".SafeToInt64(expected);

            actual
            .Should()
            .Be(expected);
        }
        public void SafeToInt64OverloadInvalidValueWithDefaultTest()
        {
            var expected = RandomValueEx.GetRandomInt64();
            var actual   = "InvalidValue".SafeToInt64(NumberStyles.Any, CultureInfo.InvariantCulture, expected);

            actual
            .Should()
            .Be(expected);
        }
示例#4
0
        public void TryParsInt64OverloadInvalidNumberFormatTest()
        {
            var expected = RandomValueEx.GetRandomInt64();

            Action test = () => expected.ToString(CultureInfo.InvariantCulture)
                          // ReSharper disable once UnusedVariable
                          .TryParsInt64(NumberStyles.AllowDecimalPoint | NumberStyles.HexNumber, CultureInfo.InvariantCulture, out Int64 result);

            test.ShouldThrow <ArgumentException>();
        }
        public void SafeToInt64WithDefaultTest()
        {
            var expected = RandomValueEx.GetRandomInt64();
            var actual   = expected.ToString(CultureInfo.InvariantCulture)
                           .SafeToInt64(RandomValueEx.GetRandomInt64());

            actual
            .Should()
            .Be(expected);
        }
        public void SafeToInt64OverloadWitDefaultTest()
        {
            var expected = RandomValueEx.GetRandomInt64();
            var actual   = expected.ToString(CultureInfo.InvariantCulture)
                           .SafeToInt64(NumberStyles.Any, CultureInfo.InvariantCulture, RandomValueEx.GetRandomInt64());

            actual
            .Should()
            .Be(expected);
        }
示例#7
0
        public void ToInt64Test()
        {
            var value  = RandomValueEx.GetRandomInt64();
            var actual = value.ToString()
                         .ToInt64();

            actual
            .Should()
            .Be(value);
        }
示例#8
0
        public void TryParsInt64OverloadFormatProviderNullTest()
        {
            var         expected = RandomValueEx.GetRandomInt64();
            CultureInfo culture  = null;
            // ReSharper disable once AssignNullToNotNullAttribute
            Action test = () => expected.ToString(CultureInfo.InvariantCulture)
                          // ReSharper disable once UnusedVariable
                          .TryParsInt64(NumberStyles.Any, culture, out Int64 result);

            test.ShouldThrow <ArgumentNullException>();
        }
        public void SafeToInt64NullDefaultTest()
        {
            String value    = null;
            var    expected = RandomValueEx.GetRandomInt64();
            // ReSharper disable once ExpressionIsAlwaysNull
            var actual = value.SafeToInt64(expected);

            actual
            .Should()
            .Be(expected);
        }
示例#10
0
        public void SafeToInt64OverloadNullWithDefaultTest()
        {
            String value    = null;
            var    expected = RandomValueEx.GetRandomInt64();
            // ReSharper disable once ExpressionIsAlwaysNull
            var actual = value.SafeToInt64(NumberStyles.Any, CultureInfo.InvariantCulture, expected);

            actual
            .Should()
            .Be(expected);
        }
示例#11
0
        public void ToInt64OverloadTest()
        {
            var culture = new CultureInfo("de-CH");
            var value   = RandomValueEx.GetRandomInt64();
            var actual  = value.ToString(culture)
                          .ToInt64(culture);

            actual
            .Should()
            .Be(value);
        }
示例#12
0
        public void TryParsInt64Test()
        {
            var expected = RandomValueEx.GetRandomInt64();
            var actual   = expected.ToString(CultureInfo.CurrentCulture)
                           .TryParsInt64(out Int64 result);

            result
            .Should()
            .Be(expected);

            actual
            .Should()
            .BeTrue();
        }
示例#13
0
        public void TryParsInt64OverloadTest()
        {
            var culture  = new CultureInfo("de-CH");
            var expected = RandomValueEx.GetRandomInt64();
            var actual   = expected.ToString(culture)
                           .TryParsInt64(NumberStyles.Any, culture, out Int64 result);

            result
            .Should()
            .Be(expected);

            actual
            .Should()
            .BeTrue();
        }
示例#14
0
        public void GetRandomInt64TestArgumentOutOfRangeException()
        {
            Action test = () => RandomValueEx.GetRandomInt64(20, 10);

            test.ShouldThrow <ArgumentOutOfRangeException>();
        }
示例#15
0
        public void GetRandomInt64TestArgumentOutOfRangeException()
        {
            Action test = () => RandomValueEx.GetRandomInt64(20, 10);

            Assert.Throws <ArgumentOutOfRangeException>(test);
        }