public void MaxOrDefault_OnDecimalArray_ReturnsMax()
            {
                var fixture = new RandomMultipleMockingFixture();
                var decimalArray = fixture.Create<decimal[]>();
                var decimalArrayMax = decimalArray.Max();

                Assert.That(() => decimalArray.MaxOrDefault(), Is.EqualTo(decimalArrayMax));
            }
            public void AverageOrDefault_OnDoubleArray_ReturnsDoubleArrayAverage()
            {
                var fixture = new RandomMultipleMockingFixture();
                var doubleArray = fixture.Create<double[]>();
                var doubleArrayAverage = doubleArray.Average();

                Assert.That(() => doubleArray.AverageOrDefault(), Is.EqualTo(doubleArrayAverage));
            }
            public void MaxOrDefault_OnDoubleArray_WithDoubleValue_ReturnsMax()
            {
                var fixture = new RandomMultipleMockingFixture();
                var doubleArray = fixture.Create<double[]>();
                var doubleArrayMax = doubleArray.Max();
                var doubleValue = fixture.Create<double>();

                Assert.That(() => doubleArray.MaxOrDefault(doubleValue), Is.EqualTo(doubleArrayMax));
            }
            public void AverageOrDefault_OnDecimalArray_WithDecimalValue_ReturnsAverage()
            {
                var fixture = new RandomMultipleMockingFixture();
                var decimalArray = fixture.Create<decimal[]>();
                var decimalArrayAverage = decimalArray.Average();
                var decimalValue = fixture.Create<decimal>();

                Assert.That(() => decimalArray.AverageOrDefault(decimalValue), Is.EqualTo(decimalArrayAverage));
            }
            public void ToOrOther_ToBadConvertible_OnIntegerWithAnyBadConvertible_ReturnsFalse()
            {
                var fixture = new RandomMultipleMockingFixture();
                var intValue = fixture.Create<int>();
                var convertible = fixture.Create<IConvertible>();
                IConvertible outParameter;
                var actual = intValue.ToOrOther(out outParameter, convertible);

                Assert.That(() => actual, Is.False);
            }
            public void ToOrOther_ToBadConvertible_OnInteger_OutBadConvertible()
            {
                var fixture = new RandomMultipleMockingFixture();
                var intValue = fixture.Create<int>();
                var convertible = fixture.Create<IConvertible>();
                IConvertible outParameter;
                intValue.ToOrOther(out outParameter, convertible);

                Assert.That(() => outParameter, Is.EqualTo(convertible));
            }
            public void RandomElement_OnCollectionSequence_ProducesRepeatableOutput_BasedOnKnownSeed()
            {
                const int numberItemsToCheck = 100;
                var fixture = new RandomMultipleMockingFixture(numberItemsToCheck);
                var seed = fixture.Create<int>();
                var random = new Random(seed);
                var integersFromSeed = Enumerable.Range(0, numberItemsToCheck).Select(i => random.Next(numberItemsToCheck)).ToArray();

                var checkList = fixture.Create<object[]>();

                random = new Random(seed);

                foreach (var i in integersFromSeed)
                {
                    Assert.That(() => checkList.RandomElement(random), Is.EqualTo(checkList[i]));
                }
            }
            public void MaxOrDefault_OnIntArray_WithLongfunc_WithLongValue_ReturnsMax()
            {
                var fixture = new RandomMultipleMockingFixture();
                var intArray = fixture.Create<int[]>();
                var longFunc = fixture.Create<Func<int, long>>();
                var longValue = fixture.Create<long>();
                var intArrayMax = intArray.Max(longFunc);

                Assert.That(() => intArray.MaxOrDefault(longFunc, longValue), Is.EqualTo(intArrayMax));
            }
            public void AverageOrDefault_OnIntArray_WithDecimalFunc_WithDecimalvalue_ReturnsAverage()
            {
                var fixture = new RandomMultipleMockingFixture();
                var intArray = fixture.Create<int[]>();
                var decimalFunc = fixture.Create<Func<int, decimal>>();
                var intArrayAverage = intArray.Average(decimalFunc);
                var decimalValue = fixture.Create<decimal>();

                Assert.That(() => intArray.AverageOrDefault(decimalFunc, decimalValue), Is.EqualTo(intArrayAverage));
            }
            public void AverageOrDefault_OnFloatArray_ReturnsFloatArrayAverage()
            {
                var fixture = new RandomMultipleMockingFixture();
                var floatArray = fixture.Create<float[]>();
                var floatArrayAverage = floatArray.Average();

                Assert.That(() => floatArray.AverageOrDefault(), Is.EqualTo(floatArrayAverage));
            }
