Esempio n. 1
0
        /// <summary>
        /// Adds an enumeration to the builder, and "echos" the added values.
        /// </summary>
        /// <param name="values">The values to add to the builder.</param>
        /// <param name="sampleBuilder">The builder, to which the values are added.</param>
        /// <returns>The added values.</returns>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="values" /> is <c>null</c>.
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="sampleBuilder" /> is <c>null</c>.
        /// </exception>
        public static IEnumerable <double> AddToSampleBuilder(this IEnumerable <double> values, SampleBuilder sampleBuilder)
        {
            if (values == null)
            {
                ThrowHelper.ThrowArgumentNull(ThrowHelper.ExceptionArgument.values);
            }
            if (sampleBuilder == null)
            {
                ThrowHelper.ThrowArgumentNull(ThrowHelper.ExceptionArgument.sampleBuilder);
            }

            return(sampleBuilder.AddWithYield(values));
        }
Esempio n. 2
0
        public void Array_given___correct_Sample()
        {
            double[] values   = { 1, 2, 3 };
            var      expected = new Sample(values);

            var sut = new SampleBuilder();

            double[] res    = sut.AddWithYield(values).ToArray();
            Sample   actual = sut.GetSample();

            Assert.Multiple(() =>
            {
                CollectionAssert.AreEqual(values, res);
                CollectionAssert.AreEqual(expected.Values, actual.Values);
                Assert.AreEqual(expected.ToString(), actual.ToString());
            });
        }
Esempio n. 3
0
        public void Add_item_then_AddWithYield_Array___correct_Sample_and_correct_yielding()
        {
            double[] values   = { 1, 2, 3 };
            var      expected = new Sample(new[] { 42d }.Concat(values));

            var sut = new SampleBuilder();

            sut.Add(42d);
            var    res    = sut.AddWithYield(values).ToArray();
            Sample actual = sut.GetSample();

            Assert.Multiple(() =>
            {
                CollectionAssert.AreEqual(values, res);
                CollectionAssert.AreEqual(expected.Values, actual.Values);
                Assert.AreEqual(expected.ToArray(), actual.ToArray());
            });
        }