Beispiel #1
0
            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));
            }
Beispiel #2
0
            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>());
            }
            public void ToOrNull_ToBadConvertible_OnAnyInteger_OutNull()
            {
                var fixture = new RandomNumberFixture();
                IConvertible outParameter;
                fixture.Create<int>().ToOrNull(out outParameter);

                Assert.That(() => outParameter, Is.Null);
            }
            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);
            }
Beispiel #5
0
            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);
            }
Beispiel #6
0
            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));
            }
Beispiel #7
0
            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>());
            }
            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));
            }
Beispiel #9
0
            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));
            }
Beispiel #10
0
            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));
            }
            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));
            }
            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));
            }
            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));
            }
            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));
            }
            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));
            }
            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)));
            }
Beispiel #17
0
            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));
            }
            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));
            }
            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));
            }
            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));
            }
            public void AverageOrDefault_OnNullIntSequence_WithIntValue_ReturnsIntValue()
            {
                IEnumerable<int> nullIntSequence = null;
                var fixture = new RandomNumberFixture();
                var intValue = fixture.Create<int>();

                Assert.That(() => nullIntSequence.AverageOrDefault(intValue), Is.EqualTo(intValue));
            }
            public void MaxOrDefault_OnEmptyIntSequence_WithNullableDecimalFunc_WithDecimalValue_ReturnsDecimalValue()
            {
                var fixture = new RandomNumberFixture();
                var emptyIntSequence = Enumerable.Empty<int>();
                var nullableDecimalFunc = fixture.Create<Func<int, decimal?>>();
                var decimalValue = fixture.Create<decimal>();

                Assert.That(() => emptyIntSequence.MaxOrDefault(nullableDecimalFunc, decimalValue), Is.EqualTo(decimalValue));
            }
            public void AverageOrDefault_OnNullIntSequence_WithFloatFunc_WithFloatValue_ReturnsFloatValue()
            {
                IEnumerable<int> nullIntSequence = null;
                var fixture = new RandomNumberFixture();
                var floatFunc = fixture.Create<Func<int, float>>();
                var floatValue = fixture.Create<float>();

                Assert.That(() => nullIntSequence.AverageOrDefault(floatFunc, floatValue), Is.EqualTo(floatValue));
            }
            public void AverageOrDefault_OnEmptyIntSequence_WithNullableFloatFunc_WithFloatValue_ReturnsFloatValue()
            {
                var fixture = new RandomNumberFixture();
                var emptyIntSequence = Enumerable.Empty<int>();
                var nullableFloatFunc = fixture.Create<Func<int, float?>>();
                var floatValue = fixture.Create<float>();

                Assert.That(() => emptyIntSequence.AverageOrDefault(nullableFloatFunc, floatValue), Is.EqualTo(floatValue));
            }
Beispiel #25
0
            public void ToNullableInt_OnIntegerString_ReturnsInteger()
            {
                var fixture = new RandomNumberFixture();
                var intValue = fixture.Create<int>();
                var intString = intValue.ToString();

                Assert.That(() => intString.To<int?>(), Is.EqualTo(intValue));
            }
            public void AverageOrDefault_OnEmptyNullableDoubleSequence_WithDoubleValue_ReturnsDoubleValue()
            {
                var fixture = new RandomNumberFixture();
                var emptyNullableDoubleSequence = Enumerable.Empty<double?>();
                var doubleValue = fixture.Create<double>();

                Assert.That(() => emptyNullableDoubleSequence.AverageOrDefault(doubleValue), Is.EqualTo(doubleValue));
            }
            public void AverageOrDefault_OnNullLongSequence_WithLongValue_ReturnsLongValue()
            {
                IEnumerable<long> nullLongSequence = null;
                var fixture = new RandomNumberFixture();
                var longValue = fixture.Create<long>();

                Assert.That(() => nullLongSequence.AverageOrDefault(longValue), Is.EqualTo(longValue));
            }
            public void MaxOrDefault_OnEmptyIntSequence_WithNullableLongFunc_WithLongValue_ReturnsLongValue()
            {
                var fixture = new RandomNumberFixture();
                var emptyIntSequence = Enumerable.Empty<int>();
                var nullableLongFunc = fixture.Create<Func<int, long?>>();
                var longValue = fixture.Create<long>();

                Assert.That(() => emptyIntSequence.MaxOrDefault(nullableLongFunc, longValue), Is.EqualTo(longValue));
            }
Beispiel #29
0
            public void ToInteger_OnNonNullNullableInteger_ReturnsTestInteger()
            {
                var fixture = new RandomNumberFixture();
                var intValue = fixture.Create<int>();
                int? nonNullNullableInt = intValue;

                Assert.That(() => nonNullNullableInt.To<int>(), Is.EqualTo(intValue));
            }
            public void AverageOrDefault_OnEmptyFloatSequence_WithFloatValue_ReturnsFloatvalue()
            {
                var fixture = new RandomNumberFixture();
                var emptyFloatSequence = Enumerable.Empty<float>();
                var floatValue = fixture.Create<float>();

                Assert.That(() => emptyFloatSequence.AverageOrDefault(floatValue), Is.EqualTo(floatValue));
            }