Example #11
0
            public void Shuffle_OnSequence_WithRandom_ReturnsSameSequenceWithKnownSeed()
            {
                const int count = 100;
                var fixture = new RandomMultipleMockingFixture(count);
                var seed = fixture.Create<int>();
                var sequence = fixture.Create<object[]>();
                var random = new Random(seed);
                var shuffled1 = sequence.Shuffle(random).ToArray();
                random = new Random(seed);
                var shuffled2 = sequence.Shuffle(random).ToArray();

                Assert.That(() => shuffled1, Is.EqualTo(shuffled2));
            }
            public void AverageOrDefault_OnNullableIntArray_RetunrsNullableIntArrayAverage()
            {
                var fixture = new RandomMultipleMockingFixture();
                var nullableIntArray = fixture.Create<int?[]>();
                var nullableIntArrayAverage = nullableIntArray.Average();

                Assert.That(() => nullableIntArray.AverageOrDefault(), Is.EqualTo(nullableIntArrayAverage));
            }
            public void AverageOrDefault_OnNullableDoubleArray_WithDoubleValue_ReturnsNullableDoubleArrayAverage()
            {
                var fixture = new RandomMultipleMockingFixture();
                var nullableDoubleArray = fixture.Create<double?[]>();
                var nullableDoubleArrayAverage = nullableDoubleArray.Average();
                var doubleValue = fixture.Create<double>();

                Assert.That(() => nullableDoubleArray.AverageOrDefault(doubleValue), Is.EqualTo(nullableDoubleArrayAverage));
            }
            public void AverageOrDefault_OnIntArray_WithNullableLongFunc_WithLongValue_ReturnsAverage()
            {
                var fixture = new RandomMultipleMockingFixture();
                var intArray = fixture.Create<int[]>();
                var nullableLongFunc = fixture.Create<Func<int, long?>>();
                var intArrayAverage = intArray.Average(nullableLongFunc);
                var longValue = fixture.Create<long>();

                Assert.That(() => intArray.AverageOrDefault(nullableLongFunc, longValue), Is.EqualTo(intArrayAverage));
            }
            public void RandomElement_OnNonCollectionSequence_ProducesRepeatableOutput_BasedOnKnownSeed()
            {
                const int numberItemsToCheck = 100;
                var fixture = new RandomMultipleMockingFixture(numberItemsToCheck);
                var seed = fixture.Create<int>();
                IEnumerable<object> checkList = fixture.Create<object[]>().Select(o => o);

                var random = new Random(seed);
                var trial1 = Enumerable.Range(0, numberItemsToCheck).Select(r => checkList.RandomElement(random)).ToArray();
                random = new Random(seed);
                var trial2 = Enumerable.Range(0, numberItemsToCheck).Select(r => checkList.RandomElement(random)).ToArray();

                Assert.That(() => trial1, Is.EqualTo(trial2));
            }
            public void AverageOrDefault_OnIntArray_WithFloatFunc_WithFloatValue_ReturnsAverage()
            {
                var fixture = new RandomMultipleMockingFixture();
                var intArray = fixture.Create<int[]>();
                var floatFunc = fixture.Create<Func<int, float>>();
                var intArrayAverage = intArray.Average(floatFunc);
                var floatValue = fixture.Create<float>();

                Assert.That(() => intArray.AverageOrDefault(floatFunc, floatValue), Is.EqualTo(intArrayAverage));
            }
            public void MaxOrDefault_OnIntArray_WithDoubleFunc_WithDoubleValue_ReturnsMax()
            {
                var fixture = new RandomMultipleMockingFixture();
                var intArray = fixture.Create<int[]>();
                var doubleFunc = fixture.Create<Func<int, double>>();
                var intArrayMax = intArray.Max(doubleFunc);
                var doubleValue = fixture.Create<double>();

                Assert.That(() => intArray.MaxOrDefault(doubleFunc, doubleValue), Is.EqualTo(intArrayMax));
            }
            public void MaxOrDefault_OnIntArray_ReturnsIntArrayMax()
            {
                var fixture = new RandomMultipleMockingFixture();
                var intArray = fixture.Create<int[]>();
                var intArrayMax = intArray.Max();

                Assert.That(() => intArray.MaxOrDefault(), Is.EqualTo(intArrayMax));
            }
            public void MaxOrDefault_OnFloatArray_WithFloatValue_ReturnsFloatArrayMax()
            {
                var fixture = new RandomMultipleMockingFixture();
                var floatArray = fixture.Create<float[]>();
                var floatArrayMax = floatArray.Max();
                var floatValue = fixture.Create<float>();

                Assert.That(() => floatArray.MaxOrDefault(floatValue), Is.EqualTo(floatArrayMax));
            }
            public void MaxOrDefault_OnNullableIntArray_WithIntValue_ReturnsNullableIntArrayMax()
            {
                var fixture = new RandomMultipleMockingFixture();
                var nullableIntArray = fixture.Create<int?[]>();
                var nullableIntArrayMax = nullableIntArray.Max();
                var intValue = fixture.Create<int>();

                Assert.That(() => nullableIntArray.MaxOrDefault(intValue), Is.EqualTo(nullableIntArrayMax));
            }
            public void AverageOrDefault_OnIntArray_WithIntValue_ReturnsIntArrayAverage()
            {
                var fixture = new RandomMultipleMockingFixture();
                var intArray = fixture.Create<int[]>();
                var intValue = fixture.Create<int>();
                var intArrayAverage = intArray.Average();

                Assert.That(() => intArray.AverageOrDefault(intValue), Is.EqualTo(intArrayAverage));
            }
            public void MaxOrDefault_OnIntArray_WithNullableDecimalFunc_WithDecimalValue_ReturnsMax()
            {
                var fixture = new RandomMultipleMockingFixture();
                var intArray = fixture.Create<int[]>();
                var nullableDecimalFunc = fixture.Create<Func<int, decimal?>>();
                var intArrayMax = intArray.Max(nullableDecimalFunc);
                var decimalValue = fixture.Create<decimal>();

                Assert.That(() => intArray.MaxOrDefault(nullableDecimalFunc, decimalValue), Is.EqualTo(intArrayMax));
            }
            public void AverageOrDefault_OnIntArray_WithNullableDecimalFunc_ReturnsAverage()
            {
                var fixture = new RandomMultipleMockingFixture();
                var intArray = fixture.Create<int[]>();
                var nullableDecimalFunc = fixture.Create<Func<int, decimal?>>();
                var intArrayAverage = intArray.Average(nullableDecimalFunc);

                Assert.That(() => intArray.AverageOrDefault(nullableDecimalFunc), Is.EqualTo(intArrayAverage));
            }
            public void MaxOrDefault_OnIntArray_WithNullableLongFunc_ReturnsMax()
            {
                var fixture = new RandomMultipleMockingFixture();
                var intArray = fixture.Create<int[]>();
                var nullableLongFunc = fixture.Create<Func<int, long?>>();
                var intArrayMax = intArray.Max(nullableLongFunc);

                Assert.That(() => intArray.MaxOrDefault(nullableLongFunc), Is.EqualTo(intArrayMax));
            }
            public void AverageOrDefault_OnLongArray_ReturnsLongArrayAverage()
            {
                var fixture = new RandomMultipleMockingFixture();
                var longArray = fixture.Create<long[]>();
                var longArrayAverage = longArray.Average();

                Assert.That(() => longArray.AverageOrDefault(), Is.EqualTo(longArrayAverage));
            }
            public void MaxOrDefault_OnLongArray_WithLongValue_ReturnsLongArrayMax()
            {
                var fixture = new RandomMultipleMockingFixture();
                var longArray = fixture.Create<long[]>();
                var longArrayMax = longArray.Max();
                var longValue = fixture.Create<long>();

                Assert.That(() => longArray.MaxOrDefault(longValue), Is.EqualTo(longArrayMax));
            }
            public void AverageOrDefault_OnNullableFloatArray_WithFloatValue_ReturnsNullableFloatArrayAverage()
            {
                var fixture = new RandomMultipleMockingFixture();
                var nullableFloatArray = fixture.Create<float?[]>();
                var nullableFloatArrayAverage = nullableFloatArray.Average();
                var floatValue = fixture.Create<float>();

                Assert.That(() => nullableFloatArray.AverageOrDefault(floatValue), Is.EqualTo(nullableFloatArrayAverage));
            }
            public void MaxOrDefault_OnNullableDecimalArray_WithDecimalValue_ReturnsNullableDecimalArrayMax()
            {
                var fixture = new RandomMultipleMockingFixture();
                var nullableDecimalArray = fixture.Create<decimal?[]>();
                var decimalValue = fixture.Create<decimal>();
                var nullableDecimalArrayMax = nullableDecimalArray.Max();

                Assert.That(() => nullableDecimalArray.MaxOrDefault(decimalValue), Is.EqualTo(nullableDecimalArrayMax));
            }
            public void AverageOrDefault_OnNullableLongArray_WithLongValue_ReturnsNullableLongArrayAverage()
            {
                var fixture = new RandomMultipleMockingFixture();
                var nullableLongArray = fixture.Create<long?[]>();
                var nullableLongArrayAverage = nullableLongArray.Average();
                var longValue = fixture.Create<long>();

                Assert.That(() => nullableLongArray.AverageOrDefault(longValue), Is.EqualTo(nullableLongArrayAverage));
            }
            public void MaxOrDefault_OnNullableFloatArray_ReturnsNullableFloatArrayMax()
            {
                var fixture = new RandomMultipleMockingFixture();
                var nullableFloatArray = fixture.Create<float?[]>();
                var nullableFloatArrayMax = nullableFloatArray.Max();

                Assert.That(() => nullableFloatArray.MaxOrDefault(), Is.EqualTo(nullableFloatArrayMax));
            }