IEnumerableExtensions

Namespace: XAct.Core.PCL
We found 10 examples in language CSharp for this search. You will see 34 fragments of code.

        [Fact]
        public void ForEach_generic_throws_ArgumentNullException()
        {
            IEnumerable<object> enumeration = new[] { "a", "b", "c" };
            void action(object _) { }
            Assert.Throws<ArgumentNullException>(() => IEnumerableExtensions.ForEach<object>((IEnumerable<object>)null, action));
            Assert.Throws<ArgumentNullException>(() => IEnumerableExtensions.ForEach<object>(enumeration, (Action<object>)null));
        }

        [Fact]
        public void ForEach_throws_ArgumentNullException()
        {
            IEnumerable enumeration = new[] { "a", "b", "c" };
            void action(object _) { }
            Assert.Throws<ArgumentNullException>(() => IEnumerableExtensions.ForEach((IEnumerable)null, action));
            Assert.Throws<ArgumentNullException>(() => IEnumerableExtensions.ForEach(enumeration, (Action<object>)null));
        }

        [Fact]
        public void Apply_generic_throws_ArgumentNullException()
        {
            IEnumerable<object> enumeration = new[] { "a", "b", "c" };
            void action(object _) { }
            Assert.Throws<ArgumentNullException>(() => IEnumerableExtensions.Apply<object>((IEnumerable<object>)null, action).Iterate());
            Assert.Throws<ArgumentNullException>(() => IEnumerableExtensions.Apply<object>(enumeration, (Action<object>)null).Iterate());
        }

        [Fact]
        public void Apply_throws_ArgumentNullException()
        {
            IEnumerable enumeration = new[] { "a", "b", "c" };
            void action(object _) { }
            Assert.Throws<ArgumentNullException>(() => IEnumerableExtensions.Apply((IEnumerable)null, action).Iterate());
            Assert.Throws<ArgumentNullException>(() => IEnumerableExtensions.Apply(enumeration, (Action<object>)null).Iterate());
        }

        [Fact]
        public void DistinctBy_throws_ArgumentNullException()
        {
            IEnumerable<object> enumeration = new[] { "a", "b", "c" };
            object action(object value) => value;
            Assert.Throws<ArgumentNullException>(() => IEnumerableExtensions.DistinctBy((IEnumerable<object>)null, action).Iterate());
            Assert.Throws<ArgumentNullException>(() => IEnumerableExtensions.DistinctBy(enumeration, (Func<object, object>)null).Iterate());
        }

        [Fact]
        public void Iterate_throws_ArgumentNullException()
        {
            Assert.Throws<ArgumentNullException>(() => IEnumerableExtensions.Iterate(null));
        }

        static void Main()
        {
            int [] arr = new int[]{3, 4, 1, 7, 10};
            Console.WriteLine( IEnumerableExtensions.Sum(arr) );
            Console.WriteLine( IEnumerableExtensions.Average(arr) );
            Console.WriteLine( IEnumerableExtensions.Max(arr) );
            Console.WriteLine( IEnumerableExtensions.Min(arr) );
            Console.WriteLine( IEnumerableExtensions.Product(arr) );
        }

        [TestMethod]
        public void IEnumerableExtensions_AllEqual_NullArgChecks()
        {
            Exceptions.Expect<ArgumentNullException>(() => IEnumerableExtensions.AllEqual(null, EqualityComparer<object>.Default));
            Exceptions.Expect<ArgumentNullException>(() => IEnumerableExtensions.AllEqual(new object[0], null));
        }

        [TestMethod]
        public void IEnumerableExtensions_AllEqual_Empty_IsTrue()
        {
            // Act + Assert
            IEnumerableExtensions.AllEqual(new int[0]).Should().BeTrue("Expected empty enumerable to be AllEqual");
        }

		public static IList<T> Shuffle<T>(this IList<T> List)
		{
			for (int I = 0; I < List.Count; I++)
			{
				List.Swap(I, IEnumerableExtensions.Generator.Next(I, List.Count));
			}
			return List;
		}

		public static T Random<T>(this IList<T> List)
		{
			return List[IEnumerableExtensions.Generator.Next(0, List.Count)];
		}

        static void Main()
        {
            int [] arr = new int[]{3, 4, 1, 7, 10};
            Console.WriteLine( IEnumerableExtensions.Sum(arr) );
            Console.WriteLine( IEnumerableExtensions.Average(arr) );
            Console.WriteLine( IEnumerableExtensions.Max(arr) );
            Console.WriteLine( IEnumerableExtensions.Min(arr) );
            Console.WriteLine( IEnumerableExtensions.Product(arr) );
        }


        [Test]
        public void TestSkipLast()
        {
            Assert.Throws<ArgumentNullException>(() => { IEnumerableExtensions.SkipLast<string>(null, 5); });

            var input = new[] { "one", "two", "three", "four" };
            Assert.IsTrue(input.SkipLast(0).SequenceEqual(input));
            Assert.IsTrue(input.SkipLast(2).SequenceEqual(new[] { "one", "two" }));
            Assert.IsTrue(input.SkipLast(20).SequenceEqual(new string[0]));
        }

        [TestMethod()]
        public void SplitWhere_NotConsecutive_ReturnsCorrect()
        {
            var source = new[] { 1, 2, 3, 6, 7, 8, 9, 10, 15, 100 };
            var firstSecondPredicate = new Func<int, int, bool>((first, second) => !second.Equals(first + 1));
            var expected = new[]
            {
                new[] { 1, 2, 3 },
                new[] { 6, 7, 8, 9, 10 },
                new[] { 15 },
                new[] { 100 }
            };
            var actual = IEnumerableExtensions.SplitWhere(source, firstSecondPredicate).ToArray();
            for (int i = 0; i < expected.Count(); i++)
            {
                Assert.IsTrue(expected[i].SequenceEqual(actual[i]));
            }
        }

        [TestMethod()]
        public void SplitWhere_Empty_ReturnsEmpty()
        {
            var source = Enumerable.Empty<int>();
            var firstSecondPredicate = new Func<int, int, bool>((first, second) => !second.Equals(first + 1));
            var expected = 0;
            var actual = IEnumerableExtensions.SplitWhere(source, firstSecondPredicate).Count();
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void MaxConsecutive_Normal_ReturnsCorrect()
        {
            var values = new[] { 1, 2, 3, 6, 7, 8, 9, 10, 15, 100 };
            int expected = 5;
            int actual;
            actual = IEnumerableExtensions.MaxConsecutive(values);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void MaxConsecutive_100000_SpeedTest()
        {
            var values = Enumerable.Range(1, 100000);
            int expected = 100000;
            int actual;
            actual = IEnumerableExtensions.MaxConsecutive(values);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void MaxConsecutiveMonths_SomeConsecutive_ReturnsCorrect()
        {
            var dates = new[]
            {
                new DateTime(2000, 1, 5),
                new DateTime(1999, 1, 1),
                new DateTime(1999, 1, 15),
                new DateTime(1999, 2, 7),
                new DateTime(1999, 3, 1),
                new DateTime(1999, 6, 30),
                new DateTime(1999, 7, 1),
                new DateTime(1999, 11, 24),
                new DateTime(1999, 12, 24),
                new DateTime(2000, 2, 1),
                new DateTime(2000, 3, 1),
                new DateTime(2000, 4, 1),
                new DateTime(2000, 5, 31),
                new DateTime(2000, 7, 1)
            };
            int expected = 7;
            int actual;
            actual = IEnumerableExtensions.MaxConsecutiveMonths(dates);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void MaxConsecutiveMonths_AllConsecutive_ReturnsCorrect()
        {
            var dates = new[]
            {
                new DateTime(1999, 11, 24),
                new DateTime(1999, 12, 24),
                new DateTime(2000, 1, 5),
                new DateTime(2000, 2, 1),
                new DateTime(2000, 3, 1),
                new DateTime(2000, 4, 1),
                new DateTime(2000, 5, 31)
            };
            int expected = 7;
            int actual;
            actual = IEnumerableExtensions.MaxConsecutiveMonths(dates);
            Assert.AreEqual(expected, actual);
        }

        public static IcmpLayer NextIcmpLayer(this Random random)
        {
            IcmpMessageType icmpMessageType = random.NextEnum(IcmpMessageType.DomainNameReply);
            ushort? checksum = random.NextBool() ? (ushort?)random.NextUShort() : null;

            switch (icmpMessageType)
            {
                case IcmpMessageType.DestinationUnreachable:
                    return new IcmpDestinationUnreachableLayer
                           {
                               Code = random.NextEnum<IcmpCodeDestinationUnreachable>(),
                               Checksum = checksum,
                               NextHopMaximumTransmissionUnit =
                               random.NextUShort(IcmpDestinationUnreachableDatagram.MinimumMaximumTransmissionUnit, ushort.MaxValue),
                           };

                case IcmpMessageType.TimeExceeded:
                    return new IcmpTimeExceededLayer
                           {
                               Code = random.NextEnum<IcmpCodeTimeExceeded>(),
                               Checksum = checksum,
                           };

                case IcmpMessageType.ParameterProblem:
                    return new IcmpParameterProblemLayer
                           {
                               Checksum = checksum,
                               Pointer = random.NextByte(),
                               OriginalDatagramLength = random.NextByte() * sizeof(uint),
                           };

                case IcmpMessageType.SourceQuench:
                    return new IcmpSourceQuenchLayer
                           {
                               Checksum = checksum
                           };

                case IcmpMessageType.Redirect:
                    return new IcmpRedirectLayer
                           {
                               Code = random.NextEnum<IcmpCodeRedirect>(),
                               Checksum = checksum,
                               GatewayInternetAddress = random.NextIpV4Address()
                           };

                case IcmpMessageType.Echo:
                    return new IcmpEchoLayer
                           {
                               Checksum = checksum,
                               Identifier = random.NextUShort(),
                               SequenceNumber = random.NextUShort()
                           };

                case IcmpMessageType.EchoReply:
                    return new IcmpEchoReplyLayer
                           {
                               Checksum = checksum,
                               Identifier = random.NextUShort(),
                               SequenceNumber = random.NextUShort()
                           };


                case IcmpMessageType.Timestamp:
                    return new IcmpTimestampLayer
                           {
                               Checksum = checksum,
                               Identifier = random.NextUShort(),
                               SequenceNumber = random.NextUShort(),
                               OriginateTimestamp = random.NextIpV4TimeOfDay(),
                               ReceiveTimestamp = random.NextIpV4TimeOfDay(),
                               TransmitTimestamp = random.NextIpV4TimeOfDay()
                           };

                case IcmpMessageType.TimestampReply:
                    return new IcmpTimestampReplyLayer
                           {
                               Checksum = checksum,
                               Identifier = random.NextUShort(),
                               SequenceNumber = random.NextUShort(),
                               OriginateTimestamp = random.NextIpV4TimeOfDay(),
                               ReceiveTimestamp = random.NextIpV4TimeOfDay(),
                               TransmitTimestamp = random.NextIpV4TimeOfDay()
                           };

                case IcmpMessageType.InformationRequest:
                    return new IcmpInformationRequestLayer
                           {
                               Checksum = checksum,
                               Identifier = random.NextUShort(),
                               SequenceNumber = random.NextUShort(),
                           };

                case IcmpMessageType.InformationReply:
                    return new IcmpInformationReplyLayer
                           {
                               Checksum = checksum,
                               Identifier = random.NextUShort(),
                               SequenceNumber = random.NextUShort(),
                           };


                case IcmpMessageType.RouterAdvertisement:
                    return new IcmpRouterAdvertisementLayer
                           {
                               Entries = random.NextIcmpRouterAdvertisementEntries(random.Next(10)).ToList().AsReadOnly(),
                               Checksum = checksum,
                               Lifetime = random.NextTimeSpan(TimeSpan.Zero, TimeSpan.FromSeconds(ushort.MaxValue)),
                           };

                case IcmpMessageType.RouterSolicitation:
                    return new IcmpRouterSolicitationLayer
                           {
                               Checksum = checksum,
                           };

                case IcmpMessageType.AddressMaskRequest:
                    return new IcmpAddressMaskRequestLayer
                           {
                               Checksum = checksum,
                               Identifier = random.NextUShort(),
                               SequenceNumber = random.NextUShort(),
                               AddressMask = random.NextIpV4Address()
                           };

                case IcmpMessageType.AddressMaskReply:
                    return new IcmpAddressMaskReplyLayer
                           {
                               Checksum = checksum,
                               Identifier = random.NextUShort(),
                               SequenceNumber = random.NextUShort(),
                               AddressMask = random.NextIpV4Address()
                           };

                case IcmpMessageType.TraceRoute:
                    return new IcmpTraceRouteLayer
                           {
                               Code = random.NextEnum<IcmpCodeTraceRoute>(),
                               Checksum = checksum,
                               Identification = random.NextUShort(),
                               OutboundHopCount = random.NextUShort(),
                               ReturnHopCount = random.NextUShort(),
                               OutputLinkSpeed = random.NextUInt(),
                               OutputLinkMaximumTransmissionUnit = random.NextUInt(),
                           };

                case IcmpMessageType.ConversionFailed:
                    return new IcmpConversionFailedLayer
                           {
                               Code = random.NextEnum<IcmpCodeConversionFailed>(),
                               Checksum = checksum,
                               Pointer = random.NextUInt(),
                           };

                case IcmpMessageType.DomainNameRequest:
                    return new IcmpDomainNameRequestLayer
                           {
                               Checksum = checksum,
                               Identifier = random.NextUShort(),
                               SequenceNumber = random.NextUShort(),
                           };

                case IcmpMessageType.DomainNameReply:
                    throw new NotSupportedException("Message Type " + icmpMessageType + " is not supported");

                case IcmpMessageType.SecurityFailures:
                    return new IcmpSecurityFailuresLayer
                           {
                               Code = random.NextEnum<IcmpCodeSecurityFailure>(),
                               Checksum = checksum,
                               Pointer = random.NextUShort()
                           };

                default:
                    throw new InvalidOperationException("Invalid icmpMessageType " + icmpMessageType);
            }
        }

        public static IEnumerable<ILayer> NextIcmpPayloadLayers(this Random random, IcmpLayer icmpLayer)
        {
            IEnumerable<ILayer> icmpPayloadLayers = new List<ILayer>();
            switch (icmpLayer.MessageType)
            {
                case IcmpMessageType.DestinationUnreachable:
                case IcmpMessageType.TimeExceeded:
                case IcmpMessageType.SourceQuench:
                case IcmpMessageType.Redirect:
                case IcmpMessageType.SecurityFailures:
                    icmpPayloadLayers = IEnumerableExtensions.Concat(icmpPayloadLayers, random.NextIpV4Layer(), random.NextPayloadLayer(IcmpIpV4HeaderPlus64BitsPayloadDatagram.OriginalDatagramPayloadLength));
                    break;
                case IcmpMessageType.ParameterProblem:
                    IpV4Layer ipV4Layer = random.NextIpV4Layer();
                    icmpPayloadLayers =
                        IEnumerableExtensions.Concat(icmpPayloadLayers, ipV4Layer,
                                                     random.NextPayloadLayer(random.NextInt(0,
                                                                                            IcmpParameterProblemLayer.OriginalDatagramLengthMaxValue + 1 -
                                                                                            ipV4Layer.Length)));
                    break;
                case IcmpMessageType.ConversionFailed:
                    IpV4Layer icmpIpV4Layer = random.NextIpV4Layer();
                    icmpPayloadLayers = IEnumerableExtensions.Concat(icmpPayloadLayers, icmpIpV4Layer);
                    if (icmpLayer.MessageTypeAndCode == IcmpMessageTypeAndCode.ConversionFailedUnsupportedTransportProtocol)
                    {
                        icmpPayloadLayers =
                            IEnumerableExtensions.Concat(icmpPayloadLayers, random.NextPayloadLayer(
                                IcmpConversionFailedDatagram.OriginalDatagramLengthForUnsupportedTransportProtocol -
                                icmpIpV4Layer.Length));
                    }
                    else
                    {
                        switch (icmpIpV4Layer.Protocol)
                        {
                            case IpV4Protocol.Udp:
                                icmpPayloadLayers = IEnumerableExtensions.Concat(icmpPayloadLayers, random.NextUdpLayer(),
                                                                             random.NextPayloadLayer(random.Next(100)));
                                break;

                            case IpV4Protocol.Tcp:
                                icmpPayloadLayers = IEnumerableExtensions.Concat(icmpPayloadLayers, random.NextTcpLayer(),
                                                                             random.NextPayloadLayer(random.Next(100)));
                                break;

                            default:
                                icmpPayloadLayers = IEnumerableExtensions.Concat(icmpPayloadLayers, random.NextPayloadLayer(random.Next(200)));

                                break;
                        }
                    }
                    break;

                case IcmpMessageType.Echo:
                case IcmpMessageType.EchoReply:
                case IcmpMessageType.Timestamp:
                case IcmpMessageType.TimestampReply:
                case IcmpMessageType.InformationRequest:
                case IcmpMessageType.InformationReply:
                case IcmpMessageType.RouterAdvertisement:
                case IcmpMessageType.RouterSolicitation:
                case IcmpMessageType.AddressMaskRequest:
                case IcmpMessageType.AddressMaskReply:
                case IcmpMessageType.TraceRoute:
                case IcmpMessageType.DomainNameRequest:
                    break;

                case IcmpMessageType.DomainNameReply:
                default:
                    throw new InvalidOperationException("Invalid icmpMessageType " + icmpLayer.MessageType);
            }
            return icmpPayloadLayers;
        }


        public static IEnumerable<IcmpRouterAdvertisementEntry> NextIcmpRouterAdvertisementEntries(this Random random, int numEntries)
        {
            for (int i = 0; i != numEntries; ++i)
                yield return new IcmpRouterAdvertisementEntry(random.NextIpV4Address(), random.Next());
        }


        #endregion Constructor

        #region IEnumerableExtensions Bvt TestCases

        /// <summary>
        /// Validate Shuffle method of IEnumerableExtensions by passing valid random object and sequences.
        /// Input Data : Valid random object and sequences.
        /// Output Data : Validate list of seqeunces.
        /// </summary>
        [TestMethod]
        [Priority(0)]
        [TestCategory("Priority0")]
        public void ValidateShuffleForValidIEnumItems()
        {
            sequences = utilityObj.xmlUtil.GetTextValue(
                Constants.IEnumerableExtensionsNode,
                Constants.Sequence1).Split(';');
            IEnumerable<string> enumerable = new string[] { sequences[0], sequences[1], sequences[2] };
            List<string> lists = enumerable.Shuffle(new Random());
            Assert.IsNotNull(lists);
            Assert.AreEqual(sequences.Length, lists.Count);

            foreach (string list in lists)
            {
                Assert.IsTrue(enumerable.Contains<string>(list));
            }

            ApplicationLog.WriteLine(string.Concat(
                  "IEnumerableExtensions BVT: Validation of Shuffle method for Random object and sequences completed successfully."));
        }

        /// <summary>
        /// Validate StringJoin method of IEnumerableExtensions by passing valid collection.
        /// Input Data : Valid collection.
        /// Output Data : Validate seqeunce.
        /// </summary>
        [TestMethod]
        [Priority(0)]
        [TestCategory("Priority0")]
        public void ValidateStringJoinForCollection()
        {
            string expectedSequence = utilityObj.xmlUtil.GetTextValue(
                Constants.IEnumerableExtensionsNode,
                Constants.ExpectedOutputNode);
            sequences = utilityObj.xmlUtil.GetTextValue(
                Constants.IEnumerableExtensionsNode,
                Constants.Sequence2).Split(';');

            IEnumerable<string> enumerable = new string[] { sequences[0], sequences[1], sequences[2], null };
            string join = enumerable.StringJoin();
            Assert.IsNotNull(join);
            Assert.AreEqual(expectedSequence, join);

            ApplicationLog.WriteLine(string.Concat(
                  "IEnumerableExtensions BVT: Validation of StringJoin method for sequences completed successfully."));
        }

        /// <summary>
        /// Validate StringJoin method of IEnumerableExtensions by passing valid collection with separator.
        /// Input Data : Valid collection with separator.
        /// Output Data : Validate seqeunce.
        /// </summary>
        [TestMethod]
        [Priority(0)]
        [TestCategory("Priority0")]
        public void ValidateStringJoinForSeparator()
        {
            string expectedSequence = utilityObj.xmlUtil.GetTextValue(
                Constants.IEnumerableExtensionsNode,
                Constants.ExpectedNormalString);
            sequences = utilityObj.xmlUtil.GetTextValue(
                Constants.IEnumerableExtensionsNode,
                Constants.Sequence2).Split(';');

            IEnumerable<string> enumerable = new string[] { sequences[0], sequences[1], sequences[2], null };
            string join = enumerable.StringJoin(":");
            Assert.IsNotNull(join);
            Assert.AreEqual(expectedSequence, join);

            ApplicationLog.WriteLine(string.Concat(
                  "IEnumerableExtensions BVT: Validation of StringJoin method for sequences and seperator completed successfully."));
        }

        /// <summary>
        /// Validate StringJoin method of IEnumerableExtensions by passing valid collection with separator and etcString.
        /// Input Data : Valid collection with separator and etcString.
        /// Output Data : Validate sequence.
        /// </summary>
        [TestMethod]
        [Priority(0)]
        [TestCategory("Priority0")]
        public void ValidateStringJoinForEtcString()
        {
            string expectedSequence = utilityObj.xmlUtil.GetTextValue(
                Constants.IEnumerableExtensionsNode,
                Constants.ExpectedSequence);
            string etcString = utilityObj.xmlUtil.GetTextValue(
                Constants.IEnumerableExtensionsNode,
                Constants.EtcStringNode);
            int maxLength = Convert.ToInt32(
                utilityObj.xmlUtil.GetTextValue(
                Constants.IEnumerableExtensionsNode,
                Constants.MaxAttemptString),
                CultureInfo.InvariantCulture);
            sequences = utilityObj.xmlUtil.GetTextValue(
                Constants.IEnumerableExtensionsNode,
                Constants.Sequence2).Split(';');

            IEnumerable<string> enumerable = new string[] { sequences[0], sequences[1], sequences[2], null };
            string join = enumerable.StringJoin(":", maxLength, etcString);
            Assert.IsNotNull(join);
            Assert.AreEqual(expectedSequence, join);

            ApplicationLog.WriteLine(string.Concat(
                  "IEnumerableExtensions BVT: Validation of StringJoin method for sequences, seperator, length and etc-string completed successfully."));
        }

        /// <summary>
        /// Validate ToHashSet method of IEnumerableExtensions by passing valid collection.
        /// Input Data : Valid collection.
        /// Output Data : Validate HashSet sequence.
        /// </summary>
        [TestMethod]
        [Priority(0)]
        [TestCategory("Priority0")]
        public void ValidateToHashSetForCollection()
        {
            sequences = utilityObj.xmlUtil.GetTextValue(
                Constants.IEnumerableExtensionsNode,
                Constants.Sequence2).Split(';');

            IEnumerable<string> enumerable = new string[] { sequences[0], sequences[1], sequences[2] };
            HashSet<string> joins = enumerable.ToHashSet();
            Assert.IsNotNull(joins);
            Assert.IsTrue(joins.Contains(sequences[0]));
            Assert.IsTrue(joins.Contains(sequences[1]));
            Assert.IsTrue(joins.Contains(sequences[2]));

            ApplicationLog.WriteLine(string.Concat(
                  "IEnumerableExtensions BVT: Validation of ToHashSet method for sequences completed successfully."));
        }

        /// <summary>
        /// Validate ToQueue method of IEnumerableExtensions by passing valid collection.
        /// Input Data : Valid collection.
        /// Output Data : Validate HashSet sequence.
        /// </summary>
        [TestMethod]
        [Priority(0)]
        [TestCategory("Priority0")]
        public void ValidateToQueueForCollection()
        {
            sequences = utilityObj.xmlUtil.GetTextValue(
                Constants.IEnumerableExtensionsNode,
                Constants.Sequence2).Split(';');

            IEnumerable<string> enumerable = new string[] { sequences[0], sequences[1], sequences[2] };
            Queue<string> joins = enumerable.ToQueue();
            Assert.IsNotNull(joins);
            Assert.IsTrue(joins.Contains(sequences[0]));
            Assert.IsTrue(joins.Contains(sequences[1]));
            Assert.IsTrue(joins.Contains(sequences[2]));

            ApplicationLog.WriteLine(string.Concat(
                  "IEnumerableExtensions BVT: Validation of ToQueue method for sequences completed successfully."));
        }


        #endregion Constructor

        #region IEnumerableExtensions Bvt TestCases

        /// <summary>
        /// Validate Shuffle method of IEnumerableExtensions by passing valid random object and sequences.
        /// Input Data : Valid random object and sequences.
        /// Output Data : Validate list of seqeunces.
        /// </summary>
        [TestMethod]
        [Priority(0)]
        [TestCategory("Priority0")]
        public void ValidateShuffleForValidIEnumItems()
        {
            sequences = utilityObj.xmlUtil.GetTextValue(
                Constants.IEnumerableExtensionsNode,
                Constants.Sequence1).Split(';');
            IEnumerable<string> enumerable = new string[] { sequences[0], sequences[1], sequences[2] };
            List<string> lists = enumerable.Shuffle(new Random());
            Assert.IsNotNull(lists);
            Assert.AreEqual(sequences.Length, lists.Count);

            foreach (string list in lists)
            {
                Assert.IsTrue(enumerable.Contains<string>(list));
            }

            ApplicationLog.WriteLine(string.Concat(
                  "IEnumerableExtensions BVT: Validation of Shuffle method for Random object and sequences completed successfully."));
        }

        /// <summary>
        /// Validate StringJoin method of IEnumerableExtensions by passing valid collection.
        /// Input Data : Valid collection.
        /// Output Data : Validate seqeunce.
        /// </summary>
        [TestMethod]
        [Priority(0)]
        [TestCategory("Priority0")]
        public void ValidateStringJoinForCollection()
        {
            string expectedSequence = utilityObj.xmlUtil.GetTextValue(
                Constants.IEnumerableExtensionsNode,
                Constants.ExpectedOutputNode);
            sequences = utilityObj.xmlUtil.GetTextValue(
                Constants.IEnumerableExtensionsNode,
                Constants.Sequence2).Split(';');

            IEnumerable<string> enumerable = new string[] { sequences[0], sequences[1], sequences[2], null };
            string join = enumerable.StringJoin();
            Assert.IsNotNull(join);
            Assert.AreEqual(expectedSequence, join);

            ApplicationLog.WriteLine(string.Concat(
                  "IEnumerableExtensions BVT: Validation of StringJoin method for sequences completed successfully."));
        }

        /// <summary>
        /// Validate StringJoin method of IEnumerableExtensions by passing valid collection with separator.
        /// Input Data : Valid collection with separator.
        /// Output Data : Validate seqeunce.
        /// </summary>
        [TestMethod]
        [Priority(0)]
        [TestCategory("Priority0")]
        public void ValidateStringJoinForSeparator()
        {
            string expectedSequence = utilityObj.xmlUtil.GetTextValue(
                Constants.IEnumerableExtensionsNode,
                Constants.ExpectedNormalString);
            sequences = utilityObj.xmlUtil.GetTextValue(
                Constants.IEnumerableExtensionsNode,
                Constants.Sequence2).Split(';');

            IEnumerable<string> enumerable = new string[] { sequences[0], sequences[1], sequences[2], null };
            string join = enumerable.StringJoin(":");
            Assert.IsNotNull(join);
            Assert.AreEqual(expectedSequence, join);

            ApplicationLog.WriteLine(string.Concat(
                  "IEnumerableExtensions BVT: Validation of StringJoin method for sequences and seperator completed successfully."));
        }

        /// <summary>
        /// Validate StringJoin method of IEnumerableExtensions by passing valid collection with separator and etcString.
        /// Input Data : Valid collection with separator and etcString.
        /// Output Data : Validate sequence.
        /// </summary>
        [TestMethod]
        [Priority(0)]
        [TestCategory("Priority0")]
        public void ValidateStringJoinForEtcString()
        {
            string expectedSequence = utilityObj.xmlUtil.GetTextValue(
                Constants.IEnumerableExtensionsNode, Constants.ExpectedSequence);
            string etcString = utilityObj.xmlUtil.GetTextValue(
                Constants.IEnumerableExtensionsNode, Constants.EtcStringNode);
            int maxLength = Convert.ToInt32(utilityObj.xmlUtil.GetTextValue(
                Constants.IEnumerableExtensionsNode, Constants.MaxAttemptString), CultureInfo.InvariantCulture);
            sequences = utilityObj.xmlUtil.GetTextValue(Constants.IEnumerableExtensionsNode, Constants.Sequence2).Split(';');

            IEnumerable<string> enumerable = new[] { sequences[0], sequences[1], sequences[2], null };
            string join = enumerable.StringJoin(":", maxLength, etcString);
            Assert.IsNotNull(join);
            Assert.AreEqual(expectedSequence, join);

            ApplicationLog.WriteLine("IEnumerableExtensions BVT: Validation of StringJoin method for sequences, separator, length and etc-string completed successfully.");
        }

        /// <summary>
        /// Validate ToHashSet method of IEnumerableExtensions by passing valid collection.
        /// Input Data : Valid collection.
        /// Output Data : Validate HashSet sequence.
        /// </summary>
        [TestMethod]
        [Priority(0)]
        [TestCategory("Priority0")]
        public void ValidateToHashSetForCollection()
        {
            sequences = utilityObj.xmlUtil.GetTextValue(
                Constants.IEnumerableExtensionsNode,
                Constants.Sequence2).Split(';');

            IEnumerable<string> enumerable = new string[] { sequences[0], sequences[1], sequences[2] };
            HashSet<string> joins = enumerable.ToHashSet();
            Assert.IsNotNull(joins);
            Assert.IsTrue(joins.Contains(sequences[0]));
            Assert.IsTrue(joins.Contains(sequences[1]));
            Assert.IsTrue(joins.Contains(sequences[2]));

            ApplicationLog.WriteLine(string.Concat(
                  "IEnumerableExtensions BVT: Validation of ToHashSet method for sequences completed successfully."));
        }

        /// <summary>
        /// Validate ToQueue method of IEnumerableExtensions by passing valid collection.
        /// Input Data : Valid collection.
        /// Output Data : Validate HashSet sequence.
        /// </summary>
        [TestMethod]
        [Priority(0)]
        [TestCategory("Priority0")]
        public void ValidateToQueueForCollection()
        {
            sequences = utilityObj.xmlUtil.GetTextValue(
                Constants.IEnumerableExtensionsNode,
                Constants.Sequence2).Split(';');

            IEnumerable<string> enumerable = new string[] { sequences[0], sequences[1], sequences[2] };
            Queue<string> joins = enumerable.ToQueue();
            Assert.IsNotNull(joins);
            Assert.IsTrue(joins.Contains(sequences[0]));
            Assert.IsTrue(joins.Contains(sequences[1]));
            Assert.IsTrue(joins.Contains(sequences[2]));

            ApplicationLog.WriteLine(string.Concat(
                  "IEnumerableExtensions BVT: Validation of ToQueue method for sequences completed successfully."));
        }

XAct.IEnumerableExtensions : Object

Methods :

public static Boolean Exists(IEnumerable<T> collection = , Predicate<T> predicateToApply = )
public static IEnumerable<T> Filter(IEnumerable<T> collection = , Predicate<T> predicateToApply = )
public static Boolean Find(IEnumerable<T> collection = , Predicate<T> predicateToApply = , T& matchedItem = )
public static Int32 FindIndex(IEnumerable<T> collection = , Predicate<T> predicateToApply = , T& matchedItem = )
public static Boolean FindLast(IEnumerable<T> collection = , Predicate<T> predicateToApply = , T& matchedItem = )
public static Void ForEach(IEnumerable<T> collection = , Action<T> actionToApply = )
public static Void ForEach(IEnumerable enumerable = , Action<T> action = )
public static IEnumerable<TReturn> Map(IEnumerable<TCollectionItem> collection = , Func<TCollectionItem, TReturn> functionToApply = )
public static IEnumerable<T> GetItemsContainedInBothLists(IEnumerable<T> first = , IEnumerable<T> second = , Func<T, Object> expression = )
public static IEnumerable<T> GetItemsExceptThoseFoundInBothLists(IEnumerable<T> first = , IEnumerable<T> second = , Func<T, Object> expression = )
public static IEnumerable<T> Except(IEnumerable<T> referenceCollection = , IEnumerable<T> updatedCollection = , Func<T, Object> expression = )
public static IEnumerable<T> Intersect(IEnumerable<T> first = , IEnumerable<T> second = , Func<T, Object> expression = )
public static IEnumerable<T> Union(IEnumerable<T> first = , IEnumerable<T> second = , Func<T, Object> expression = )
public static Void ForEach(IEnumerable<T> firstCollection = , IEnumerable<T> secondCollection = , Func<T, Object> matchExpression = , Action<TT> updateSecondCollectionItemOverFirstCollectionItemAction = )
public static String CollectionToString(IEnumerable collection = , String divChar = )
public static IEnumerable<Int32> To(Int32 from = , Int32 to = )
public static IEnumerable<T> AtOddPositions(IEnumerable<T> list = )
public static IEnumerable<T> AtEvenPositions(IEnumerable<T> list = )
public static String ConvertListToInClause(IEnumerable list = , String formatCode = , Boolean useQuotes = , Boolean useLowercase = , Boolean addBrackets = )
public static IEnumerable<T> Append(IEnumerable<T> collection = , T item = )
public static IEnumerable<T> Prepend(IEnumerable<T> collection = , T item = )
public static T ArgMax(IEnumerable<T> collection = , Func<T, TValue> function = )
public static T ArgMin(IEnumerable<T> collection = , Func<T, TValue> function = )
public static String[] ToStringArray(IEnumerable<T> x = )
public static String JoinSafely(IEnumerable<T> items = , String separator = )
public static IEnumerable<TSource> DistinctBy(IEnumerable<TSource> source = , Expression<Func<TSource, TKey>> keySelector = )
public static List<T> AddIfNotAlreadyAdded(IEnumerable<T> list = , T item = , Expression<Func<T, TProperty>> keySelector = )
public static List<T> AddIfNotAlreadyAdded(IEnumerable<T> list = , IEnumerable<T> items = , Expression<Func<T, TProperty>> keySelector = )
public static List<T> AddIfNotAlreadyAdded(IEnumerable<T> list = , T item = )
public static List<T> AddIfNotAlreadyAdded(IEnumerable<T> list = , IEnumerable<T> items = )
public static Int32 IndexOf(IEnumerable<T> items = , Func<T, Boolean> predicate = )
public static Int32 IndexOf(IEnumerable<T> items = , T item = )
public static IEnumerable<T> TopologicalSort(IEnumerable<T> source = , Func<T, IEnumerable<T>> dependencies = , Boolean throwOnCycle = False)
public static String ToDelimited(IEnumerable<T> list = , String separator = , Func<T, String> toStringFunction = )
public static IEnumerable<TSource> GetDuplicates(IEnumerable<TSource> source = , Func<TSource, TKey> selector = )
public static Boolean IsMultiple(IEnumerable<T> source = )
public static Boolean None(IEnumerable<TSource> source = )
public static IList<TSource> Except(IEnumerable<TSource> source = , TSource item = )
public static Boolean AllValuesUnique(IEnumerable<T> source = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()