本文整理汇总了C#中CustomExtensions.UnitTests.Customization.Fixtures.RandomNumberFixture类的典型用法代码示例。如果您正苦于以下问题:C# RandomNumberFixture类的具体用法?C# RandomNumberFixture怎么用?C# RandomNumberFixture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RandomNumberFixture类属于CustomExtensions.UnitTests.Customization.Fixtures命名空间,在下文中一共展示了RandomNumberFixture类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ToInteger_OnDecimal_ReturnsInteger
public void ToInteger_OnDecimal_ReturnsInteger()
{
var fixture = new RandomNumberFixture();
var decimalValue = fixture.Create<decimal>();
int intValue = Convert.ToInt32(decimalValue);
Assert.That(() => decimalValue.To<int>(), Is.EqualTo(intValue));
}
开发者ID:jcomtois,项目名称:CustomExtensions,代码行数:8,代码来源:ToTest.cs
示例2: Left_OnNullString_ThrowsValidationException
public void Left_OnNullString_ThrowsValidationException()
{
string nullString = null;
var fixture = new RandomNumberFixture();
var intValue = fixture.Create<int>();
Assert.That(() => nullString.Left(intValue), Throws.TypeOf<ValidationException>().With.InnerException.TypeOf<ArgumentNullException>());
}
开发者ID:jcomtois,项目名称:CustomExtensions,代码行数:8,代码来源:LeftTest.cs
示例3: ToOrNull_ToBadConvertible_OnAnyInteger_OutNull
public void ToOrNull_ToBadConvertible_OnAnyInteger_OutNull()
{
var fixture = new RandomNumberFixture();
IConvertible outParameter;
fixture.Create<int>().ToOrNull(out outParameter);
Assert.That(() => outParameter, Is.Null);
}
开发者ID:jcomtois,项目名称:CustomExtensions,代码行数:8,代码来源:ToOrNullTest.cs
示例4: ToOrNull_ToBadConvertible_OnAnyInteger_ReturnsFalse
public void ToOrNull_ToBadConvertible_OnAnyInteger_ReturnsFalse()
{
var fixture = new RandomNumberFixture();
IConvertible outParameter;
var actual = fixture.Create<int>().ToOrNull(out outParameter);
Assert.That(() => actual, Is.False);
}
开发者ID:jcomtois,项目名称:CustomExtensions,代码行数:8,代码来源:ToOrNullTest.cs
示例5: Left_OnEmptyString_ReturnsEmptyString
public void Left_OnEmptyString_ReturnsEmptyString()
{
var emptyString = string.Empty;
var fixture = new RandomNumberFixture();
var intValue = fixture.Create<int>();
Assert.That(() => emptyString.Left(intValue), Is.Empty);
}
开发者ID:jcomtois,项目名称:CustomExtensions,代码行数:8,代码来源:LeftTest.cs
示例6: ToFloat_OnDecimal_ReturnsFloat
public void ToFloat_OnDecimal_ReturnsFloat()
{
var fixture = new RandomNumberFixture();
var decimalValue = fixture.Create<decimal>();
float floatValue = Convert.ToSingle(decimalValue);
Assert.That(() => decimalValue.To<float>(), Is.EqualTo(floatValue));
}
开发者ID:jcomtois,项目名称:CustomExtensions,代码行数:8,代码来源:ToTest.cs
示例7: Left_OnNullString_WithNegativeLength_ThrowsValidationException
public void Left_OnNullString_WithNegativeLength_ThrowsValidationException()
{
string nullString = null;
var fixture = new RandomNumberFixture();
var intValue = fixture.Create<int>();
intValue = -intValue;
Assert.That(() => nullString.Left(intValue), Throws.TypeOf<ValidationException>().With.InnerException.TypeOf<MultiException>());
}
开发者ID:jcomtois,项目名称:CustomExtensions,代码行数:9,代码来源:LeftTest.cs
示例8: ToOrOther_ToInteger_OnNullStringWithInteger_OutInteger
public void ToOrOther_ToInteger_OnNullStringWithInteger_OutInteger()
{
string nullString = null;
var fixture = new RandomNumberFixture();
var intValue = fixture.Create<int>();
int outParameter;
nullString.ToOrOther(out outParameter, intValue);
Assert.That(() => outParameter, Is.EqualTo(intValue));
}
开发者ID:jcomtois,项目名称:CustomExtensions,代码行数:10,代码来源:ToOrOtherTest.cs
示例9: Parse_ToDecimal_OnNegativeInteger_ReturnsDecimal
public void Parse_ToDecimal_OnNegativeInteger_ReturnsDecimal()
{
var fixture = new RandomNumberFixture();
var intValue = Math.Abs(fixture.Create<int>());
intValue++;
var negativeInt = -intValue / (intValue + 1);
var negativeIntString = negativeInt.ToString();
var converted = Convert.ToDecimal(negativeIntString);
Assert.That(() => negativeIntString.Parse<decimal>(), Is.EqualTo(converted));
}
开发者ID:jcomtois,项目名称:CustomExtensions,代码行数:11,代码来源:ParseTest.cs
示例10: Parse_ToDecimal_OnPositiveDecimal_ReturnsDecimal
public void Parse_ToDecimal_OnPositiveDecimal_ReturnsDecimal()
{
var fixture = new RandomNumberFixture();
var decimalValue = Math.Abs(fixture.Create<decimal>());
decimalValue++;
var positiveDecimal = decimalValue / (decimalValue + 1);
var positiveDecimalString = positiveDecimal.ToString("F");
var converted = Convert.ToDecimal(positiveDecimalString);
Assert.That(() => positiveDecimalString.Parse<decimal>(), Is.EqualTo(converted));
}
开发者ID:jcomtois,项目名称:CustomExtensions,代码行数:11,代码来源:ParseTest.cs
示例11: AverageOrDefault_OnNullIntSequence_WithDoubleFunc_WithDoubleValue_ReturnsDoubleValue
public void AverageOrDefault_OnNullIntSequence_WithDoubleFunc_WithDoubleValue_ReturnsDoubleValue()
{
IEnumerable<int> nullIntSequence = null;
var fixture = new RandomNumberFixture();
var doubleFunc = fixture.Create<Func<int, double>>();
var doubeValue = fixture.Create<double>();
Assert.That(() => nullIntSequence.AverageOrDefault(doubleFunc, doubeValue), Is.EqualTo(doubeValue));
}
开发者ID:jcomtois,项目名称:CustomExtensions,代码行数:9,代码来源:AverageOrDefaultTest.cs
示例12: AverageOrDefault_OnEmptyDecimalSequence_WithDecimalValue_ReturnsDecimalValue
public void AverageOrDefault_OnEmptyDecimalSequence_WithDecimalValue_ReturnsDecimalValue()
{
var fixture = new RandomNumberFixture();
var emtpyDecimalSequence = Enumerable.Empty<decimal>();
var decimalValue = fixture.Create<decimal>();
Assert.That(() => emtpyDecimalSequence.AverageOrDefault(decimalValue), Is.EqualTo(decimalValue));
}
开发者ID:jcomtois,项目名称:CustomExtensions,代码行数:8,代码来源:AverageOrDefaultTest.cs
示例13: AverageOrDefault_OnNullDecimalSequence_WithDecimalValue_ReturnsDecimalValue
public void AverageOrDefault_OnNullDecimalSequence_WithDecimalValue_ReturnsDecimalValue()
{
IEnumerable<decimal> nullDecimalSequence = null;
var fixture = new RandomNumberFixture();
var decimalValue = fixture.Create<decimal>();
Assert.That(() => nullDecimalSequence.AverageOrDefault(decimalValue), Is.EqualTo(decimalValue));
}
开发者ID:jcomtois,项目名称:CustomExtensions,代码行数:8,代码来源:AverageOrDefaultTest.cs
示例14: AverageOrDefault_OnEmptyNullableLongSequence_WithLongValue_ReturnsLongValue
public void AverageOrDefault_OnEmptyNullableLongSequence_WithLongValue_ReturnsLongValue()
{
var fixture = new RandomNumberFixture();
var emptyNullableLongSequnce = Enumerable.Empty<long?>();
var longValue = fixture.Create<long>();
Assert.That(() => emptyNullableLongSequnce.AverageOrDefault(longValue), Is.EqualTo(longValue));
}
开发者ID:jcomtois,项目名称:CustomExtensions,代码行数:8,代码来源:AverageOrDefaultTest.cs
示例15: AverageOrDefault_OnEmptyNullableIntSequence_WithIntValue_ReturnsIntValue
public void AverageOrDefault_OnEmptyNullableIntSequence_WithIntValue_ReturnsIntValue()
{
var fixture = new RandomNumberFixture();
var emptyNullableIntSequence = Enumerable.Empty<int?>();
var intValue = fixture.Create<int>();
Assert.That(() => emptyNullableIntSequence.AverageOrDefault(intValue), Is.EqualTo(intValue));
}
开发者ID:jcomtois,项目名称:CustomExtensions,代码行数:8,代码来源:AverageOrDefaultTest.cs
示例16: MaxOrDefault_OnEmptyIntSequence_WithNullableIntFunc_ReturnsDefaultInt
public void MaxOrDefault_OnEmptyIntSequence_WithNullableIntFunc_ReturnsDefaultInt()
{
var fixture = new RandomNumberFixture();
var emptyIntSequence = Enumerable.Empty<int>();
var nullableIntFunc = fixture.Create<Func<int, int?>>();
Assert.That(() => emptyIntSequence.MaxOrDefault(nullableIntFunc), Is.EqualTo(default(int)));
}
开发者ID:jcomtois,项目名称:CustomExtensions,代码行数:8,代码来源:MaxOrDefaultTest.cs
示例17: ToString_OnTestInteger_ReturnsTestIntegerString
public void ToString_OnTestInteger_ReturnsTestIntegerString()
{
var fixture = new RandomNumberFixture();
var intValue = fixture.Create<int>();
var intString = intValue.ToString();
Assert.That(() => intValue.To<string>(), Is.EqualTo(intString));
}
开发者ID:jcomtois,项目名称:CustomExtensions,代码行数:8,代码来源:ToTest.cs
示例18: AverageOrDefault_OnEmptyIntSequence_WithNullableDuoubleFunc_WithDoubleValue_ReturnsDoubleValue
public void AverageOrDefault_OnEmptyIntSequence_WithNullableDuoubleFunc_WithDoubleValue_ReturnsDoubleValue()
{
var fixture = new RandomNumberFixture();
var emptyIntSequence = Enumerable.Empty<int>();
var nullableDoubleFunc = fixture.Create<Func<int, double?>>();
var doubleValue = fixture.Create<double>();
Assert.That(() => emptyIntSequence.AverageOrDefault(nullableDoubleFunc, doubleValue), Is.EqualTo(doubleValue));
}
开发者ID:jcomtois,项目名称:CustomExtensions,代码行数:9,代码来源:AverageOrDefaultTest.cs
示例19: AverageOrDefault_OnNullIntSequence_WithNullableLongFunc_WithLongValue_ReturnsLongValue
public void AverageOrDefault_OnNullIntSequence_WithNullableLongFunc_WithLongValue_ReturnsLongValue()
{
IEnumerable<int> nullIntSequence = null;
var fixture = new RandomNumberFixture();
var nullableLongFunc = fixture.Create<Func<int, long?>>();
var longValue = fixture.Create<long>();
Assert.That(() => nullIntSequence.AverageOrDefault(nullableLongFunc, longValue), Is.EqualTo(longValue));
}
开发者ID:jcomtois,项目名称:CustomExtensions,代码行数:9,代码来源:AverageOrDefaultTest.cs
示例20: AverageOrDefault_OnNullIntSequence_WithNullableDecimalFunc_WithDecimalValue_ReturnsDecimalValue
public void AverageOrDefault_OnNullIntSequence_WithNullableDecimalFunc_WithDecimalValue_ReturnsDecimalValue()
{
IEnumerable<int> nullIntSequence = null;
var fixture = new RandomNumberFixture();
var nullableDecimalFunc = fixture.Create<Func<int, decimal?>>();
var decimalValue = fixture.Create<decimal>();
Assert.That(() => nullIntSequence.AverageOrDefault(nullableDecimalFunc, decimalValue), Is.EqualTo(decimalValue));
}
开发者ID:jcomtois,项目名称:CustomExtensions,代码行数:9,代码来源:AverageOrDefaultTest.cs
注:本文中的CustomExtensions.UnitTests.Customization.Fixtures.RandomNumberFixture类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论