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

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

            Assert.That(outputString, Is.EqualTo(expectedString));
        }
Exemple #2
0
        public void Lag_NullCollection_ThrowsArgumentNullException()
        {
            IEnumerable <int> collection = null;

            Assert.Throws <ArgumentNullException>(() => CollectionExtensions.Lag(collection));
        }
Exemple #3
0
        public void Lag_NegativeAmount_ThrowsArgumentOutOfRangeException()
        {
            IEnumerable <int> collection = Enumerable.Range(0, 10);

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