public void Must_ReturnAnInstanceThatWrapsTheSuppliedIEnumerable( IEnumerable <object> source) { var snumerable = Smartnumerable.Create(source); AssertionExtensions.SequencesAreEqual(source, snumerable); }
public void OnFirstEnumeration_Must_SuccessfullyEnumerateTheSourceCollection(IEnumerable <string> sourceEnumerable) { var originalEnumerable = CreateOneTimeEnumerable(sourceEnumerable); var smartnumerable = BuildEnumerableWithSmartnumerator(originalEnumerable); var result1 = smartnumerable.ToArray(); AssertionExtensions.SequencesAreEqual(sourceEnumerable, result1); }
public void Must_InsertAValue_AtTheEndOfArray( string[] input, string value, string[] expectedResult) { var result = target.Insert(input, input.Length, value); AssertionExtensions.SequencesAreEqual(expectedResult, result); }
public void Must_ReturnAllTransformedRows( IList <string[]> rows) { Setup_Transformer_ToReturnTheInput(); var result = target.TransformRows(transformer.Object, rows.ToArray(), rows[0].Length); AssertionExtensions.SequencesAreEqual(rows, result); }
public void Must_InsertAValue_WhenItsTheFirstElementInTheArray( string[] input, string value, string[] expectedResult) { var result = target.Insert(input, 0, value); AssertionExtensions.SequencesAreEqual(expectedResult, result); }
public void Must_InsertAValue_BetweenExistingArrayElements( string[] input, int targetPosition, string value, string[] expectedResult) { var result = target.Insert(input, targetPosition, value); AssertionExtensions.SequencesAreEqual(expectedResult, result); }
public void Must_SuccessfullyReturnAllRows__WhenTheyAreAllOfTheSameLength(IList <string[]> rows) { var expectedCollection = rows.ToArray(); Setup_TheReader(rows); var result = target.Read(new Mock <Stream>().Object).ToArray(); AssertionExtensions.SequencesAreEqual(expectedCollection, result); }
public void Must_ReturnAllRows(IList <string[]> rows) { var expectedRows = rows.ToArray(); Setup_StreamReader_NumberOfRows(rows.Count); Setup_RowParser_ReturnSequence_ThenThrowAnException(rows); var result = target.ReadRows(stream.Object) .ToArray(); AssertionExtensions.SequencesAreEqual(expectedRows, result); }
public void Must_Return_OnlyTheRowsTheEvaluatedDeemedWorthyOfBeingReturned( IList <string[]> rows, IList <bool> matches, IList <string[]> expectedRows) { var matcher = new Mock <IRowMatchEvaluator>(); Setup_MatchEvaluator(matcher, matches); var result = target.Filter(rows, matcher.Object).ToArray(); AssertionExtensions.SequencesAreEqual(expectedRows, result); }
public void AddingItems__When_SourceIsEmptyInitially__Must_AddItemAtTheEndOfCollection(IList <string> values) { var source = new List <string>(); target = new WritingEnumerator <string>(source); foreach (var value in values) { target.Add(value); } AssertionExtensions.SequencesAreEqual(values, source); }
public void Must_ReturnTheResultsAsSmartnumerable() { var rows = GetEnumerable(); expensiveReader.Setup( x => x.ReadRows( It.IsAny <Stream>())) .Returns(rows); var input = new Mock <Stream>().Object; var result = target.ReadRows(input); AssertionExtensions.SequencesAreEqual(rows, result); Assert.IsTrue(result is Smartnumerable <string[]>); }
public void AddingItems__When_SourceIsNotEmptyInitially__Must_AddItemAtTheEndOfCollection( IList <string> source, IList <string> values) { var expectedCollection = source.Concat(values).ToList(); target = new WritingEnumerator <string>(source); foreach (var value in values) { target.Add(value); } AssertionExtensions.SequencesAreEqual(expectedCollection, source); }
public void Must_ReplaceTheTargetArrayItem_WithTheTransformedValue( IList <string> cells, int targetColumnIndex, string newValue, IList <string> expectedCells) { valueTransformer.Setup( x => x.GetValue(It.IsAny <string>())) .Returns(newValue); target = new SingleValueTransformer(targetColumnIndex, valueTransformer.Object); var result = target.Transform(cells.ToArray()); AssertionExtensions.SequencesAreEqual(expectedCells, result); }
public void Must_Return_ARowReturnByTheArrayElementInserter( IList <string> row) { var expectedRow = row.ToArray(); elementInserter.Setup( x => x.Insert( It.IsAny <string[]>(), It.IsAny <int>(), It.IsAny <string>())) .Returns(row.ToArray()); //make a separate copy to make sure i spot if it's modified before getting returned var result = target.Insert(new string[0], 0, default); AssertionExtensions.SequencesAreEqual(expectedRow, result); }
private void AfterFirstCompleteEnumeration_OnSubsequentEnumerations_Must_ReturnAllTheValuesWithoutTalkingToTheOriginalCollection( IEnumerable <string> sourceEnumerable, int subsequentEnumerationCount) { var originalEnumerable = CreateOneTimeEnumerable(sourceEnumerable); var enumerable = BuildEnumerableWithSmartnumerator(originalEnumerable); enumerable.ToArray(); for (int i = 0; i < subsequentEnumerationCount; i++) { var result = enumerable.ToArray(); AssertionExtensions.SequencesAreEqual(sourceEnumerable, result); } }
public void Must_Return_FirstLineAsHeaderCells( IList <string> headerCells, IList <string[]> contentRows) { var expected = headerCells; var input = Combine(headerCells, contentRows); Setup_StreamReader(input); var stream = new Mock <Stream>(); var result = target.Read(stream.Object); AssertionExtensions.SequencesAreEqual(expected, result.HeaderCells); }
public void Must_Return_TheRestAsContentRows( IList <string> headerCells, IList <string[]> contentRows) { var expected = contentRows.ToArray(); var input = Combine(headerCells, contentRows); Setup_StreamReader(input); var stream = new Mock <Stream>(); var result = target.Read(stream.Object); for (int i = 0; i < expected.Length; i++) { Assert.AreNotEqual(i, result.ContentRows.Length, "The resulting collection can't be smaller than the expected one"); AssertionExtensions.SequencesAreEqual(expected[i], result.ContentRows[i]); } }
private void RunMultipleEnumerations_ExpectToGetSameResultsThatTheEnumerationOfTheTestSourceEnumerableYields( IEnumerable <string> sourceEnumerable, int itemsToTakeFirstTime, int[] itemsToTakeOnSubsequentEnumerations) { var originalEnumerable = CreateOneTimeEnumerable(sourceEnumerable); var enumerable = BuildEnumerableWithSmartnumerator(originalEnumerable); //incomplete first enumeration enumerable.Take(itemsToTakeFirstTime).ToList(); //subsequent enumerations for (int i = 0; i < itemsToTakeOnSubsequentEnumerations.Length; i++) { int itemsToTakeOnSubsequentEnumeration = itemsToTakeOnSubsequentEnumerations[i]; var expectedCollection = sourceEnumerable.Take(itemsToTakeOnSubsequentEnumeration).ToList(); var result = enumerable.Take(itemsToTakeOnSubsequentEnumeration).ToList(); AssertionExtensions.SequencesAreEqual(expectedCollection, result, $"Enumeration {i}"); } }