public void SafeToInt32Test() { var expected = RandomValueEx.GetRandomInt32(); var actual = expected.ToString(CultureInfo.InvariantCulture) .SafeToInt32(); actual .Should() .Be(expected); }
public void SafeToInt32OverloadWitDefaultTest() { var expected = RandomValueEx.GetRandomInt32(); var actual = expected.ToString(CultureInfo.InvariantCulture) .SafeToInt32(NumberStyles.Any, CultureInfo.InvariantCulture, RandomValueEx.GetRandomInt32()); actual .Should() .Be(expected); }
public void ToInt32OverloadTest() { var culture = new CultureInfo("de-CH"); var value = RandomValueEx.GetRandomInt32(); var actual = value.ToString(culture) .ToInt32(culture); actual .Should() .Be(value); }
public void SaveToInt32OverloadNullWithDefaultTest() { String value = null; var expected = RandomValueEx.GetRandomInt32(); // ReSharper disable once ExpressionIsAlwaysNull var actual = value.SaveToInt32(NumberStyles.Any, CultureInfo.InvariantCulture, expected); actual .Should() .Be(expected); }
public void ToSecondsTest() { var value = RandomValueEx.GetRandomInt32(1, 100); var expected = TimeSpan.FromSeconds(value); var actual = ((Int64)value).ToSeconds(); actual .Should() .Be(expected); }
public void SaveToInt32NullDefaultTest() { String value = null; var expected = RandomValueEx.GetRandomInt32(); // ReSharper disable once ExpressionIsAlwaysNull var actual = value.SaveToInt32(expected); actual .Should() .Be(expected); }
public void SafeToDecimalNullTest() { String value = null; var expected = new Decimal(RandomValueEx.GetRandomInt32()); // ReSharper disable once ExpressionIsAlwaysNull var actual = value.SafeToDecimal(expected); actual .Should() .Be(expected); }
public void TryParsInt32OverloadFormatProviderNullTest() { var expected = RandomValueEx.GetRandomInt32(); CultureInfo culture = null; // ReSharper disable once AssignNullToNotNullAttribute Action test = () => expected.ToString(CultureInfo.InvariantCulture) // ReSharper disable once UnusedVariable .TryParsInt32(NumberStyles.Any, culture, out var result); test.ShouldThrow <ArgumentNullException>(); }
public void CtorTest() { var index = RandomValueEx.GetRandomInt32(); var value = RandomValueEx.GetRandomString(); var target = new IndexedItem <String>(index, value); target.Index.Should() .Be(index); target.Item.Should() .Be(value); }
public void ToMinutesTest() { var value = RandomValueEx.GetRandomInt32(1, 100); var expected = TimeSpan.FromMinutes(value); var actual = value.ToMinutes(); actual .Should() .Be(expected); }
public void TryParsInt32Test() { var expected = RandomValueEx.GetRandomInt32(); var actual = expected.ToString(CultureInfo.CurrentCulture) .TryParsInt32(out var result); result .Should() .Be(expected); actual .Should() .BeTrue(); }
public void TryParsInt32OverloadTest() { var culture = new CultureInfo("de-CH"); var expected = RandomValueEx.GetRandomInt32(); var actual = expected.ToString(culture) .TryParsInt32(NumberStyles.Any, culture, out var result); result .Should() .Be(expected); actual .Should() .BeTrue(); }
public void CreateValueTest() { var expectedValue = RandomValueEx.GetRandomInt32(); var expectedMemberInformation = new MemberInformation(); IMemberInformation actualParameter = null; var target = new ExpressionInstanceFactory(x => { actualParameter = x; return(expectedValue); }); var actual = target.CreateValue(expectedMemberInformation); actual.Should() .Be(expectedValue); actualParameter.Should() .BeSameAs(expectedMemberInformation); }
public void GetValueTest6() { var model = new TestModel { MyListInt = new List <Int32> { RandomValueEx.GetRandomInt32(), RandomValueEx.GetRandomInt32(), RandomValueEx.GetRandomInt32() } }; var target = new ObjectValueProvider(model); var actual = target.GetValue("MyListInt[0]"); actual.Should() .Be(model.MyListInt[0] .ToString()); }
public void FactorOfTest() { var value = RandomValueEx.GetRandomInt32(); var factorNumer = RandomValueEx.GetRandomInt32(); var expected = factorNumer % value == 0; var actual = value.FactorOf(factorNumer); Assert.Equal(expected, actual); value = 10; factorNumer = 100; actual = value.FactorOf(factorNumer); Assert.True(actual); value = 11; factorNumer = 100; actual = value.FactorOf(factorNumer); Assert.False(actual); }
public void IsMultipleOfTest() { var value = RandomValueEx.GetRandomInt32(); var factor = RandomValueEx.GetRandomInt32(); var expected = value % factor == 0; var actual = value.IsMultipleOf(factor); Assert.Equal(expected, actual); value = 10; factor = 2; actual = value.IsMultipleOf(factor); Assert.True(actual); value = 10; factor = 3; actual = value.IsMultipleOf(factor); Assert.False(actual); }
public void IsMultipleOfTest() { Int64 value = RandomValueEx.GetRandomInt32(); Int64 factor = RandomValueEx.GetRandomInt32(); var expected = value % factor == 0; var actual = value.IsMultipleOf(factor); Assert.Equal(expected, actual); value = 10; factor = 2; actual = value.IsMultipleOf(factor); Assert.Equal(true, actual); value = 10; factor = 3; actual = value.IsMultipleOf(factor); Assert.Equal(false, actual); }