コード例 #1
0
        public void Lead_WithTestCases_ProducesCorrectResults(string collectionString, int amount, string expectedString)
        {
            int[] collection = collectionString.Split(',').Where(s => !string.IsNullOrWhiteSpace(s)).Select(int.Parse).ToArray();

            var output       = CollectionExtensions.Lead(collection, amount);
            var outputString = string.Join(",", output.Select(item => $"({item.Element},{item.LeadingElement})"));

            Assert.That(outputString, Is.EqualTo(expectedString));
        }
コード例 #2
0
        public void Lead_NullCollection_ThrowsArgumentNullException()
        {
            IEnumerable <int> collection = null;

            Assert.Throws <ArgumentNullException>(() => CollectionExtensions.Lead(collection));
        }
コード例 #3
0
        public void Lead_NegativeAmount_ThrowsArgumentOutOfRangeException()
        {
            IEnumerable <int> collection = Enumerable.Range(0, 10);

            Assert.Throws <ArgumentOutOfRangeException>(() => CollectionExtensions.Lead(collection, -1));
        }