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)); }
public void Lag_NullCollection_ThrowsArgumentNullException() { IEnumerable <int> collection = null; Assert.Throws <ArgumentNullException>(() => CollectionExtensions.Lag(collection)); }
public void Lag_NegativeAmount_ThrowsArgumentOutOfRangeException() { IEnumerable <int> collection = Enumerable.Range(0, 10); Assert.Throws <ArgumentOutOfRangeException>(() => CollectionExtensions.Lag(collection, -1)); }